blob: 0f0eb5ccf43eb0b3b15a990f4ab1d24c51168327 [file] [log] [blame]
#!/bin/sh
# Check how network syscalls are traced when decoding socket descriptors
. "${srcdir=.}/init.sh"
# strace -y is implemented using /proc/self/fd
[ -d /proc/self/fd/ ] ||
framework_skip_ '/proc/self/fd/ is not available'
check_prog grep
rm -f $LOG.*
./net-accept-connect ||
fail_ 'net-accept-connect failed'
# using -y to test socket descriptors 'paths' decoding
args="-tt -ff -y -o $LOG -enetwork ./net-accept-connect"
$STRACE $args ||
fail_ "strace $args failed"
"$srcdir"/../strace-log-merge $LOG > $LOG || {
cat $LOG
fail_ 'strace-log-merge failed'
}
rm -f $LOG.*
grep_log()
{
local syscall="$1"; shift
local prefix='[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +'
LC_ALL=C grep -E -x "$prefix$syscall$@" $LOG > /dev/null || {
cat $LOG
fail_ "strace -enetwork failed to trace \"$syscall\" properly"
}
}
grep_log bind '\(0<socket:\[[0-9]+\]>, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="local-stream"\}, 15\) += 0'
grep_log listen '\(0<socket:\[[0-9]+\]>, 5\) += 0'
grep_log getsockname '\(0<socket:\[[0-9]+\]>, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="local-stream"\}, \[15\]\) += 0'
grep_log accept '\(0<socket:\[[0-9]+\]>, \{sa_family=AF_(LOCAL|UNIX|FILE), NULL\}, \[2\]\) += 1<socket:\[[0-9]+\]>'
grep_log connect '\(1<socket:\[[0-9]+\]>, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="local-stream"\}, 15\) += 0'
exit 0