strace/tests/unix-yy.test
Dmitry V. Levin c9cc4cbc50 tests: fix race condition in net-accept-connect based tests
Change all net-accept-connect based tests to use different unix domain
socket addresses, so that these tests could be safely run in parallel.

* tests/net-accept-connect.c: Parametrize unix domain socket address.
* tests/net-fd.test: Pass socket address to net-accept-connect.
* tests/net.test: Likewise.
* tests/unix-yy.test: Likewise.
* tests/unix-yy-accept.awk: Update regexps.
* tests/unix-yy-connect.awk: Likewise.
2015-01-07 22:05:38 +00:00

62 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# Check decoding of address information (inode[->peer][,path])
# associated with unix domain socket descriptors.
. "${srcdir=.}/init.sh"
# strace -yy is implemented using /proc/self/fd
[ -d /proc/self/fd/ ] ||
framework_skip_ '/proc/self/fd/ is not available'
check_prog awk
check_prog sed
rm -f $LOG.* $LOG-*
addr=unix-yy-local-stream
./net-accept-connect $addr ||
fail_ 'net-accept-connect failed'
./netlink_unix_diag || {
if [ $? -eq 77 ]; then
framework_skip_ 'NETLINK_SOCK_DIAG for unix domain sockets is not available'
else
fail_ 'netlink_unix_diag failed'
fi
}
args="-tt -ff -yy -eclose,network ./net-accept-connect $addr"
$STRACE -o "$LOG" $args ||
fail_ "$STRACE $args failed"
"$srcdir"/../strace-log-merge $LOG > $LOG || {
cat $LOG
fail_ 'strace-log-merge failed'
}
rm -f $LOG.*
child="$(sed -rn '/SIGCHLD/ s/^.*, si_pid=([1-9][0-9]*), .*/\1/p' $LOG)"
[ -n "$child" ] || {
cat $LOG
fail_ 'failed to find pid of child process'
}
sed -rn "/^$child"' /!d; / socket\(/,$ s/^[0-9]+ +[^ ]+ (.+)/\1/p' $LOG > $LOG-connect &&
sed -rn "/^$child"' /d; /SIGCHLD/d; / socket\(/,$ s/^[0-9]+ +[^ ]+ (.+)/\1/p' $LOG > $LOG-accept || {
cat $LOG
fail_ 'failed to separate logs'
}
awk -f "$srcdir"/unix-yy-connect.awk -v addr=$addr $LOG-connect || {
cat $LOG-connect
fail_ "strace $args failed to decode socket descriptors properly"
}
awk -f "$srcdir"/unix-yy-accept.awk -v addr=$addr $LOG-accept || {
cat $LOG-accept
fail_ "strace $args failed to decode socket descriptors properly"
}
exit 0