summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2021-10-02 20:31:03 +0200
committerEugene Syromyatnikov <evgsyr@gmail.com>2021-10-09 19:24:40 +0200
commit6a9d1b1cd46222be851f1b5e80275adc835dc6be (patch)
treef6953e2ba4a1f7506a7dc738998345d7d220bac9
parent00cc4e170a424d414e7821081ced415df9bc0d0b (diff)
downloadstrace-6a9d1b1cd46222be851f1b5e80275adc835dc6be.tar.gz
tests/test_nlattr.h: provide TEST_NLATTR_OBJECT_ and TEST_NLATTR_ARRAY_
So they can be used along with custom nla_type string format. * tests/test_nlattr.h (TEST_NLATTR_OBJECT_): New macro, a wrapper for TEST_NLATTR_OBJECT_EX_. (TEST_NLATTR_ARRAY_): Rename from TEST_NLATTR_ARRAY, add nla_type_str_ argument. (TEST_NLATTR_ARRAY): New macro, a wrapper for TEST_NLATTR_ARRAY_.
-rw-r--r--tests/test_nlattr.h32
1 files changed, 25 insertions, 7 deletions
diff --git a/tests/test_nlattr.h b/tests/test_nlattr.h
index 138bb6e6b..32d70eb3e 100644
--- a/tests/test_nlattr.h
+++ b/tests/test_nlattr.h
@@ -169,6 +169,15 @@ print_sockfd(int sockfd, const char *pfx, const char *sfx)
(pattern_), (obj_), sizeof(obj_), \
print_quoted_hex, __VA_ARGS__)
+#define TEST_NLATTR_OBJECT_(fd_, nlh0_, hdrlen_, \
+ init_msg_, print_msg_, \
+ nla_type_, nla_type_str_, pattern_, obj_, ...) \
+ TEST_NLATTR_OBJECT_EX_((fd_), (nlh0_), (hdrlen_), \
+ (init_msg_), (print_msg_), \
+ (nla_type_), (nla_type_str_), \
+ (pattern_), (obj_), sizeof(obj_), \
+ print_quoted_hex, __VA_ARGS__)
+
#define TEST_NLATTR_OBJECT_MINSZ(fd_, nlh0_, hdrlen_, \
init_msg_, print_msg_, \
nla_type_, pattern_, obj_, minsz_, ...) \
@@ -178,9 +187,10 @@ print_sockfd(int sockfd, const char *pfx, const char *sfx)
(pattern_), (obj_), (minsz_), \
print_quoted_hex, __VA_ARGS__)
-#define TEST_NLATTR_ARRAY(fd_, nlh0_, hdrlen_, \
- init_msg_, print_msg_, \
- nla_type_, pattern_, obj_, print_elem_) \
+#define TEST_NLATTR_ARRAY_(fd_, nlh0_, hdrlen_, \
+ init_msg_, print_msg_, \
+ nla_type_, nla_type_str_, \
+ pattern_, obj_, print_elem_) \
do { \
const unsigned int plen = \
sizeof((obj_)[0]) - 1 > DEFAULT_STRLEN \
@@ -188,13 +198,13 @@ print_sockfd(int sockfd, const char *pfx, const char *sfx)
/* len < sizeof((obj_)[0]) */ \
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)); \
/* sizeof((obj_)[0]) < len < sizeof(obj_) */ \
TEST_NLATTR_((fd_), (nlh0_), (hdrlen_), \
(init_msg_), (print_msg_), \
- (nla_type_), #nla_type_, \
+ (nla_type_), (nla_type_str_), \
sizeof(obj_) - 1, \
&(obj_), sizeof(obj_) - 1, \
printf("["); \
@@ -207,7 +217,7 @@ print_sockfd(int sockfd, const char *pfx, const char *sfx)
/* 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_), \
&(obj_), sizeof(obj_) - 1, \
printf("["); \
@@ -222,7 +232,7 @@ print_sockfd(int sockfd, const char *pfx, const char *sfx)
/* 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_), \
printf("["); \
@@ -234,6 +244,14 @@ print_sockfd(int sockfd, const char *pfx, const char *sfx)
printf("]")); \
} while (0)
+#define TEST_NLATTR_ARRAY(fd_, nlh0_, hdrlen_, \
+ init_msg_, print_msg_, \
+ nla_type_, pattern_, obj_, print_elem_) \
+ TEST_NLATTR_ARRAY_((fd_), (nlh0_), (hdrlen_), \
+ (init_msg_), (print_msg_), \
+ (nla_type_), #nla_type_, \
+ (pattern_), (obj_), (print_elem_))
+
#define TEST_NESTED_NLATTR_OBJECT_EX_(fd_, nlh0_, hdrlen_, \
init_msg_, print_msg_, \
nla_type_, nla_type_str_, \