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 | |
Dmitry V. Levin | 8f54664 | 2015-03-17 17:07:57 +0000 | [diff] [blame] | 7 | $STRACE -h | grep '^-k' > /dev/null || |
| 8 | skip_ 'strace -k is not available' |
| 9 | |
Masatake YAMATO | 9682107 | 2014-05-14 13:16:29 +0900 | [diff] [blame] | 10 | # strace -k is implemented using /proc/$pid/maps |
| 11 | [ -f /proc/self/maps ] || |
| 12 | framework_skip_ '/proc/self/maps is not available' |
| 13 | |
| 14 | check_prog sed |
| 15 | check_prog tr |
| 16 | |
Dmitry V. Levin | 8f54664 | 2015-03-17 17:07:57 +0000 | [diff] [blame] | 17 | run_prog ./stack-fcall |
| 18 | run_strace -e getpid -k $args |
Masatake YAMATO | 9682107 | 2014-05-14 13:16:29 +0900 | [diff] [blame] | 19 | |
Dmitry V. Levin | c588b20 | 2014-06-13 15:07:24 +0000 | [diff] [blame] | 20 | expected='getpid f3 f2 f1 f0 main ' |
Dmitry V. Levin | 8f54664 | 2015-03-17 17:07:57 +0000 | [diff] [blame] | 21 | result=$(sed -n '1,/(main+0x[a-f0-9]\+) .*/ s/^.*(\([^+]\+\)+0x[a-f0-9]\+) .*/\1/p' "$LOG" | |
Masatake YAMATO | 9682107 | 2014-05-14 13:16:29 +0900 | [diff] [blame] | 22 | tr '\n' ' ') |
| 23 | |
| 24 | test "$result" = "$expected" || { |
Masatake YAMATO | 9682107 | 2014-05-14 13:16:29 +0900 | [diff] [blame] | 25 | echo "expected: \"$expected\"" |
| 26 | echo "result: \"$result\"" |
Dmitry V. Levin | 8f54664 | 2015-03-17 17:07:57 +0000 | [diff] [blame] | 27 | dump_log_and_fail_with "$STRACE $args output mismatch" |
Masatake YAMATO | 9682107 | 2014-05-14 13:16:29 +0900 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | exit 0 |