Home | History | Annotate | Download | only in tests
      1 #!/bin/sh
      2 
      3 # Ensure that strace -k works.
      4 
      5 . "${srcdir=.}/init.sh"
      6 
      7 $STRACE -h | grep '^-k' > /dev/null ||
      8 	skip_ 'strace -k is not available'
      9 
     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 
     17 run_prog ./stack-fcall
     18 run_strace -e getpid -k $args
     19 
     20 expected='getpid f3 f2 f1 f0 main '
     21 result=$(sed -n '1,/(main+0x[a-f0-9]\+) .*/ s/^.*(\([^+]\+\)+0x[a-f0-9]\+) .*/\1/p' "$LOG" |
     22 	tr '\n' ' ')
     23 
     24 test "$result" = "$expected" || {
     25 	echo "expected: \"$expected\""
     26 	echo "result: \"$result\""
     27 	dump_log_and_fail_with "$STRACE $args output mismatch"
     28 }
     29 
     30 exit 0
     31