Masatake YAMATO | 6077ad8 | 2014-12-24 20:59:32 +0900 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Check decoding of address information (inode[->peer][,path]) |
| 4 | # associated with unix domain socket descriptors. |
| 5 | |
| 6 | . "${srcdir=.}/init.sh" |
| 7 | |
| 8 | # strace -yy is implemented using /proc/self/fd |
| 9 | [ -d /proc/self/fd/ ] || |
| 10 | framework_skip_ '/proc/self/fd/ is not available' |
| 11 | |
| 12 | check_prog awk |
| 13 | check_prog sed |
| 14 | |
| 15 | rm -f $LOG.* $LOG-* |
| 16 | |
| 17 | ./net-accept-connect || |
| 18 | fail_ 'net-accept-connect failed' |
| 19 | |
| 20 | ./netlink_inet_diag || { |
| 21 | if [ $? -eq 77 ]; then |
| 22 | framework_skip_ 'NETLINK_INET_DIAG is not available' |
| 23 | else |
| 24 | fail_ 'netlink_inet_diag failed' |
| 25 | fi |
| 26 | } |
| 27 | |
| 28 | args="-tt -ff -yy -o $LOG -eclose,network ./net-accept-connect" |
| 29 | $STRACE $args || |
| 30 | fail_ "strace $args failed" |
| 31 | |
| 32 | "$srcdir"/../strace-log-merge $LOG > $LOG || { |
| 33 | cat $LOG |
| 34 | fail_ 'strace-log-merge failed' |
| 35 | } |
| 36 | rm -f $LOG.* |
| 37 | |
| 38 | child="$(sed -rn '/SIGCHLD/ s/^.*, si_pid=([1-9][0-9]*), .*/\1/p' $LOG)" |
| 39 | [ -n "$child" ] || { |
| 40 | cat $LOG |
| 41 | fail_ 'failed to find pid of child process' |
| 42 | } |
| 43 | |
| 44 | sed -rn "/^$child"' /!d; / socket\(/,$ s/^[0-9]+ +[^ ]+ (.+)/\1/p' $LOG > $LOG-connect && |
| 45 | sed -rn "/^$child"' /d; /SIGCHLD/d; / socket\(/,$ s/^[0-9]+ +[^ ]+ (.+)/\1/p' $LOG > $LOG-accept || { |
| 46 | cat $LOG |
| 47 | fail_ 'failed to separate logs' |
| 48 | } |
| 49 | |
| 50 | awk -f "$srcdir"/unix-yy-connect.awk $LOG-connect || { |
| 51 | cat $LOG-connect |
| 52 | fail_ "strace $args failed to decode socket descriptors properly" |
| 53 | } |
| 54 | |
| 55 | awk -f "$srcdir"/unix-yy-accept.awk $LOG-accept || { |
| 56 | cat $LOG-accept |
| 57 | fail_ "strace $args failed to decode socket descriptors properly" |
| 58 | } |
| 59 | |
| 60 | exit 0 |