[PATCH 4/4] tests: check decoding of nlmsgerr attributes
Dmitry V. Levin
ldv at altlinux.org
Tue Jul 18 21:47:59 UTC 2017
On Mon, Jul 17, 2017 at 11:07:46PM +0800, JingPiao Chen wrote:
> * tests/nlattr_nlmsgerr.c: New file.
> * tests/gen_tests.in (nlattr_nlmsgerr): New entry.
> * tests/pure_executables.list: Add nlattr_nlmsgerr.
> * tests/.gitignore: Likewise.
[...]
> +int
> +main(void)
> +{
> + skip_if_unavailable("/proc/self/fd/");
> +
> + const int fd = create_nl_socket(NETLINK_SOCK_DIAG);
> + const unsigned int hdrlen = sizeof(struct nlmsgerr);
> + void *const nlh0 = tail_alloc(NLMSG_SPACE(hdrlen));
> +
> + static char pattern[4096];
> + fill_memory_ex(pattern, sizeof(pattern), 'a', 'z' - 'a' + 1);
> +
> + static const uint8_t cookie[] = { 0xab, 0xfe };
> + TEST_NLATTR(fd, nlh0, hdrlen,
> + init_nlmsgerr, print_nlmsgerr,
> + NLMSGERR_ATTR_COOKIE,
> + sizeof(cookie), cookie, sizeof(cookie),
> + printf("[%u, %u]", cookie[0], cookie[1]);
> + printf("}"));
> +
> + printf("+++ exited with 0 +++\n");
> + return 0;
> +}
Note that pattern is initialized but never used here.
Shouldn't TEST_NLATTR_ARRAY be used here instead of TEST_NLATTR?
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170719/60682289/attachment.bin>
More information about the Strace-devel
mailing list