Skip to content

Commit 7ca41fa

Browse files
committed
perf test shell trace_exit_race: Show what went wrong in verbose mode
If it fails we need to check what was the reason, what were the lines that didn't match the expected format, so: root@number:~# perf test -v "trace exit race" --- start --- test child forked, pid 2028724 Lines not matching the expected regexp: ' +[0-9]+\.[0-9]+ +true/[0-9]+ syscalls:sys_enter_exit_group\(\)$': 0.000 :2028750/2028750 syscalls:sys_enter_exit_group() ---- end(-1) ---- 110: perf trace exit race : FAILED! root@number:~# In this case we're not resolving the process COMM for some reason and fallback to printing just the pid/tid, this will be fixed in a followup patch. Howard Chu spotted a problem with single code surrounding a regexp, that made the test always fail, but since there were some failures when I tested (COMM not being resolved in some of the results) the end inverse grep would show some lines and thus didn't notice the single quote problem. He also provided a patch to test if less than the number of expected matches took place but all of them with the expected output, in which case the inverse grep wouldn't show anything, confusing the tester. Reviewed-by: Howard Chu <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Benjamin Peterson <[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/lkml/ZzdknoHqrJbojb6P@x1 Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent f72bcb9 commit 7ca41fa

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

tools/perf/tests/shell/trace_exit_race.sh

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@
1111

1212
skip_if_no_perf_trace || exit 2
1313

14+
if [ "$1" = "-v" ]; then
15+
verbose="1"
16+
fi
17+
18+
iter=10
19+
regexp=" +[0-9]+\.[0-9]+ +true/[0-9]+ syscalls:sys_enter_exit_group\(\)$"
20+
1421
trace_shutdown_race() {
15-
for _ in $(seq 10); do
22+
for _ in $(seq $iter); do
1623
perf trace -e syscalls:sys_enter_exit_group true 2>>$file
1724
done
18-
[ "$(grep -c -E ' +[0-9]+\.[0-9]+ +true/[0-9]+ syscalls:sys_enter_exit_group\(\)$' $file)" = "10" ]
25+
result="$(grep -c -E "$regexp" $file)"
26+
[ $result = $iter ]
1927
}
2028

2129

@@ -27,5 +35,17 @@ export PERF_CONFIG=/dev/null
2735

2836
trace_shutdown_race
2937
err=$?
38+
39+
if [ $err != 0 ] && [ "${verbose}" = "1" ]; then
40+
lines_not_matching=$(mktemp /tmp/temporary_file.XXXXX)
41+
if grep -v -E "$regexp" $file > $lines_not_matching ; then
42+
echo "Lines not matching the expected regexp: '$regexp':"
43+
cat $lines_not_matching
44+
else
45+
echo "Missing output, expected $iter but only got $result"
46+
fi
47+
rm -f $lines_not_matching
48+
fi
49+
3050
rm -f ${file}
3151
exit $err

0 commit comments

Comments
 (0)