mirror of https://gitee.com/openkylin/linux.git
perf tests: Add hybrid cases for 'Parse event definition strings' test
Add basic hybrid test cases for 'Parse event definition strings' test. # perf test 6 6: Parse event definition strings : Ok Signed-off-by: Jin Yao <yao.jin@linux.intel.com> Reviewed-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Kan Liang <kan.liang@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20210427070139.25256-19-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
91c0f5ec81
commit
2541cb63ac
|
@ -1512,6 +1512,124 @@ static int test__all_tracepoints(struct evlist *evlist)
|
|||
return test__checkevent_tracepoint_multi(evlist);
|
||||
}
|
||||
|
||||
static int test__hybrid_hw_event_with_pmu(struct evlist *evlist)
|
||||
{
|
||||
struct evsel *evsel = evlist__first(evlist);
|
||||
|
||||
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong config", 0x3c == evsel->core.attr.config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test__hybrid_hw_group_event(struct evlist *evlist)
|
||||
{
|
||||
struct evsel *evsel, *leader;
|
||||
|
||||
evsel = leader = evlist__first(evlist);
|
||||
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong config", 0x3c == evsel->core.attr.config);
|
||||
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
||||
|
||||
evsel = evsel__next(evsel);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong config", 0xc0 == evsel->core.attr.config);
|
||||
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test__hybrid_sw_hw_group_event(struct evlist *evlist)
|
||||
{
|
||||
struct evsel *evsel, *leader;
|
||||
|
||||
evsel = leader = evlist__first(evlist);
|
||||
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
||||
|
||||
evsel = evsel__next(evsel);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong config", 0x3c == evsel->core.attr.config);
|
||||
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test__hybrid_hw_sw_group_event(struct evlist *evlist)
|
||||
{
|
||||
struct evsel *evsel, *leader;
|
||||
|
||||
evsel = leader = evlist__first(evlist);
|
||||
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong config", 0x3c == evsel->core.attr.config);
|
||||
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
||||
|
||||
evsel = evsel__next(evsel);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test__hybrid_group_modifier1(struct evlist *evlist)
|
||||
{
|
||||
struct evsel *evsel, *leader;
|
||||
|
||||
evsel = leader = evlist__first(evlist);
|
||||
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong config", 0x3c == evsel->core.attr.config);
|
||||
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
||||
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
||||
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
||||
|
||||
evsel = evsel__next(evsel);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong config", 0xc0 == evsel->core.attr.config);
|
||||
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
||||
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
||||
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test__hybrid_raw1(struct evlist *evlist)
|
||||
{
|
||||
struct evsel *evsel = evlist__first(evlist);
|
||||
|
||||
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
|
||||
|
||||
/* The type of second event is randome value */
|
||||
evsel = evsel__next(evsel);
|
||||
TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test__hybrid_raw2(struct evlist *evlist)
|
||||
{
|
||||
struct evsel *evsel = evlist__first(evlist);
|
||||
|
||||
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test__hybrid_cache_event(struct evlist *evlist)
|
||||
{
|
||||
struct evsel *evsel = evlist__first(evlist);
|
||||
|
||||
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong config", 0x2 == (evsel->core.attr.config & 0xffffffff));
|
||||
|
||||
evsel = evsel__next(evsel);
|
||||
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->core.attr.type);
|
||||
TEST_ASSERT_VAL("wrong config", 0x10002 == (evsel->core.attr.config & 0xffffffff));
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct evlist_test {
|
||||
const char *name;
|
||||
__u32 type;
|
||||
|
@ -1868,6 +1986,54 @@ static struct terms_test test__terms[] = {
|
|||
},
|
||||
};
|
||||
|
||||
static struct evlist_test test__hybrid_events[] = {
|
||||
{
|
||||
.name = "cpu_core/cpu-cycles/",
|
||||
.check = test__hybrid_hw_event_with_pmu,
|
||||
.id = 0,
|
||||
},
|
||||
{
|
||||
.name = "{cpu_core/cpu-cycles/,cpu_core/instructions/}",
|
||||
.check = test__hybrid_hw_group_event,
|
||||
.id = 1,
|
||||
},
|
||||
{
|
||||
.name = "{cpu-clock,cpu_core/cpu-cycles/}",
|
||||
.check = test__hybrid_sw_hw_group_event,
|
||||
.id = 2,
|
||||
},
|
||||
{
|
||||
.name = "{cpu_core/cpu-cycles/,cpu-clock}",
|
||||
.check = test__hybrid_hw_sw_group_event,
|
||||
.id = 3,
|
||||
},
|
||||
{
|
||||
.name = "{cpu_core/cpu-cycles/k,cpu_core/instructions/u}",
|
||||
.check = test__hybrid_group_modifier1,
|
||||
.id = 4,
|
||||
},
|
||||
{
|
||||
.name = "r1a",
|
||||
.check = test__hybrid_raw1,
|
||||
.id = 5,
|
||||
},
|
||||
{
|
||||
.name = "cpu_core/r1a/",
|
||||
.check = test__hybrid_raw2,
|
||||
.id = 6,
|
||||
},
|
||||
{
|
||||
.name = "cpu_core/config=10,config1,config2=3,period=1000/u",
|
||||
.check = test__checkevent_pmu,
|
||||
.id = 7,
|
||||
},
|
||||
{
|
||||
.name = "cpu_core/LLC-loads/,cpu_atom/LLC-load-misses/",
|
||||
.check = test__hybrid_cache_event,
|
||||
.id = 8,
|
||||
},
|
||||
};
|
||||
|
||||
static int test_event(struct evlist_test *e)
|
||||
{
|
||||
struct parse_events_error err;
|
||||
|
@ -2035,6 +2201,11 @@ do { \
|
|||
ret2 = ret1; \
|
||||
} while (0)
|
||||
|
||||
if (perf_pmu__has_hybrid()) {
|
||||
TEST_EVENTS(test__hybrid_events);
|
||||
return ret2;
|
||||
}
|
||||
|
||||
TEST_EVENTS(test__events);
|
||||
|
||||
if (test_pmu())
|
||||
|
|
Loading…
Reference in New Issue