3 # SPDX-License-Identifier: GPL-2.0
9 echo "Basic stat command test"
10 if ! perf stat true 2>&1 | egrep -q "Performance counter stats for 'true':"
12 echo "Basic stat command test [Failed]"
16 echo "Basic stat command test [Success]"
19 test_stat_record_report() {
20 echo "stat record and report test"
21 if ! perf stat record -o - true | perf stat report -i - 2>&1 | \
22 egrep -q "Performance counter stats for 'pipe':"
24 echo "stat record and report test [Failed]"
28 echo "stat record and report test [Success]"
31 test_stat_repeat_weak_groups() {
32 echo "stat repeat weak groups test"
33 if ! perf stat -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}' \
34 true 2>&1 | grep -q 'seconds time elapsed'
36 echo "stat repeat weak groups test [Skipped event parsing failed]"
39 if ! perf stat -r2 -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}:W' \
42 echo "stat repeat weak groups test [Failed]"
46 echo "stat repeat weak groups test [Success]"
49 test_topdown_groups() {
50 # Topdown events must be grouped with the slots event first. Test that
51 # parse-events reorders this.
52 echo "Topdown event group test"
53 if ! perf stat -e '{slots,topdown-retiring}' true > /dev/null 2>&1
55 echo "Topdown event group test [Skipped event parsing failed]"
58 if perf stat -e '{slots,topdown-retiring}' true 2>&1 | egrep -q "<not supported>"
60 echo "Topdown event group test [Failed events not supported]"
64 if perf stat -e '{topdown-retiring,slots}' true 2>&1 | egrep -q "<not supported>"
66 echo "Topdown event group test [Failed slots not reordered first]"
70 echo "Topdown event group test [Success]"
73 test_topdown_weak_groups() {
74 # Weak groups break if the perf_event_open of multiple grouped events
75 # fails. Breaking a topdown group causes the events to fail. Test a very large
76 # grouping to see that the topdown events aren't broken out.
77 echo "Topdown weak groups test"
78 ok_grouping="{slots,topdown-bad-spec,topdown-be-bound,topdown-fe-bound,topdown-retiring},branch-instructions,branch-misses,bus-cycles,cache-misses,cache-references,cpu-cycles,instructions,mem-loads,mem-stores,ref-cycles,cache-misses,cache-references"
79 if ! perf stat --no-merge -e "$ok_grouping" true > /dev/null 2>&1
81 echo "Topdown weak groups test [Skipped event parsing failed]"
84 group_needs_break="{slots,topdown-bad-spec,topdown-be-bound,topdown-fe-bound,topdown-retiring,branch-instructions,branch-misses,bus-cycles,cache-misses,cache-references,cpu-cycles,instructions,mem-loads,mem-stores,ref-cycles,cache-misses,cache-references}:W"
85 if perf stat --no-merge -e "$group_needs_break" true 2>&1 | egrep -q "<not supported>"
87 echo "Topdown weak groups test [Failed events not supported]"
91 echo "Topdown weak groups test [Success]"
95 test_stat_record_report
96 test_stat_repeat_weak_groups
98 test_topdown_weak_groups