Masatake YAMATO | 9682107 | 2014-05-14 13:16:29 +0900 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Ensure that strace -k works. |
| 4 | |
| 5 | . "${srcdir=.}/init.sh" |
| 6 | |
| 7 | # strace -k is implemented using /proc/$pid/maps |
| 8 | [ -f /proc/self/maps ] || |
| 9 | framework_skip_ '/proc/self/maps is not available' |
| 10 | |
| 11 | check_prog sed |
| 12 | check_prog tr |
| 13 | |
| 14 | ./stack-fcall || |
| 15 | fail_ 'stack-fcall failed' |
| 16 | |
| 17 | $STRACE -h | grep '^-k' > /dev/null || |
| 18 | skip_ 'strace -k is not available' |
| 19 | |
| 20 | args="-e getuid -k ./stack-fcall" |
| 21 | $STRACE $args > $LOG 2>&1 || { |
| 22 | cat $LOG |
| 23 | fail_ "$STRACE $args failed" |
| 24 | } |
| 25 | |
| 26 | expected='getuid f1 f0 main ' |
| 27 | result=$(sed -n '1,/(main+0x[a-f0-9]\+) .*/ s/^.*(\([^+]\+\)+0x[a-f0-9]\+) .*/\1/p' $LOG | |
| 28 | tr '\n' ' ') |
| 29 | |
| 30 | test "$result" = "$expected" || { |
| 31 | cat $LOG |
| 32 | echo "expected: \"$expected\"" |
| 33 | echo "result: \"$result\"" |
| 34 | fail_ "unexpected output from $STRACE $args" |
| 35 | } |
| 36 | |
| 37 | exit 0 |