From: Dmitry V. Levin Date: Mon, 23 May 2016 10:26:46 +0000 (+0000) Subject: tests/net-yy-netlink.c: robustify against libc specific issues X-Git-Tag: v4.12~104 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ea65fb549ae476829293b1c44625bfb0bad9932;p=strace tests/net-yy-netlink.c: robustify against libc specific issues * tests/net-yy-netlink.c (main): Use getsockname instead of recvmsg as the latter has notible implementation differences that make the test unreliable. --- diff --git a/tests/net-yy-netlink.c b/tests/net-yy-netlink.c index 2b9d96fc..e52cfedd 100644 --- a/tests/net-yy-netlink.c +++ b/tests/net-yy-netlink.c @@ -29,14 +29,12 @@ */ #include "tests.h" -#include #include #include #include #include #include #include -#include #include #include #include @@ -56,7 +54,6 @@ main(void) }; struct sockaddr *const sa = tail_memdup(&addr, sizeof(addr)); socklen_t * const len = tail_alloc(sizeof(socklen_t)); - struct msghdr *const mh = tail_alloc(sizeof(*mh)); *len = sizeof(addr); const int fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_SOCK_DIAG); @@ -68,15 +65,18 @@ main(void) if (bind(fd, sa, *len)) perror_msg_and_skip("bind"); - printf("bind(%d, {sa_family=AF_NETLINK, pid=%u, " - "groups=00000000}, %u) = 0\n", fd, inode, magic, - (unsigned) *len); + printf("bind(%d, {sa_family=AF_NETLINK" + ", pid=%u, groups=00000000}, %u) = 0\n", + fd, inode, magic, (unsigned) *len); - assert(recvmsg(fd, mh, MSG_DONTWAIT) == -1); - printf("recvmsg(%d, %p, MSG_DONTWAIT)" - " = -1 %s (%m)\n", fd, magic, mh, errno2name()); + if (getsockname(fd, sa, len)) + perror_msg_and_fail("getsockname"); + printf("getsockname(%d, {sa_family=AF_NETLINK" + ", pid=%u, groups=00000000}, [%u]) = 0\n", + fd, magic, magic, (unsigned) *len); - assert(close(fd) == 0); + if (close(fd)) + perror_msg_and_fail("close"); printf("close(%d) = 0\n", fd, magic); puts("+++ exited with 0 +++");