Re: [PATCH 0/6 v1] perf test attr: Fix the re-enabled test
From: Namhyung Kim
Date: Tue Oct 06 2026 - 20:00:36 EST
On Tue, Oct 06, 2026 at 06:13:03PM +0200, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
>
> Hello all,
>
> This series fixes the "Perf attribute expectations test" (perf test 82,
> formerly "Setup struct perf_event_attr").
>
> Patches 1-2 are Michael Petlan's prerequisite fixes that make the shell
> wrapper propagate attr.py's return value and correct the
> perf_event_attr size expectation after struct config4 was added. They
> are included at the start of the series so that it applies cleanly on
> the current perf-tools-next (and for the review bots to verify the new
> patches); the new fixes are patches 3-6.
>
> With the test reporting failures again, several stale expectations
> surfaced and are addressed here:
>
> - test-record-graph-dwarf still expected PERF_SAMPLE_ADDR and
> PERF_SAMPLE_DATA_SRC for --call-graph dwarf. Those were dropped by
> bdd051e249141c79 ("perf record: Split --data-mmap option"), which
> decoupled data MMAP recording from the sample address bits.
>
> - The record and stat group tests expected cache-misses and
> instructions to be the legacy PERF_TYPE_HARDWARE events, but since
> b1c5efbfd92eb84d ("perf parse-events: Remove hard coded legacy
> hardware and cache parsing") they resolve to the core PMU sysfs/JSON
> events, so request the legacy encodings explicitly with the
> legacy-hardware-config term.
>
> - The perf stat default metrics open their events in groups and the
> raw encodings of instructions, branch-misses, cpu-cycles and
> stalled-cycles-frontend/backend differ between Intel and AMD, so
> base-stat now accepts the standalone and group variants and
> test-stat-default/detailed-{1,2,3} gained the per-vendor raw
> encodings.
>
> - attr.py no longer requires a recorded event to be in a group when
> the matching expectation does not declare one, allowing the stat
> tests to verify event attributes without encoding the metric
> grouping. Expectations that declare a group are still verified in
> both directions.
>
> The test passes with 'perf test -vv attribute' on x86_64. The AMD
> encodings come from the amd_pmu_event_map tables in
> arch/x86/events/amd/core.c.
On my machine, the current tmp.perf-tools-next which contains these
changes fails like this.
$ tools/perf/perf test -v 82
---- start ----
test child forked, pid 931585
/home/namhyung/project/linux/tools/perf/tests/shell/attr.sh: line 20: python: command not found
---- end(-1) ----
82: Perf attribute expectations test : FAILED!
=== Test Summary ===
Passed main tests : 0
Passed subtests : 0
Skipped tests : 0
Failed tests : 1
List of failed tests:
82: Perf attribute expectations test
The below patch fixes the problem.
Thanks,
Namhyung
diff --git a/tools/perf/tests/shell/attr.sh b/tools/perf/tests/shell/attr.sh
index 307e1535795a34dc..ca3ca4a193971ec1 100755
--- a/tools/perf/tests/shell/attr.sh
+++ b/tools/perf/tests/shell/attr.sh
@@ -4,6 +4,10 @@
err=0
+shelldir=$(dirname "$0")
+# shellcheck source=lib/setup_python.sh
+. "${shelldir}"/lib/setup_python.sh
+
cleanup() {
trap - EXIT TERM INT
}
@@ -17,7 +21,7 @@ trap trap_cleanup EXIT TERM INT
shelldir=$(dirname "$0")
perf_path=$(which perf)
-python "${shelldir}"/lib/attr.py -d "${shelldir}"/attr -v -p "$perf_path"
+$PYTHON "${shelldir}"/lib/attr.py -d "${shelldir}"/attr -v -p "$perf_path"
err=$?
cleanup
exit $err