Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Check how network syscalls are traced when decoding socket descriptors |
| 4 | |
| 5 | . "${srcdir=.}/init.sh" |
| 6 | |
| 7 | # strace -y is implemented using /proc/self/fd |
| 8 | [ -d /proc/self/fd/ ] || |
| 9 | framework_skip_ '/proc/self/fd/ is not available' |
| 10 | |
| 11 | check_prog grep |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 12 | |
| 13 | rm -f $LOG.* |
| 14 | |
Dmitry V. Levin | c9cc4cb | 2015-01-07 20:14:19 +0000 | [diff] [blame] | 15 | addr=net-fd-local-stream |
| 16 | ./net-accept-connect $addr || |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 17 | fail_ 'net-accept-connect failed' |
| 18 | |
| 19 | # using -y to test socket descriptors 'paths' decoding |
Dmitry V. Levin | c9cc4cb | 2015-01-07 20:14:19 +0000 | [diff] [blame] | 20 | args="-tt -ff -y -enetwork ./net-accept-connect $addr" |
| 21 | $STRACE -o "$LOG" $args || |
| 22 | fail_ "$STRACE $args failed" |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 23 | |
| 24 | "$srcdir"/../strace-log-merge $LOG > $LOG || { |
| 25 | cat $LOG |
| 26 | fail_ 'strace-log-merge failed' |
| 27 | } |
| 28 | |
| 29 | rm -f $LOG.* |
| 30 | |
| 31 | grep_log() |
| 32 | { |
| 33 | local syscall="$1"; shift |
| 34 | local prefix='[1-9][0-9]* +[0-9]+:[0-9]+:[0-9]+\.[0-9]+ +' |
| 35 | |
Dmitry V. Levin | ed7ada2 | 2015-01-13 00:06:09 +0000 | [diff] [blame] | 36 | LC_ALL=C grep -E -x "$prefix$syscall$*" $LOG > /dev/null || { |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 37 | cat $LOG |
| 38 | fail_ "strace -enetwork failed to trace \"$syscall\" properly" |
| 39 | } |
| 40 | } |
Dmitry V. Levin | c9cc4cb | 2015-01-07 20:14:19 +0000 | [diff] [blame] | 41 | grep_log bind '\(0<socket:\[[0-9]+\]>, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="'$addr'"\}, 22\) += 0' |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 42 | grep_log listen '\(0<socket:\[[0-9]+\]>, 5\) += 0' |
Dmitry V. Levin | c9cc4cb | 2015-01-07 20:14:19 +0000 | [diff] [blame] | 43 | grep_log getsockname '\(0<socket:\[[0-9]+\]>, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="'$addr'"\}, \[22\]\) += 0' |
Dmitry V. Levin | 15114ec | 2014-08-06 16:46:13 +0000 | [diff] [blame] | 44 | grep_log accept '\(0<socket:\[[0-9]+\]>, \{sa_family=AF_(LOCAL|UNIX|FILE), NULL\}, \[2\]\) += 1<socket:\[[0-9]+\]>' |
Dmitry V. Levin | c9cc4cb | 2015-01-07 20:14:19 +0000 | [diff] [blame] | 45 | grep_log connect '\(1<socket:\[[0-9]+\]>, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="'$addr'"\}, 22\) += 0' |
Philippe Ombredanne | 894c7e3 | 2014-02-01 09:57:45 -0800 | [diff] [blame] | 46 | |
| 47 | exit 0 |