Skip to content

Commit ba50aca

Browse files
tlfalcongregkh
authored andcommitted
perf test: Fix ratio_to_prev event parsing test
[ Upstream commit 77cb9b4 ] test__ratio_to_prev() assumed the first event in a group is the leader, which is not the case when the event is expanded into two event groups on hybrid PMU's with auto counter reload support. Instead, iterate over the event group generated for each core PMU. Also update "wrong leader" test to check that the subordinate event has the correct leader instead of checking that it is not the group leader. Finally, do not exit immediately if a PMU without auto counter reload support is found. Signed-off-by: Thomas Falcon <thomas.falcon@intel.com> Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Reviewed-by: Ian Rogers <irogers@google.com> Fixes: 56be0fe ("perf record: Add auto counter reload parse and regression tests") Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b8d0d73 commit ba50aca

1 file changed

Lines changed: 28 additions & 21 deletions

File tree

tools/perf/tests/parse-events.c

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,31 +1796,38 @@ static bool test__acr_valid(void)
17961796

17971797
static int test__ratio_to_prev(struct evlist *evlist)
17981798
{
1799-
struct evsel *evsel;
1799+
struct evsel *evsel, *leader;
18001800

18011801
TEST_ASSERT_VAL("wrong number of entries", 2 * perf_pmus__num_core_pmus() == evlist->core.nr_entries);
18021802

1803-
evlist__for_each_entry(evlist, evsel) {
1804-
if (!perf_pmu__has_format(evsel->pmu, "acr_mask"))
1805-
return TEST_OK;
1806-
1807-
if (evsel == evlist__first(evlist)) {
1808-
TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2);
1809-
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
1810-
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
1811-
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
1812-
TEST_ASSERT_EVSEL("unexpected event",
1813-
evsel__match(evsel, HARDWARE, HW_CPU_CYCLES),
1814-
evsel);
1815-
} else {
1816-
TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2);
1817-
TEST_ASSERT_VAL("wrong leader", !evsel__is_group_leader(evsel));
1818-
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 0);
1819-
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
1820-
TEST_ASSERT_EVSEL("unexpected event",
1821-
evsel__match(evsel, HARDWARE, HW_INSTRUCTIONS),
1822-
evsel);
1803+
evlist__for_each_entry(evlist, evsel) {
1804+
if (evsel != evsel__leader(evsel) ||
1805+
!perf_pmu__has_format(evsel->pmu, "acr_mask")) {
1806+
continue;
18231807
}
1808+
leader = evsel;
1809+
/* cycles */
1810+
TEST_ASSERT_VAL("wrong config2", 0 == leader->core.attr.config2);
1811+
TEST_ASSERT_VAL("wrong core.nr_members", leader->core.nr_members == 2);
1812+
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(leader) == 0);
1813+
TEST_ASSERT_EVSEL("unexpected event",
1814+
evsel__match(leader, HARDWARE, HW_CPU_CYCLES),
1815+
leader);
1816+
/*
1817+
* The period value gets configured within evlist__config,
1818+
* while this test executes only parse events method.
1819+
*/
1820+
TEST_ASSERT_VAL("wrong period", 0 == leader->core.attr.sample_period);
1821+
1822+
/* instructions/period=200000,ratio-to-prev=2.0/ */
1823+
evsel = evsel__next(evsel);
1824+
TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2);
1825+
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
1826+
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 0);
1827+
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
1828+
TEST_ASSERT_EVSEL("unexpected event",
1829+
evsel__match(evsel, HARDWARE, HW_INSTRUCTIONS),
1830+
evsel);
18241831
/*
18251832
* The period value gets configured within evlist__config,
18261833
* while this test executes only parse events method.

0 commit comments

Comments
 (0)