Skip to content

Commit 2d099cc

Browse files
namhyungacmel
authored andcommitted
perf test: Add perf trace summary test
$ sudo ./perf test -vv 'trace summary' 109: perf trace summary: --- start --- test child forked, pid 3501572 testing: perf trace -s -- true testing: perf trace -S -- true testing: perf trace -s --summary-mode=thread -- true testing: perf trace -S --summary-mode=total -- true testing: perf trace -as --summary-mode=thread --no-bpf-summary -- true testing: perf trace -as --summary-mode=total --no-bpf-summary -- true testing: perf trace -as --summary-mode=thread --bpf-summary -- true testing: perf trace -as --summary-mode=total --bpf-summary -- true testing: perf trace -aS --summary-mode=total --bpf-summary -- true ---- end(0) ---- 109: perf trace summary : Ok Reviewed-by: Howard Chu <[email protected]> Signed-off-by: Namhyung Kim <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Howard Chu <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Song Liu <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 1bec43f commit 2d099cc

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/sh
2+
# perf trace summary
3+
# SPDX-License-Identifier: GPL-2.0
4+
5+
# Check that perf trace works with various summary mode
6+
7+
# shellcheck source=lib/probe.sh
8+
. "$(dirname $0)"/lib/probe.sh
9+
10+
skip_if_no_perf_trace || exit 2
11+
[ "$(id -u)" = 0 ] || exit 2
12+
13+
OUTPUT=$(mktemp /tmp/perf_trace_test.XXXXX)
14+
15+
test_perf_trace() {
16+
args=$1
17+
workload="true"
18+
search="^\s*(open|read|close).*[0-9]+%$"
19+
20+
echo "testing: perf trace ${args} -- ${workload}"
21+
perf trace ${args} -- ${workload} >${OUTPUT} 2>&1
22+
if [ $? -ne 0 ]; then
23+
echo "Error: perf trace ${args} failed unexpectedly"
24+
cat ${OUTPUT}
25+
rm -f ${OUTPUT}
26+
exit 1
27+
fi
28+
29+
count=$(grep -E -c -m 3 "${search}" ${OUTPUT})
30+
if [ "${count}" != "3" ]; then
31+
echo "Error: cannot find enough pattern ${search} in the output"
32+
cat ${OUTPUT}
33+
rm -f ${OUTPUT}
34+
exit 1
35+
fi
36+
}
37+
38+
# summary only for a process
39+
test_perf_trace "-s"
40+
41+
# normal output with summary at the end
42+
test_perf_trace "-S"
43+
44+
# summary only with an explicit summary mode
45+
test_perf_trace "-s --summary-mode=thread"
46+
47+
# summary with normal output - total summary mode
48+
test_perf_trace "-S --summary-mode=total"
49+
50+
# summary only for system wide - per-thread summary
51+
test_perf_trace "-as --summary-mode=thread --no-bpf-summary"
52+
53+
# summary only for system wide - total summary mode
54+
test_perf_trace "-as --summary-mode=total --no-bpf-summary"
55+
56+
# summary only for system wide - per-thread summary with BPF
57+
test_perf_trace "-as --summary-mode=thread --bpf-summary"
58+
59+
# summary only for system wide - total summary mode with BPF
60+
test_perf_trace "-as --summary-mode=total --bpf-summary"
61+
62+
# summary with normal output for system wide - total summary mode with BPF
63+
test_perf_trace "-aS --summary-mode=total --bpf-summary"
64+
65+
rm -f ${OUTPUT}

0 commit comments

Comments
 (0)