diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c index 478b33825790..263cbb67c861 100644 --- a/tools/perf/tests/pmu-events.c +++ b/tools/perf/tests/pmu-events.c @@ -812,6 +812,15 @@ static int check_parse_id(const char *id, struct parse_events_error *error, for (cur = strchr(dup, '@') ; cur; cur = strchr(++cur, '@')) *cur = '/'; + if (fake_pmu) { + /* + * Every call to __parse_events will try to initialize the PMU + * state from sysfs and then clean it up at the end. Reset the + * PMU events to the test state so that we don't pick up + * erroneous prefixes and suffixes. + */ + perf_pmu__test_parse_init(); + } ret = __parse_events(evlist, dup, error, fake_pmu); free(dup);