Dmitry V. Levin
552bc3a09a
* tests/inet-accept-connect-send-recv.c (main): Return 77 if inet stream socket cannot be created or it cannot be bound to INADDR_LOOPBACK. * tests/net-yy.test: Skip the test if inet-accept-connect-send-recv returns 77.
65 lines
1.5 KiB
Bash
Executable File
65 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Check decoding of ip:port pairs associated with 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-*
|
|
|
|
./inet-accept-connect-send-recv || {
|
|
if [ $? -eq 77 ]; then
|
|
framework_skip_ 'PF_INET SOCK_STREAM is not available'
|
|
else
|
|
fail_ 'inet-accept-connect-send-recv failed'
|
|
fi
|
|
}
|
|
|
|
./netlink_inet_diag || {
|
|
if [ $? -eq 77 ]; then
|
|
framework_skip_ 'NETLINK_INET_DIAG is not available'
|
|
else
|
|
fail_ 'netlink_inet_diag failed'
|
|
fi
|
|
}
|
|
|
|
args="-tt -ff -yy -o $LOG -eclose,network ./inet-accept-connect-send-recv"
|
|
$STRACE $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"/net-yy-connect.awk $LOG-connect || {
|
|
cat $LOG-connect
|
|
fail_ "strace $args failed to decode socket descriptors properly"
|
|
}
|
|
|
|
awk -f "$srcdir"/net-yy-accept.awk $LOG-accept || {
|
|
cat $LOG-accept
|
|
fail_ "strace $args failed to decode socket descriptors properly"
|
|
}
|
|
|
|
exit 0
|