From: Dmitry V. Levin Date: Thu, 5 Mar 2015 17:30:23 +0000 (+0000) Subject: tests: robustify unix-yy.test X-Git-Tag: v4.10~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da66e25779635e59b42a4477ef1e8b6b6917dac6;p=strace tests: robustify unix-yy.test Implement additional synchronization between parent and child processes to guarantee that the child starts closing connected socket only after exiting of the parent's accept() syscall. This guarantee seems to be necessary to reliably receive UNIX_DIAG_PEER messages from NETLINK_SOCK_DIAG interface. * tests/net-accept-connect.c: Implement additional synchronization between parent and child processes. * tests/unix-yy-connect.awk: Update. --- diff --git a/tests/net-accept-connect.c b/tests/net-accept-connect.c index 6d99e3aa..c9bc8e4d 100644 --- a/tests/net-accept-connect.c +++ b/tests/net-accept-connect.c @@ -1,12 +1,21 @@ #include #include #include +#include #include #include #include #include -int main(int ac, const char **av) +static void +handler(int sig) +{ + assert(close(1) == 0); + _exit(0); +} + +int +main(int ac, const char **av) { struct sockaddr_un addr = { .sun_family = AF_UNIX, @@ -40,16 +49,24 @@ int main(int ac, const char **av) if (pid) { assert(accept(0, (struct sockaddr *) &addr, &len) == 1); assert(close(0) == 0); + assert(kill(pid, SIGUSR1) == 0); int status; assert(waitpid(pid, &status, 0) == pid); assert(status == 0); assert(close(1) == 0); } else { + sigset_t set; + sigemptyset(&set); + sigaddset(&set, SIGUSR1); + + assert(sigprocmask(SIG_BLOCK, &set, NULL) == 0); + assert(signal(SIGUSR1, handler) != SIG_ERR); assert(socket(PF_LOCAL, SOCK_STREAM, 0) == 1); assert(close(0) == 0); assert(connect(1, (struct sockaddr *) &addr, len) == 0); - assert(close(1) == 0); - return 0; + assert(sigprocmask(SIG_UNBLOCK, &set, NULL) == 0); + assert(pause() == 99); + return 1; } unlink(av[1]); diff --git a/tests/unix-yy-connect.awk b/tests/unix-yy-connect.awk index bbbcff91..4641d783 100644 --- a/tests/unix-yy-connect.awk +++ b/tests/unix-yy-connect.awk @@ -1,5 +1,5 @@ BEGIN { - lines = 5 + lines = 6 fail = 0 addrlen = length(addr) + 3 @@ -20,7 +20,9 @@ NR == 3 { } } -NR == 4 { +NR == 4 && /^--- SIGUSR1 / {next} + +NR == 5 { if (inode != "" && r_close_connected != "" && match($0, r_close_connected, a) && a[1] == inode) { next }