From: Dmitry V. Levin Date: Mon, 5 Jun 2017 12:17:49 +0000 (+0000) Subject: tests: enhance create_nl_socket diagnostics messages X-Git-Tag: v4.18~114 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c8d11b682bde950756631da53bd19347669f371;p=strace tests: enhance create_nl_socket diagnostics messages * tests/tests.h (create_nl_socket): Rename to create_nl_socket_ext, add a string argument. (create_nl_socket): New macro wrapper around create_nl_socket_ext. * tests/create_nl_socket.c (create_nl_socket): Rename to create_nl_socket_ext, add a string argument, include it in diagnostic messages. --- diff --git a/tests/create_nl_socket.c b/tests/create_nl_socket.c index aeac907f..9b4904a2 100644 --- a/tests/create_nl_socket.c +++ b/tests/create_nl_socket.c @@ -30,17 +30,17 @@ #include int -create_nl_socket(const int proto) +create_nl_socket_ext(const int proto, const char *const name) { const int fd = socket(AF_NETLINK, SOCK_RAW, proto); if (fd < 0) - perror_msg_and_skip("socket AF_NETLINK"); + perror_msg_and_skip("socket AF_NETLINK %s", name); const struct sockaddr_nl addr = { .nl_family = AF_NETLINK }; const socklen_t len = sizeof(addr); if (bind(fd, (const struct sockaddr *) &addr, len)) - perror_msg_and_skip("bind"); + perror_msg_and_skip("bind AF_NETLINK %s", name); return fd; } diff --git a/tests/tests.h b/tests/tests.h index fd7f194a..36344930 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -168,7 +168,8 @@ int recv_mmsg(int, struct mmsghdr *, unsigned int, unsigned int, struct timespec int send_mmsg(int, struct mmsghdr *, unsigned int, unsigned int); /* Create a netlink socket. */ -int create_nl_socket(int); +int create_nl_socket_ext(int proto, const char *name); +#define create_nl_socket(proto) create_nl_socket_ext((proto), #proto) /* Create a pipe with maximized descriptor numbers. */ void pipe_maxfd(int pipefd[2]);