blob: f757fb91be573818c444f47c61e25eb57aed41ba [file] [log] [blame]
Masatake YAMATO96821072014-05-14 13:16:29 +09001#!/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
11check_prog sed
12check_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
Dmitry V. Levine4113972014-06-05 14:37:04 +000020args="-e getpid -k ./stack-fcall"
Masatake YAMATO96821072014-05-14 13:16:29 +090021$STRACE $args > $LOG 2>&1 || {
22 cat $LOG
23 fail_ "$STRACE $args failed"
24}
25
Dmitry V. Levinc588b202014-06-13 15:07:24 +000026expected='getpid f3 f2 f1 f0 main '
Masatake YAMATO96821072014-05-14 13:16:29 +090027result=$(sed -n '1,/(main+0x[a-f0-9]\+) .*/ s/^.*(\([^+]\+\)+0x[a-f0-9]\+) .*/\1/p' $LOG |
28 tr '\n' ' ')
29
30test "$result" = "$expected" || {
31 cat $LOG
32 echo "expected: \"$expected\""
33 echo "result: \"$result\""
34 fail_ "unexpected output from $STRACE $args"
35}
36
37exit 0