From 6c7c4e50b1365680c1078907cd9800a5864c4d10 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 30 Jun 2017 21:38:49 +0000 Subject: [PATCH] tests: check decoding of several standard netlink attributes * tests/nlattr_inet_diag_msg.c (main): Check decoding of uint32_t, uint8_t, and zero-terminated string attributes. Co-authored-by: JingPiao Chen --- tests/nlattr_inet_diag_msg.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/nlattr_inet_diag_msg.c b/tests/nlattr_inet_diag_msg.c index 65ca667b..59c2e0d0 100644 --- a/tests/nlattr_inet_diag_msg.c +++ b/tests/nlattr_inet_diag_msg.c @@ -162,6 +162,30 @@ main(void) init_inet_diag_msg, print_inet_diag_msg, INET_DIAG_SKMEMINFO, pattern, mem, print_uint); + static const uint32_t mark = 0xabdfadca; + TEST_NLATTR_OBJECT(fd, nlh0, hdrlen, + init_inet_diag_msg, print_inet_diag_msg, + INET_DIAG_MARK, pattern, mark, + printf("%u", mark)); + + static const uint8_t shutdown = 0xcd; + TEST_NLATTR(fd, nlh0, hdrlen, + init_inet_diag_msg, print_inet_diag_msg, INET_DIAG_SHUTDOWN, + sizeof(shutdown), &shutdown, sizeof(shutdown), + printf("%u", shutdown)); + + char *const str = tail_alloc(DEFAULT_STRLEN); + fill_memory_ex(str, DEFAULT_STRLEN, '0', 10); + TEST_NLATTR(fd, nlh0, hdrlen, + init_inet_diag_msg, print_inet_diag_msg, INET_DIAG_CONG, + DEFAULT_STRLEN, str, DEFAULT_STRLEN, + printf("\"%.*s\"...", DEFAULT_STRLEN, str)); + str[DEFAULT_STRLEN - 1] = '\0'; + TEST_NLATTR(fd, nlh0, hdrlen, + init_inet_diag_msg, print_inet_diag_msg, INET_DIAG_CONG, + DEFAULT_STRLEN, str, DEFAULT_STRLEN, + printf("\"%s\"", str)); + puts("+++ exited with 0 +++"); return 0; } -- 2.40.0