Skip to content

Commit e8478b8

Browse files
Petar Gligoricacmel
authored andcommitted
perf test: add new task-analyzer tests
Provide task-analyzer test cases for all possible arguments and a subset of possible combinations. 12 Tests in total. test_basic: - cmd:"perf script report task-analyzer" - Fundamental test of script without arguments. - Check for standard output. test_ns_rename: - cmd:"perf script report task-analyzer --ns --rename-comms-by-tids 0:random" - Standard task with timestamps in nanoseconds and comm renamed. - Check for standard output. test_ms_filtertasks_highlight: - cmd:"perf script report task-analyzer --ms --filter-tasks perf --highlight-tasks perf" - Standard task with timestamps in milliseconds, task filtered out and highlighted. - Check for standard output. test_extended_times_timelimit_limittasks: - cmd "perf script report task-analyzer --extended-times --time-limit :99999" - Standard task with additional schedule out/in info and timlimit active at 99999. - Check for extended table output. test_summary: - cmd:"perf script report task-analyzer --summary" - Standard task with additional summary output. - Check for summary print. test_summary_extended: - cmd:"perf script report task-analyzer --summary-extended" - Standard task with summary and additional schedule in/out info. - Chceck for extended table print. test_summaryonly: - cmd:"perf script report task-analyzer --summary-only" - Only summary should be printed. - Check for summary print. test_extended_times_summary_ns: - cmd:"perf script report task-analyzer --extended-times --summary --ns" - Standard task with extended schedule in/out information and summary in ns. - Check for extended table and summary. test_csv: - cmd:"perf script report task-analyzer --csv csv" - Print standard task to csv file in csv format. - Check for csv format. test_csv_extended_times: - cmd:"perf script report task-analyzer --csv csv --extended-times" - Print standard task to csv file in csv format with additional schedule in/out information. - Check for additional information and csv format. test_csvsummary: - cmd:"perf script report task-analyzer --csv-summary csvsummary" - Print summary to csvsummary file in csv format. - Check for csv format. test_csvsummary_extended: - cmd:"perf script report task-analyzer --csv-summary csvsummary --summary-extended" - Print summary to csvsummary file in csv format with additional schedule in/out information. - Check for additional information and csv format. Suggested-by: Ian Rogers <[email protected]> Signed-off-by: Petar Gligoric <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Hagen Paul Pfeifer <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent fdd0f81 commit e8478b8

File tree

1 file changed

+151
-0
lines changed

1 file changed

+151
-0
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#!/bin/bash
2+
# perf script task-analyzer tests
3+
# SPDX-License-Identifier: GPL-2.0
4+
5+
tmpdir=$(mktemp -d /tmp/perf-script-task-analyzer-XXXXX)
6+
err=0
7+
8+
cleanup() {
9+
rm -f perf.data
10+
rm -f perf.data.old
11+
rm -f csv
12+
rm -f csvsummary
13+
rm -rf $tmpdir
14+
trap - exit term int
15+
}
16+
17+
trap_cleanup() {
18+
cleanup
19+
exit 1
20+
}
21+
trap trap_cleanup exit term int
22+
23+
report() {
24+
if [ $1 = 0 ]; then
25+
echo "PASS: \"$2\""
26+
else
27+
echo "FAIL: \"$2\" Error message: \"$3\""
28+
err=1
29+
fi
30+
}
31+
32+
check_exec_0() {
33+
if [ $? != 0 ]; then
34+
report 1 "invokation of ${$1} command failed"
35+
fi
36+
}
37+
38+
find_str_or_fail() {
39+
grep -q "$1" $2
40+
if [ $? != 0 ]; then
41+
report 1 $3 "Failed to find required string:'${1}'."
42+
else
43+
report 0 $3
44+
fi
45+
}
46+
47+
prepare_perf_data() {
48+
# 1s should be sufficient to catch at least some switches
49+
perf record -e sched:sched_switch -a -- sleep 1 > /dev/null 2>&1
50+
}
51+
52+
# check standard inkvokation with no arguments
53+
test_basic() {
54+
out="$tmpdir/perf.out"
55+
perf script report task-analyzer > $out
56+
check_exec_0 "perf"
57+
find_str_or_fail "Comm" $out ${FUNCNAME[0]}
58+
}
59+
60+
test_ns_rename(){
61+
out="$tmpdir/perf.out"
62+
perf script report task-analyzer --ns --rename-comms-by-tids 0:random > $out
63+
check_exec_0 "perf"
64+
find_str_or_fail "Comm" $out ${FUNCNAME[0]}
65+
}
66+
67+
test_ms_filtertasks_highlight(){
68+
out="$tmpdir/perf.out"
69+
perf script report task-analyzer --ms --filter-tasks perf --highlight-tasks perf \
70+
> $out
71+
check_exec_0 "perf"
72+
find_str_or_fail "Comm" $out ${FUNCNAME[0]}
73+
}
74+
75+
test_extended_times_timelimit_limittasks() {
76+
out="$tmpdir/perf.out"
77+
perf script report task-analyzer --extended-times --time-limit :99999 \
78+
--limit-to-tasks perf > $out
79+
check_exec_0 "perf"
80+
find_str_or_fail "Out-Out" $out ${FUNCNAME[0]}
81+
}
82+
83+
test_summary() {
84+
out="$tmpdir/perf.out"
85+
perf script report task-analyzer --summary > $out
86+
check_exec_0 "perf"
87+
find_str_or_fail "Summary" $out ${FUNCNAME[0]}
88+
}
89+
90+
test_summaryextended() {
91+
out="$tmpdir/perf.out"
92+
perf script report task-analyzer --summary-extended > $out
93+
check_exec_0 "perf"
94+
find_str_or_fail "Inter Task Times" $out ${FUNCNAME[0]}
95+
}
96+
97+
test_summaryonly() {
98+
out="$tmpdir/perf.out"
99+
perf script report task-analyzer --summary-only > $out
100+
check_exec_0 "perf"
101+
find_str_or_fail "Summary" $out ${FUNCNAME[0]}
102+
}
103+
104+
test_extended_times_summary_ns() {
105+
out="$tmpdir/perf.out"
106+
perf script report task-analyzer --extended-times --summary --ns > $out
107+
check_exec_0 "perf"
108+
find_str_or_fail "Out-Out" $out ${FUNCNAME[0]}
109+
find_str_or_fail "Summary" $out ${FUNCNAME[0]}
110+
}
111+
112+
test_csv() {
113+
perf script report task-analyzer --csv csv > /dev/null
114+
check_exec_0 "perf"
115+
find_str_or_fail "Comm;" csv ${FUNCNAME[0]}
116+
}
117+
118+
test_csv_extended_times() {
119+
perf script report task-analyzer --csv csv --extended-times > /dev/null
120+
check_exec_0 "perf"
121+
find_str_or_fail "Out-Out;" csv ${FUNCNAME[0]}
122+
}
123+
124+
test_csvsummary() {
125+
perf script report task-analyzer --csv-summary csvsummary > /dev/null
126+
check_exec_0 "perf"
127+
find_str_or_fail "Comm;" csvsummary ${FUNCNAME[0]}
128+
}
129+
130+
test_csvsummary_extended() {
131+
perf script report task-analyzer --csv-summary csvsummary --summary-extended \
132+
>/dev/null
133+
check_exec_0 "perf"
134+
find_str_or_fail "Out-Out;" csvsummary ${FUNCNAME[0]}
135+
}
136+
137+
prepare_perf_data
138+
test_basic
139+
test_ns_rename
140+
test_ms_filtertasks_highlight
141+
test_extended_times_timelimit_limittasks
142+
test_summary
143+
test_summaryextended
144+
test_summaryonly
145+
test_extended_times_summary_ns
146+
test_csv
147+
test_csvsummary
148+
test_csv_extended_times
149+
test_csvsummary_extended
150+
cleanup
151+
exit $err

0 commit comments

Comments
 (0)