[PATCH v3 4/4] perf test: Update test for --for-each-cgroup option
From: Namhyung Kim
Date: Fri Jul 10 2026 - 20:04:56 EST
To simply check the number of output lines with and without the option.
Before this series, it failed like below:
$ perf test -v 125
125: perf stat --bpf-counters --for-each-cgroup test:
---- start ----
test child forked, pid 1941516
Normal output has 22 lines, but it now has 54
---- end(-1) ----
125: perf stat --bpf-counters --for-each-cgroup test : FAILED!
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
v3 changes)
* use default events and metrics (Sashiko)
* update the commit description
tools/perf/tests/shell/stat_bpf_counters_cgrp.sh | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/tools/perf/tests/shell/stat_bpf_counters_cgrp.sh b/tools/perf/tests/shell/stat_bpf_counters_cgrp.sh
index ff2e06c408bc6be1..febe3af0644157f3 100755
--- a/tools/perf/tests/shell/stat_bpf_counters_cgrp.sh
+++ b/tools/perf/tests/shell/stat_bpf_counters_cgrp.sh
@@ -58,9 +58,24 @@ check_system_wide_counted()
fi
}
+# Missing flags in evlist__clone() resulted in different output.
+# Just check the number of output lines for simple verification.
+check_evlist_expand()
+{
+ normal_output=$(perf stat -a -x, true 2>&1 | wc -l)
+ expand_output=$(perf stat -a -x, --bpf-counters --for-each-cgroup / true 2>&1 | wc -l)
+ if [ "${normal_output}" != "${expand_output}" ]; then
+ if [ "${verbose}" = "1" ]; then
+ echo "Normal output has ${normal_output} lines, but it now has ${expand_output}"
+ fi
+ exit 1
+ fi
+}
+
check_bpf_counter
find_cgroups
check_system_wide_counted
+check_evlist_expand
exit 0
--
2.55.0.795.g602f6c329a-goog