Skip to content

Commit f72bcb9

Browse files
benjaminpacmel
authored andcommitted
perf tests: Add test for trace output loss
Add a test that checks that trace output is not lost to races. This is accomplished by tracing the exit_group syscall of "true" multiple times and checking for correct output. Signed-off-by: Benjamin Peterson <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Tested-by: Howard Chu <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Addressed two ShellCheck warnings ] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 1302e35 commit f72bcb9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
# perf trace exit race
3+
# SPDX-License-Identifier: GPL-2.0
4+
5+
# Check that the last events of a perf trace'd subprocess are not
6+
# lost. Specifically, trace the exiting syscall of "true" 10 times and ensure
7+
# the output contains 10 correct lines.
8+
9+
# shellcheck source=lib/probe.sh
10+
. "$(dirname $0)"/lib/probe.sh
11+
12+
skip_if_no_perf_trace || exit 2
13+
14+
trace_shutdown_race() {
15+
for _ in $(seq 10); do
16+
perf trace -e syscalls:sys_enter_exit_group true 2>>$file
17+
done
18+
[ "$(grep -c -E ' +[0-9]+\.[0-9]+ +true/[0-9]+ syscalls:sys_enter_exit_group\(\)$' $file)" = "10" ]
19+
}
20+
21+
22+
file=$(mktemp /tmp/temporary_file.XXXXX)
23+
24+
# Do not use whatever ~/.perfconfig file, it may change the output
25+
# via trace.{show_timestamp,show_prefix,etc}
26+
export PERF_CONFIG=/dev/null
27+
28+
trace_shutdown_race
29+
err=$?
30+
rm -f ${file}
31+
exit $err

0 commit comments

Comments
 (0)