]> granicus.if.org Git - strace/commitdiff
tests: add fallback_func argument to TEST_NESTED_NLATTR_OBJECT_EX_
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sun, 10 Jun 2018 10:49:20 +0000 (12:49 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 11 Jun 2018 14:02:06 +0000 (14:02 +0000)
* 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.

tests/nlattr_ifla_af_spec.c
tests/test_nlattr.h

index 287e0817f4f63fcb3d40ad7ef796fe775fef7e5b..24f55af6a18a2598b15b13cec3d7920031f7aa77 100644 (file)
@@ -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));
        }
 
index f5ee8cbd2c9bcb738b4ae35233ae74558ec6c5c5..21264200f81300564619ede2da755ac1daba99c8 100644 (file)
@@ -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_,               \