[PATCH v2 4/4] perf test: Update test for --for-each-cgroup option

From: Namhyung Kim

Date: Fri Jul 10 2026 - 19:42:25 EST


To simply check the number of output lines with and without the option.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
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..17b17b112169c8ba 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 -e cpu-clock -x, true 2>&1 | wc -l)
+ expand_output=$(perf stat -a -e cpu-clock -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