From: Dmitry V. Levin Date: Thu, 21 Jul 2016 18:18:40 +0000 (+0000) Subject: tests: skip netlink_protocol.test on old systems X-Git-Tag: v4.13~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c652ccf908b246b016f8ae7904d80fbe83be542;p=strace tests: skip netlink_protocol.test on old systems * tests/netlink_protocol.c: Check that HAVE_SYS_XATTR_H is defined. Include and . (main): Check that system.sockprotoname attribute is supported. --- diff --git a/tests/netlink_protocol.c b/tests/netlink_protocol.c index e0d7b52f..aee9a874 100644 --- a/tests/netlink_protocol.c +++ b/tests/netlink_protocol.c @@ -29,17 +29,22 @@ */ #include "tests.h" -#include -#include -#include -#include -#include -#include -#include - -#if !defined NETLINK_SOCK_DIAG && defined NETLINK_INET_DIAG -# define NETLINK_SOCK_DIAG NETLINK_INET_DIAG -#endif + +#ifdef HAVE_SYS_XATTR_H + +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# if !defined NETLINK_SOCK_DIAG && defined NETLINK_INET_DIAG +# define NETLINK_SOCK_DIAG NETLINK_INET_DIAG +# endif static void send_query(const int fd) @@ -192,8 +197,8 @@ send_query(const int fd) (unsigned) sizeof(*reqs), (unsigned) sizeof(*reqs)); /* abbreviated output */ -#define DEFAULT_STRLEN 32 -#define ABBREV_LEN (DEFAULT_STRLEN + 1) +# define DEFAULT_STRLEN 32 +# define ABBREV_LEN (DEFAULT_STRLEN + 1) const unsigned int msg_len = sizeof(struct nlmsghdr) * ABBREV_LEN; struct nlmsghdr *const msgs = tail_alloc(msg_len); unsigned int i; @@ -238,9 +243,23 @@ int main(void) printf("bind(%d, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}" ", %u) = 0\n", fd, len); + char *path; + if (asprintf(&path, "/proc/self/fd/%u", fd) < 0) + perror_msg_and_fail("asprintf"); + char buf[256]; + if (getxattr(path, "system.sockprotoname", buf, sizeof(buf) - 1) < 0) + perror_msg_and_skip("getxattr"); + free(path); + send_query(fd); printf("+++ exited with 0 +++\n"); return 0; } + +#else + +SKIP_MAIN_UNDEFINED("HAVE_SYS_XATTR_H") + +#endif