[PATCH v4 06/21] perf test attr: Relax group checking for ungrouped expectations
From: Arnaldo Carvalho de Melo
Date: Fri Oct 16 2026 - 17:26:39 EST
From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
When matching the recorded events back against the expectations,
attr.py requires every event opened in a group to match an expectation
that declares the same group. The perf stat default metrics open the
events of each metric in groups, but the test expectations only verify
the event attributes, so test-stat-default fails with:
FAILED '.../test-stat-default' - group failure
Only enforce the group of a recorded event when the expectation it
matches declares one. Expectations that ask for a group are still
verified in both directions.
Fixes: c7adeb0974f18da4 ("perf jevents: Add set of common metrics based on default ones")
Fixes: 2dfc0cab3da4a205 ("perf stat: Add detail -d,-dd,-ddd metrics")
Assisted-by: LLM
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/tests/shell/lib/attr.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/perf/tests/shell/lib/attr.py b/tools/perf/tests/shell/lib/attr.py
index 2d7dd26a5737777c..087bfa4532b69c58 100644
--- a/tools/perf/tests/shell/lib/attr.py
+++ b/tools/perf/tests/shell/lib/attr.py
@@ -372,7 +372,7 @@ class Test(object):
else:
raise Unsup(self)
- def compare(self, expect, result):
+ def compare(self, expect, result, strict_groups=True):
match = {}
log.debug(" compare")
@@ -406,8 +406,9 @@ class Test(object):
match[exp_name] = exp_list
- # For each defined group in the expected events
- # check we match the same group in the result.
+ # Check that each expected group is matched in the result; an event
+ # opened in a group may match an expectation that doesn't declare
+ # one, as those only verify the event attributes.
for exp_name, exp_event in expect.items():
group = exp_event.group
@@ -416,6 +417,8 @@ class Test(object):
for res_name in match[exp_name]:
res_group = result[res_name].group
+ if res_group == '' and not strict_groups:
+ continue
if res_group not in match[group]:
raise Fail(self, 'group failure')
@@ -454,7 +457,7 @@ class Test(object):
# do the expectation - results matching - both ways
self.compare(self.expect, self.result)
- self.compare(self.result, self.expect)
+ self.compare(self.result, self.expect, strict_groups=False)
finally:
# cleanup
--
2.55.0