]> granicus.if.org Git - strace/commitdiff
tests: extend TEST_NLATTR_OBJECT macro
authorJingPiao Chen <chenjingpiao@gmail.com>
Thu, 20 Jul 2017 08:45:58 +0000 (16:45 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 24 Jul 2017 11:18:43 +0000 (11:18 +0000)
* tests/test_nlattr.h (TEST_NLATTR_OBJECT_EX_,
TEST_NLATTR_OBJECT_EX): New macros.
(TEST_NLATTR_OBJECT): Use TEST_NLATTR_OBJECT_EX_.

tests/test_nlattr.h

index 4585893da1e3ef7bf74173c648a833802ebcad42..204c4371e791681f12d6b8ae806a3457dfee26b5 100644 (file)
@@ -96,9 +96,10 @@ print_nlattr(const unsigned int nla_len, const char *const nla_type)
                (nla_type_), #nla_type_,                                \
                (nla_data_len_), (src_), (slen_), __VA_ARGS__)
 
-#define TEST_NLATTR_OBJECT(fd_, nlh0_, hdrlen_,                                \
-                          init_msg_, print_msg_,                       \
-                          nla_type_, pattern_, obj_, ...)              \
+#define TEST_NLATTR_OBJECT_EX_(fd_, nlh0_, hdrlen_,                    \
+                              init_msg_, print_msg_,                   \
+                              nla_type_, nla_type_str_,                \
+                              pattern_, obj_, fallback_func, ...)      \
        do {                                                            \
                const unsigned int plen =                               \
                        sizeof(obj_) - 1 > DEFAULT_STRLEN               \
@@ -106,13 +107,13 @@ print_nlattr(const unsigned int nla_len, const char *const nla_type)
                /* len < sizeof(obj_) */                                \
                TEST_NLATTR_((fd_), (nlh0_), (hdrlen_),                 \
                        (init_msg_), (print_msg_),                      \
-                       (nla_type_), #nla_type_,                        \
+                       (nla_type_), (nla_type_str_),                   \
                        plen, (pattern_), plen,                         \
-                       print_quoted_hex((pattern_), plen));            \
+                       (fallback_func)((pattern_), plen));             \
                /* short read of sizeof(obj_) */                        \
                TEST_NLATTR_((fd_), (nlh0_), (hdrlen_),                 \
                        (init_msg_), (print_msg_),                      \
-                       (nla_type_), #nla_type_,                        \
+                       (nla_type_), (nla_type_str_),                   \
                        sizeof(obj_),                                   \
                        (pattern_), sizeof(obj_) - 1,                   \
                        printf("%p",                                    \
@@ -120,12 +121,31 @@ print_nlattr(const unsigned int nla_len, const char *const nla_type)
                /* sizeof(obj_) */                                      \
                TEST_NLATTR_((fd_), (nlh0_), (hdrlen_),                 \
                        (init_msg_), (print_msg_),                      \
-                       (nla_type_), #nla_type_,                        \
+                       (nla_type_), (nla_type_str_),                   \
                        sizeof(obj_),                                   \
                        &(obj_), sizeof(obj_),                          \
                        __VA_ARGS__);                                   \
        } while (0)
 
+#define TEST_NLATTR_OBJECT_EX(fd_, nlh0_, hdrlen_,                     \
+                             init_msg_, print_msg_,                    \
+                             nla_type_,                                \
+                             pattern_, obj_, fallback_func, ...)       \
+       TEST_NLATTR_OBJECT_EX_((fd_), (nlh0_), (hdrlen_),               \
+                              (init_msg_), (print_msg_),               \
+                              (nla_type_), #nla_type_,                 \
+                              (pattern_), (obj_), (fallback_func),     \
+                              __VA_ARGS__)
+
+#define TEST_NLATTR_OBJECT(fd_, nlh0_, hdrlen_,                                \
+                          init_msg_, print_msg_,                       \
+                          nla_type_, pattern_, obj_, ...)              \
+       TEST_NLATTR_OBJECT_EX_((fd_), (nlh0_), (hdrlen_),               \
+                              (init_msg_), (print_msg_),               \
+                              (nla_type_), #nla_type_,                 \
+                              (pattern_), (obj_), print_quoted_hex,    \
+                              __VA_ARGS__)
+
 #define TEST_NLATTR_ARRAY(fd_, nlh0_, hdrlen_,                         \
                          init_msg_, print_msg_,                        \
                          nla_type_, pattern_, obj_, print_elem_)       \