[PATCH v2 2/2] perf test: Add test case for group members
From: Jin Yao
Date: Mon May 25 2020 - 02:58:11 EST
The evlist may consist of some event + group combinations.
For example, perf stat -e "A,{B,C},D".
This patch testes the event in evlist to see if it has the
correct leader and correct nr_members.
Signed-off-by: Jin Yao <yao.jin@xxxxxxxxxxxxxxx>
---
tools/perf/tests/parse-events.c | 35 ++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 895188b63f96..d584b77c878d 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1386,6 +1386,34 @@ static int test__sym_event_dc(struct evlist *evlist)
return 0;
}
+static int test__mixed_group(struct evlist *evlist)
+{
+ struct evsel *evsel, *leader;
+
+ TEST_ASSERT_VAL("wrong number of entries", 4 == evlist->core.nr_entries);
+
+ /* cycles - leader is also itself */
+ evsel = leader = evlist__first(evlist);
+ TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
+ TEST_ASSERT_VAL("wrong nr_members", 0 == evsel->core.nr_members);
+
+ /* {cache-misses,branch-misses} - leader is cache-misses */
+ evsel = leader = evsel__next(evsel);
+ TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
+ TEST_ASSERT_VAL("wrong nr_members", 2 == evsel->core.nr_members);
+
+ evsel = evsel__next(evsel);
+ TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
+ TEST_ASSERT_VAL("wrong nr_members", 0 == evsel->core.nr_members);
+
+ /* instructions - leader is also itself */
+ evsel = leader = evlist__first(evlist);
+ TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
+ TEST_ASSERT_VAL("wrong nr_members", 0 == evsel->core.nr_members);
+
+ return 0;
+}
+
static int count_tracepoints(void)
{
struct dirent *events_ent;
@@ -1737,7 +1765,12 @@ static struct evlist_test test__events[] = {
.name = "cycles:k",
.check = test__sym_event_dc,
.id = 55,
- }
+ },
+ {
+ .name = "cycles,{cache-misses,branch-misses},instructions",
+ .check = test__mixed_group,
+ .id = 56,
+ },
};
static struct evlist_test test__events_pmu[] = {
--
2.17.1