]> granicus.if.org Git - strace/commitdiff
tests: enhance create_nl_socket diagnostics messages
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 5 Jun 2017 12:17:49 +0000 (12:17 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 5 Jun 2017 14:51:26 +0000 (14:51 +0000)
* 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.

tests/create_nl_socket.c
tests/tests.h

index aeac907f4ade8adee1aa9a3c964a997cac3e79a7..9b4904a28c160bb9e109d5fa9de34a227e4939cb 100644 (file)
 #include <linux/netlink.h>
 
 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;
 }
index fd7f194a25a6769a01ffb0bae6469fe8b6358cff..3634493045bf14d7a63cbbc10465bb3c3559f744 100644 (file)
@@ -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]);