1#!/bin/sh 2 3# Check how network syscalls are traced. 4 5. "${srcdir=.}/init.sh" 6 7check_prog grep 8check_prog rm 9 10rm -f $LOG.* 11 12./net-accept-connect || 13 fail_ 'net-accept-connect failed' 14 15args="-tt -ff -o $LOG -enetwork ./net-accept-connect" 16$STRACE $args || 17 fail_ "strace $args failed" 18 19"$srcdir"/../strace-log-merge $LOG > $LOG || { 20 cat $LOG 21 fail_ 'strace-log-merge failed' 22} 23 24rm -f $LOG.* 25 26grep_log() 27{ 28 local syscall="$1"; shift 29 local prefix='[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +' 30 31 LC_ALL=C grep -E -x "$prefix$syscall$@" $LOG > /dev/null || { 32 cat $LOG 33 fail_ "strace -enetwork failed to trace \"$syscall\" properly" 34 } 35} 36 37grep_log socket '\(PF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 0' 38grep_log socket '\(PF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 1' 39grep_log bind '\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="local-stream"\}, 15\) += 0' 40grep_log listen '\(0, 5\) += 0' 41grep_log getsockname '\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="local-stream"\}, \[15\]\) += 0' 42grep_log accept '\(0, \{sa_family=AF_(LOCAL|UNIX|FILE), NULL\}, \[2\]\) += 1' 43grep_log connect '\(1, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="local-stream"\}, 15\) += 0' 44 45exit 0 46