tests: add fallback_func argument to TEST_NESTED_NLATTR_OBJECT_EX_
* tests/test_nlattr.h (TEST_NESTED_NLATTR_OBJECT_EX_): Add fallback_func argument, call it instead of print_quoted_hex. (TEST_NESTED_NLATTR_OBJECT_EX, TEST_NESTED_NLATTR_OBJECT): Specify print_quoted_hex as a fallback_func. * tests/nlattr_ifla_af_spec.c: Specify print_quoted_hex as a fallback_func in TEST_NESTED_NLATTR_OBJECT_EX_ calls.
This commit is contained in:
parent
49d030ab8a
commit
b178553f22
@ -188,12 +188,12 @@ main(void)
|
||||
TEST_NESTED_NLATTR_OBJECT_EX_(fd, nlh0, hdrlen,
|
||||
init_AF_INET_msg, print_AF_INET_msg,
|
||||
0, "IFLA_INET_UNSPEC", pattern,
|
||||
unknown_msg, 2,
|
||||
unknown_msg, print_quoted_hex, 2,
|
||||
printf("\"\\xab\\xac\\xdb\\xcd\""));
|
||||
TEST_NESTED_NLATTR_OBJECT_EX_(fd, nlh0, hdrlen,
|
||||
init_AF_INET_msg, print_AF_INET_msg,
|
||||
2, "0x2 /* IFLA_INET_??? */", pattern,
|
||||
unknown_msg, 2,
|
||||
unknown_msg, print_quoted_hex, 2,
|
||||
printf("\"\\xab\\xac\\xdb\\xcd\""));
|
||||
|
||||
/* AF_INET: IFLA_INET_CONF */
|
||||
@ -207,12 +207,12 @@ main(void)
|
||||
TEST_NESTED_NLATTR_OBJECT_EX_(fd, nlh0, hdrlen,
|
||||
init_AF_INET6_msg, print_AF_INET6_msg,
|
||||
0, "IFLA_INET6_UNSPEC", pattern,
|
||||
unknown_msg, 2,
|
||||
unknown_msg, print_quoted_hex, 2,
|
||||
printf("\"\\xab\\xac\\xdb\\xcd\""));
|
||||
TEST_NESTED_NLATTR_OBJECT_EX_(fd, nlh0, hdrlen,
|
||||
init_AF_INET6_msg, print_AF_INET6_msg,
|
||||
9, "0x9 /* IFLA_INET6_??? */", pattern,
|
||||
unknown_msg, 2,
|
||||
unknown_msg, print_quoted_hex, 2,
|
||||
printf("\"\\xab\\xac\\xdb\\xcd\""));
|
||||
|
||||
/* AF_INET6: IFLA_INET6_FLAGS */
|
||||
@ -232,7 +232,8 @@ main(void)
|
||||
init_AF_INET6_msg,
|
||||
print_AF_INET6_msg,
|
||||
1, "IFLA_INET6_FLAGS", pattern,
|
||||
inet6_flags[i].flags, 2,
|
||||
inet6_flags[i].flags,
|
||||
print_quoted_hex, 2,
|
||||
printf("%s", inet6_flags[i].str));
|
||||
}
|
||||
|
||||
@ -254,7 +255,7 @@ main(void)
|
||||
TEST_NESTED_NLATTR_OBJECT_EX_(fd, nlh0, hdrlen,
|
||||
init_AF_INET6_msg, print_AF_INET6_msg,
|
||||
4, "IFLA_INET6_MCAST", pattern,
|
||||
unknown_msg, 2,
|
||||
unknown_msg, print_quoted_hex, 2,
|
||||
printf("\"\\xab\\xac\\xdb\\xcd\""));
|
||||
|
||||
/* AF_INET6: IFLA_INET6_CACHEINFO */
|
||||
@ -264,7 +265,7 @@ main(void)
|
||||
TEST_NESTED_NLATTR_OBJECT_EX_(fd, nlh0, hdrlen,
|
||||
init_AF_INET6_msg, print_AF_INET6_msg,
|
||||
5, "IFLA_INET6_CACHEINFO", pattern,
|
||||
ci, 2,
|
||||
ci, print_quoted_hex, 2,
|
||||
PRINT_FIELD_U("{", ci, max_reasm_len);
|
||||
PRINT_FIELD_U(", ", ci, tstamp);
|
||||
PRINT_FIELD_U(", ", ci, reachable_time);
|
||||
@ -290,7 +291,7 @@ main(void)
|
||||
TEST_NESTED_NLATTR_OBJECT_EX_(fd, nlh0, hdrlen,
|
||||
init_AF_INET6_msg, print_AF_INET6_msg,
|
||||
7, "IFLA_INET6_TOKEN", pattern,
|
||||
inet6_addr, 2,
|
||||
inet6_addr, print_quoted_hex, 2,
|
||||
printf("badc:ded:face:beef:deca:feed"
|
||||
":dead:feed"));
|
||||
|
||||
@ -310,7 +311,8 @@ main(void)
|
||||
init_AF_INET6_msg,
|
||||
print_AF_INET6_msg,
|
||||
8, "IFLA_INET6_ADDR_GEN_MODE",
|
||||
pattern, agms[i].flags, 2,
|
||||
pattern, agms[i].flags,
|
||||
print_quoted_hex, 2,
|
||||
printf("%s", agms[i].str));
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,8 @@ print_nlattr(const unsigned int nla_len, const char *const nla_type, bool add_da
|
||||
#define TEST_NESTED_NLATTR_OBJECT_EX_(fd_, nlh0_, hdrlen_, \
|
||||
init_msg_, print_msg_, \
|
||||
nla_type_, nla_type_str_, \
|
||||
pattern_, obj_, depth_, ...) \
|
||||
pattern_, obj_, fallback_func, \
|
||||
depth_, ...) \
|
||||
do { \
|
||||
const unsigned int plen = \
|
||||
sizeof(obj_) - 1 > DEFAULT_STRLEN \
|
||||
@ -235,7 +236,7 @@ print_nlattr(const unsigned int nla_len, const char *const nla_type, bool add_da
|
||||
(init_msg_), (print_msg_), \
|
||||
(nla_type_), (nla_type_str_), \
|
||||
plen, (pattern_), plen, \
|
||||
print_quoted_hex((pattern_), plen); \
|
||||
(fallback_func)((pattern_), plen); \
|
||||
size_t i; \
|
||||
for (i = 0; i < depth_; ++i) \
|
||||
printf("}")); \
|
||||
@ -270,7 +271,8 @@ print_nlattr(const unsigned int nla_len, const char *const nla_type, bool add_da
|
||||
TEST_NESTED_NLATTR_OBJECT_EX_((fd_), (nlh0_), (hdrlen_), \
|
||||
(init_msg_), (print_msg_), \
|
||||
(nla_type_), #nla_type_, \
|
||||
(pattern_), (obj_), (depth_), \
|
||||
(pattern_), (obj_), \
|
||||
print_quoted_hex, (depth_), \
|
||||
__VA_ARGS__)
|
||||
|
||||
#define TEST_NESTED_NLATTR_OBJECT(fd_, nlh0_, hdrlen_, \
|
||||
@ -279,7 +281,8 @@ print_nlattr(const unsigned int nla_len, const char *const nla_type, bool add_da
|
||||
TEST_NESTED_NLATTR_OBJECT_EX_((fd_), (nlh0_), (hdrlen_), \
|
||||
(init_msg_), (print_msg_), \
|
||||
(nla_type_), #nla_type_, \
|
||||
(pattern_), (obj_), 1, \
|
||||
(pattern_), (obj_), \
|
||||
print_quoted_hex, 1, \
|
||||
__VA_ARGS__)
|
||||
|
||||
#define TEST_NESTED_NLATTR_ARRAY_EX(fd_, nlh0_, hdrlen_, \
|
||||
|
Loading…
x
Reference in New Issue
Block a user