blob: 4a9b889dc5e5489583eac4a711ebec7838cc56b2 [file] [log] [blame]
#!/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