blob: 4c24efdaad46eabf541a81bc268739061bdf6bfe [file] [log] [blame]
Philippe Ombredanne894c7e32014-02-01 09:57:45 -08001#!/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
11check_prog grep
Philippe Ombredanne894c7e32014-02-01 09:57:45 -080012
13rm -f $LOG.*
14
Dmitry V. Levinc9cc4cb2015-01-07 20:14:19 +000015addr=net-fd-local-stream
16./net-accept-connect $addr ||
Philippe Ombredanne894c7e32014-02-01 09:57:45 -080017 fail_ 'net-accept-connect failed'
18
19# using -y to test socket descriptors 'paths' decoding
Dmitry V. Levinc9cc4cb2015-01-07 20:14:19 +000020args="-tt -ff -y -enetwork ./net-accept-connect $addr"
21$STRACE -o "$LOG" $args ||
22 fail_ "$STRACE $args failed"
Philippe Ombredanne894c7e32014-02-01 09:57:45 -080023
24"$srcdir"/../strace-log-merge $LOG > $LOG || {
25 cat $LOG
26 fail_ 'strace-log-merge failed'
27}
28
29rm -f $LOG.*
30
31grep_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. Levined7ada22015-01-13 00:06:09 +000036 LC_ALL=C grep -E -x "$prefix$syscall$*" $LOG > /dev/null || {
Philippe Ombredanne894c7e32014-02-01 09:57:45 -080037 cat $LOG
38 fail_ "strace -enetwork failed to trace \"$syscall\" properly"
39 }
40}
Dmitry V. Levinc9cc4cb2015-01-07 20:14:19 +000041grep_log bind '\(0<socket:\[[0-9]+\]>, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="'$addr'"\}, 22\) += 0'
Philippe Ombredanne894c7e32014-02-01 09:57:45 -080042grep_log listen '\(0<socket:\[[0-9]+\]>, 5\) += 0'
Dmitry V. Levinc9cc4cb2015-01-07 20:14:19 +000043grep_log getsockname '\(0<socket:\[[0-9]+\]>, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="'$addr'"\}, \[22\]\) += 0'
Dmitry V. Levin15114ec2014-08-06 16:46:13 +000044grep_log accept '\(0<socket:\[[0-9]+\]>, \{sa_family=AF_(LOCAL|UNIX|FILE), NULL\}, \[2\]\) += 1<socket:\[[0-9]+\]>'
Dmitry V. Levinc9cc4cb2015-01-07 20:14:19 +000045grep_log connect '\(1<socket:\[[0-9]+\]>, \{sa_family=AF_(LOCAL|UNIX|FILE), sun_path="'$addr'"\}, 22\) += 0'
Philippe Ombredanne894c7e32014-02-01 09:57:45 -080046
47exit 0