Skip to content

Commit 5123509

Browse files
captain5050namhyung
authored andcommitted
perf tests stat: Add test for error for an offline CPU
Add a test that if an offline CPU is requested perf stat will fail. $ perf test -vv "perf stat tests" 101: perf stat tests: --- start --- test child forked, pid 46965 Basic stat command test Basic stat command test [Success] Null stat command test Null stat command test [Success] Offline CPU stat command test (cpu 8) Offline CPU stat command test [Success] stat record and report test stat record and report test [Success] stat record and script test stat record and script test [Success] stat repeat weak groups test stat repeat weak groups test [Success] Topdown event group test Topdown event group test [Success] Topdown weak groups test Topdown weak groups test [Skipped event parsing failed] cputype test cputype test [Success] hybrid test hybrid test [Success] ---- end(0) ---- 101: perf stat tests : Ok Reported-by: Thomas Richter <tmricht@linux.ibm.com> Closes: https://lore.kernel.org/linux-perf-users/94313b82-888b-4f42-9fb0-4585f9e90080@linux.ibm.com/ Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent c9a8c34 commit 5123509

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tools/perf/tests/shell/stat.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,32 @@ test_null_stat() {
2727
echo "Null stat command test [Success]"
2828
}
2929

30+
find_offline_cpu() {
31+
for i in $(seq 1 4096)
32+
do
33+
if [[ ! -f /sys/devices/system/cpu/cpu$i/online || \
34+
$(cat /sys/devices/system/cpu/cpu$i/online) == "0" ]]
35+
then
36+
echo $i
37+
return
38+
fi
39+
done
40+
echo "Failed to find offline CPU"
41+
exit 1
42+
}
43+
44+
test_offline_cpu_stat() {
45+
cpu=$(find_offline_cpu)
46+
echo "Offline CPU stat command test (cpu $cpu)"
47+
if ! perf stat "-C$cpu" -e cycles true 2>&1 | grep -E -q "No supported events found."
48+
then
49+
echo "Offline CPU stat command test [Failed]"
50+
err=1
51+
return
52+
fi
53+
echo "Offline CPU stat command test [Success]"
54+
}
55+
3056
test_stat_record_report() {
3157
echo "stat record and report test"
3258
if ! perf stat record -e task-clock -o - true | perf stat report -i - 2>&1 | \
@@ -224,6 +250,7 @@ test_hybrid() {
224250

225251
test_default_stat
226252
test_null_stat
253+
test_offline_cpu_stat
227254
test_stat_record_report
228255
test_stat_record_script
229256
test_stat_repeat_weak_groups

0 commit comments

Comments
 (0)