Lines Matching +full:test +full:- +full:cpu
3 # SPDX-License-Identifier: GPL-2.0
5 set -e
8 stat_output=$(mktemp /tmp/perf-stat-test-output.XXXXX)
11 rm -f "${stat_output}"
12 trap - EXIT TERM INT
24 echo "Basic stat command test"
25 if ! perf stat true 2>&1 | grep -E -q "Performance counter stats for 'true':"
27 echo "Basic stat command test [Failed]"
31 echo "Basic stat command test [Success]"
35 echo "Null stat command test"
36 if ! perf stat --null true 2>&1 | grep -E -q "Performance counter stats for 'true':"
38 echo "Null stat command test [Failed]"
42 echo "Null stat command test [Success]"
48 if [[ ! -f /sys/devices/system/cpu/cpu$i/online || \
49 $(cat /sys/devices/system/cpu/cpu$i/online) == "0" ]]
55 echo "Failed to find offline CPU"
60 cpu=$(find_offline_cpu)
61 echo "Offline CPU stat command test (cpu $cpu)"
62 if ! perf stat "-C$cpu" -e cycles true 2>&1 | grep -E -q "No supported events found."
64 echo "Offline CPU stat command test [Failed]"
68 echo "Offline CPU stat command test [Success]"
72 echo "stat record and report test"
73 if ! perf stat record -e task-clock -o - true | perf stat report -i - 2>&1 | \
74 grep -E -q "Performance counter stats for 'pipe':"
76 echo "stat record and report test [Failed]"
80 echo "stat record and report test [Success]"
84 echo "stat record and script test"
85 if ! perf stat record -e task-clock -o - true | perf script -i - 2>&1 | \
86 …grep -E -q "CPU[[:space:]]+THREAD[[:space:]]+VAL[[:space:]]+ENA[[:space:]]+RUN[[:space:]]+TIME[[:s…
88 echo "stat record and script test [Failed]"
92 echo "stat record and script test [Success]"
96 echo "stat repeat weak groups test"
97 if ! perf stat -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}' \
98 true 2>&1 | grep -q 'seconds time elapsed'
100 echo "stat repeat weak groups test [Skipped event parsing failed]"
103 …if ! perf stat -r2 -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}:W' \
106 echo "stat repeat weak groups test [Failed]"
110 echo "stat repeat weak groups test [Success]"
114 # Topdown events must be grouped with the slots event first. Test that
115 # parse-events reorders this.
116 echo "Topdown event group test"
117 if ! perf stat -e '{slots,topdown-retiring}' true > /dev/null 2>&1
119 echo "Topdown event group test [Skipped event parsing failed]"
126 if perf stat -e "$events" true 2>&1 | grep -E -q "<not supported>"
128 echo "Topdown event group test [Failed $failure for '$events']"
133 do_topdown_group_test "{slots,topdown-retiring}" "events not supported"
136 "context-switches" "faults")
141 do_topdown_group_test "$filler1,topdown-retiring,slots" \
142 "slots not reordered first in no-group case"
143 do_topdown_group_test "slots,$filler1,topdown-retiring" \
144 "topdown metrics event not reordered in no-group case"
145 do_topdown_group_test "{$filler1,topdown-retiring,slots}" \
147 do_topdown_group_test "{$filler1,slots},topdown-retiring" \
149 do_topdown_group_test "topdown-retiring,{$filler1,slots}" \
151 do_topdown_group_test "{$filler1,slots},{topdown-retiring}" \
153 do_topdown_group_test "{topdown-retiring},{$filler1,slots}" \
155 do_topdown_group_test "{$filler1,slots},$filler2,topdown-retiring" \
156 "non-adjacent topdown metrics group not move into slots group"
157 do_topdown_group_test "$filler2,topdown-retiring,{$filler1,slots}" \
158 "non-adjacent topdown metrics group not move into slots group last"
159 do_topdown_group_test "{$filler1,slots},{$filler2,topdown-retiring}" \
161 do_topdown_group_test "{$filler1,topdown-retiring},{$filler2,slots}" \
164 if test "$td_err" -eq 0
166 echo "Topdown event group test [Success]"
174 # fails. Breaking a topdown group causes the events to fail. Test a very large
176 echo "Topdown weak groups test"
177 …-bad-spec,topdown-be-bound,topdown-fe-bound,topdown-retiring},branch-instructions,branch-misses,bu…
178 if ! perf stat --no-merge -e "$ok_grouping" true > /dev/null 2>&1
180 echo "Topdown weak groups test [Skipped event parsing failed]"
183 …-bad-spec,topdown-be-bound,topdown-fe-bound,topdown-retiring,branch-instructions,branch-misses,bus…
184 if perf stat --no-merge -e "$group_needs_break" true 2>&1 | grep -E -q "<not supported>"
186 echo "Topdown weak groups test [Failed events not supported]"
190 echo "Topdown weak groups test [Success]"
194 # Test --cputype argument.
195 echo "cputype test"
198 if perf stat --cputype="123" -e instructions true > /dev/null 2>&1
200 echo "cputype test [Bogus PMU didn't fail]"
208 for i in $devs/cpu $devs/cpu_atom $devs/armv8_pmuv3_0 $devs/armv8_cortex_*
211 if test -d "$i"
216 if perf stat -e "$i_base/instructions/" true > /dev/null 2>&1
222 if test "x$pmu" = "x"
224 echo "cputype test [Skipped known PMU not found]"
228 # Test running with cputype produces output.
229 if ! perf stat --cputype="$pmu" -e instructions true 2>&1 | grep -E -q "instructions"
231 echo "cputype test [Failed count missed with given filter]"
235 echo "cputype test [Success]"
239 # Test the default stat command on hybrid devices opens one cycles event for
240 # each CPU type.
241 echo "hybrid test"
244 pmus=$(ls /sys/bus/event_source/devices/*/cpus 2>/dev/null | wc -l)
245 if [ "$pmus" -lt 1 ]
251 …cycles_events=$(perf stat -a -- sleep 0.1 2>&1 | grep -E "/cpu-cycles/[uH]*| cpu-cycles[:uH]* " …
255 # can fall back to task-clock and so the end count may be 0. Fail if neither
257 if [ "$pmus" -ne "$cycles_events" ] && [ "0" -ne "$cycles_events" ]
259 echo "hybrid test [Found $pmus PMUs but $cycles_events cycles events. Failed]"
263 echo "hybrid test [Success]"
267 echo "stat -C <cpu> test"
268 # Test the full online CPU list (ranges and lists)
269 online_cpus=$(cat /sys/devices/system/cpu/online)
270 if ! perf stat -C "$online_cpus" -a true > "${stat_output}" 2>&1
272 echo "stat -C <cpu> test [Failed - command failed for cpus $online_cpus]"
278 if ! grep -E -q "Performance counter stats for" "${stat_output}"
280 echo "stat -C <cpu> test [Failed - missing output for cpus $online_cpus]"
286 # Test each individual online CPU
287 for cpu_dir in /sys/devices/system/cpu/cpu[0-9]*; do
288 cpu=${cpu_dir##*/cpu}
290 if [ -f "$cpu_dir/online" ] && [ "$(cat "$cpu_dir/online")" -eq 0 ]
295 if ! perf stat -C "$cpu" -a true > "${stat_output}" 2>&1
297 echo "stat -C <cpu> test [Failed - command failed for cpu $cpu]"
302 if ! grep -E -q "Performance counter stats for" "${stat_output}"
304 echo "stat -C <cpu> test [Failed - missing output for cpu $cpu]"
311 # Test synthetic list and range if cpu0 and cpu1 are online
314 if [ -d "/sys/devices/system/cpu/cpu0" ]
316 …if [ ! -f "/sys/devices/system/cpu/cpu0/online" ] || [ "$(cat /sys/devices/system/cpu/cpu0/online)…
321 if [ -d "/sys/devices/system/cpu/cpu1" ]
323 …if [ ! -f "/sys/devices/system/cpu/cpu1/online" ] || [ "$(cat /sys/devices/system/cpu/cpu1/online)…
329 if [ $c0_online -eq 1 ] && [ $c1_online -eq 1 ]
331 # Test list "0,1"
332 if ! perf stat -C "0,1" -a true > "${stat_output}" 2>&1
334 echo "stat -C <cpu> test [Failed - command failed for cpus 0,1]"
339 if ! grep -E -q "Performance counter stats for" "${stat_output}"
341 echo "stat -C <cpu> test [Failed - missing output for cpus 0,1]"
347 # Test range "0-1"
348 if ! perf stat -C "0-1" -a true > "${stat_output}" 2>&1
350 echo "stat -C <cpu> test [Failed - command failed for cpus 0-1]"
355 if ! grep -E -q "Performance counter stats for" "${stat_output}"
357 echo "stat -C <cpu> test [Failed - missing output for cpus 0-1]"
364 echo "stat -C <cpu> test [Success]"
368 echo "stat -A test"
369 if ! perf stat -A -a true > "${stat_output}" 2>&1
371 echo "stat -A test [Failed - command failed]"
377 if ! grep -E -q "CPU" "${stat_output}"
379 echo "stat -A test [Failed - missing CPU column]"
384 echo "stat -A test [Success]"
388 echo "stat -d test"
389 if ! perf stat -d true > "${stat_output}" 2>&1
391 echo "stat -d test [Failed - command failed]"
397 if ! grep -E -q "Performance counter stats" "${stat_output}"
399 echo "stat -d test [Failed - missing output]"
405 if ! perf stat -dd true > "${stat_output}" 2>&1
407 echo "stat -dd test [Failed - command failed]"
413 if ! grep -E -q "Performance counter stats" "${stat_output}"
415 echo "stat -dd test [Failed - missing output]"
421 if ! perf stat -ddd true > "${stat_output}" 2>&1
423 echo "stat -ddd test [Failed - command failed]"
429 if ! grep -E -q "Performance counter stats" "${stat_output}"
431 echo "stat -ddd test [Failed - missing output]"
437 echo "stat -d test [Success]"
441 echo "stat -r test"
442 if ! perf stat -r 2 true > "${stat_output}" 2>&1
444 echo "stat -r test [Failed - command failed]"
450 if ! grep -E -q "\([[:space:]]*\+-.*%[[:space:]]*\)" "${stat_output}"
452 echo "stat -r test [Failed - missing variance]"
457 echo "stat -r test [Success]"
461 echo "stat -p test"
464 if ! perf stat -p $pid > "${stat_output}" 2>&1
466 echo "stat -p test [Failed - command failed]"
474 if ! grep -E -q "Performance counter stats" "${stat_output}"
476 echo "stat -p test [Failed - missing output]"
480 echo "stat -p test [Success]"