From: JingPiao Chen Date: Thu, 20 Jul 2017 08:45:58 +0000 (+0800) Subject: tests: extend TEST_NLATTR_OBJECT macro X-Git-Tag: v4.19~213 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3acb11230cf7fdf5fe9d51053c2d5fcd1555f603;p=strace tests: extend TEST_NLATTR_OBJECT macro * tests/test_nlattr.h (TEST_NLATTR_OBJECT_EX_, TEST_NLATTR_OBJECT_EX): New macros. (TEST_NLATTR_OBJECT): Use TEST_NLATTR_OBJECT_EX_. --- diff --git a/tests/test_nlattr.h b/tests/test_nlattr.h index 4585893d..204c4371 100644 --- a/tests/test_nlattr.h +++ b/tests/test_nlattr.h @@ -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_) \