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
14check_prog sed
15check_prog tr
16
17run_prog ./stack-fcall
18run_strace -e getpid -k $args
19
20expected='getpid f3 f2 f1 f0 main '
21result=$(sed -n '1,/(main+0x[a-f0-9]\+) .*/ s/^.*(\([^+]\+\)+0x[a-f0-9]\+) .*/\1/p' "$LOG" |
22	tr '\n' ' ')
23
24test "$result" = "$expected" || {
25	echo "expected: \"$expected\""
26	echo "result: \"$result\""
27	dump_log_and_fail_with "$STRACE $args output mismatch"
28}
29
30exit 0
31