Skip to content

Commit 37e2a19

Browse files
notValordacmel
authored andcommitted
perf test pmu: Set uninitialized PMU alias to null
Commit 3e0bf9f ("perf pmu: Restore full PMU name wildcard support") adds a test case "PMU cmdline match" that covers PMU name wildcard support provided by function perf_pmu__match(). The test works with a wide range of supported combinations of PMU name matching but omits the case that if the perf_pmu__match() cannot match the PMU name to the wildcard, it tries to match its alias. However, this variable is not set up, causing the test case to fail when run with subprocesses or to segfault if run as a single process. ./perf test -vv 9 9: Sysfs PMU tests : 9.1: Parsing with PMU format directory : Ok 9.2: Parsing with PMU event : Ok 9.3: PMU event names : Ok 9.4: PMU name combining : Ok 9.5: PMU name comparison : Ok 9.6: PMU cmdline match : FAILED! ./perf test -F 9 9.1: Parsing with PMU format directory : Ok 9.2: Parsing with PMU event : Ok 9.3: PMU event names : Ok 9.4: PMU name combining : Ok 9.5: PMU name comparison : Ok Segmentation fault (core dumped) Initialize the PMU alias to null for all tests of perf_pmu__match() as this functionality is not being tested and the alias matching works exactly the same as the matching of the PMU name. ./perf test -F 9 9.1: Parsing with PMU format directory : Ok 9.2: Parsing with PMU event : Ok 9.3: PMU event names : Ok 9.4: PMU name combining : Ok 9.5: PMU name comparison : Ok 9.6: PMU cmdline match : Ok Fixes: 3e0bf9f ("perf pmu: Restore full PMU name wildcard support") Signed-off-by: Veronika Molnarova <[email protected]> Cc: James Clark <[email protected]> Cc: Michael Petlan <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Radostin Stoyanov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 2df5484 commit 37e2a19

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/perf/tests/pmu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,13 @@ static int test__name_cmp(struct test_suite *test __maybe_unused, int subtest __
453453
/**
454454
* Test perf_pmu__match() that's used to search for a PMU given a name passed
455455
* on the command line. The name that's passed may also be a filename type glob
456-
* match.
456+
* match. If the name does not match, perf_pmu__match() attempts to match the
457+
* alias of the PMU, if provided.
457458
*/
458459
static int test__pmu_match(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
459460
{
460461
struct perf_pmu test_pmu;
462+
test_pmu.alias_name = NULL;
461463

462464
test_pmu.name = "pmuname";
463465
TEST_ASSERT_EQUAL("Exact match", perf_pmu__match(&test_pmu, "pmuname"), true);

0 commit comments

Comments
 (0)