perf test: perf stat tests fails on s390
Subsystems (2)
PATCH 1/1 perf test: perf stat tests fails on s390
The test case 'perf stat tests' fails on s390 z/VM machines. The root cause is the unsupported CPU measurement facility on z/VM. Therefore the events cycles and instructions do not exist and are unsupported. This cause the subtest
Hide zero events stat test
to fail.
Output before:
# perf test 116 116: perf stat tests : FAILED!
=== Test Summary ===
Passed main tests : 0
Passed subtests : 0 Skipped tests : 0 Failed tests : 1
List of failed tests:
116: perf stat tests
#
Output after:
# ./perf test 116 116: perf stat tests : Ok
=== Test Summary ===
Passed main tests : 1
Passed subtests : 0 Skipped tests : 0 Failed tests : 0
#
--- tools/perf/tests/shell/stat.sh | 5 +++++ 1 file changed, 5 insertions(+)
tools/perf/tests/shell/stat.sh +5 -0
@@ -583,6 +583,11 @@ test_hide_zero_events_stat() { # Check that --metric-only works with --hide-zero-events if ! perf stat --hide-zero-events --metric-only -e instructions,cycles true > "${stat_output}" 2>&1 then + grep -q 'No supported events found' "${stat_output}" + if [ $? -eq 0 ]; then + echo "Hide zero events stat test [Skipped - events not supported]" + return + fi echo "Hide zero events stat test [Failed - metric-only command failed]" err=1 return
Signature · 1 line
2.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Code Fix: Replace with `if grep -q 'No supported events found' "${stat_output}"; then`.…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Code Fix: Replace with if grep -q 'No supported events found' "${stat_output}"; then. Standalone grep -q under set -e causes unexpected script abort. --
commit 4b80c04b99f0ab66b8227b70f1041582e256987c
Author: Thomas Richter <[email protected]>
perf test: perf stat tests fails on s390
This commit fixes a failure in the 'perf stat tests' on s390 z/VM by skipping the test if the cycles and instructions events are unsupported. It checks the output of the failed perf stat command for 'No supported events found' to determine if the test should be skipped.
tools/perf/tests/shell/stat.sh test_hide_zero_events_stat() { · line 587
Quoted 10 lines
tools/perf/tests/shell/stat.sh +2
-0@@ -583,6 +583,11 @@ test_hide_zero_events_stat() { # Check that --metric-only works with --hide-zero-events if ! perf stat --hide-zero-events --metric-only -e instructions,cycles true > "${stat_output}" 2>&1 then + grep -q 'No supported events found' "${stat_output}" + if [ $? -eq 0 ]; then
[Severity: Medium]
In test_hide_zero_events_stat(), will this standalone grep cause the script to abort unexpectedly?
If the script is running with 'set -e' and the perf stat command fails for any reason other than unsupported events, grep will not find a match and will return a non-zero exit code.
This non-zero exit directly forces a script abort, making the subsequent '$?' condition and fallback error handlers unreachable.
Should this be combined into the if statement directly?
if grep -q 'No supported events found' "${stat_output}"; then
echo "Hide zero events stat test [Skipped - events not supported]" return
fi
Quoted 6 lines
tools/perf/tests/shell/stat.sh +3
-0+ echo "Hide zero events stat test [Skipped - events not supported]" + return + fi echo "Hide zero events stat test [Failed - metric-only command failed]" err=1 return
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 59 lines · Thomas Richter
The test case 'perf stat tests' fails on s390 z/VM machines. The root cause is the unsupported CPU measurement facility on z/VM. Therefore the events cycles and instructions do not exist and are unsupported. This cause the subtest
Hide zero events stat test
to fail.Output before:
# perf test 116 116: perf stat tests : FAILED!=== Test Summary ===
Passed main tests : 0Passed subtests : 0 Skipped tests : 0 Failed tests : 1List of failed tests:
116: perf stat tests
#Output after:
# ./perf test 116 116: perf stat tests : Ok=== Test Summary ===
Passed main tests : 1Passed subtests : 0 Skipped tests : 0 Failed tests : 0#
Fixes 64724095a33f ("perf stat: Add --hide-zero-events option to suppress zero-count events")Cc Aaron Tomlin <[email protected]>Cc Ian Rogers <[email protected]>Cc Namhyung Kim <[email protected]>Signed-off-by Thomas Richter <[email protected]>--- tools/perf/tests/shell/stat.sh | 5 +++++ 1 file changed, 5 insertions(+)tools/perf/tests/shell/stat.sh +5
-0@@ -583,6 +583,11 @@ test_hide_zero_events_stat() { # Check that --metric-only works with --hide-zero-events if ! perf stat --hide-zero-events --metric-only -e instructions,cycles true > "${stat_output}" 2>&1 then + grep -q 'No supported events found' "${stat_output}" + if [ $? -eq 0 ]; then + echo "Hide zero events stat test [Skipped - events not supported]" + return + fi echo "Hide zero events stat test [Failed - metric-only command failed]" err=1 returnSignature · 1 line
2.55.0
Hi Thomas,
This makes sense.
However, please see the valid feedback from Sashiko [1]. Otherwise:
[1]: https://sashiko.dev/#/patchset/20260902115218.2977412-1-tmricht%40linux.ibm.com
Kind regards,
Signature · 1 line
Aaron Tomlin