Skip to contentSkip to conversation

perf test: Improve pmu event metric testing

PATCH New Ian Rogers 1 participant 1 message May 13, 2020 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH v3 1/1 perf test: Improve pmu event metric testing

Break pmu-events test into 2 and add a test to verify that all pmu metric expressions simply parse. Try to parse all metric ids/events, skip/warn if metrics for the current architecture fail to parse. To support warning for a skip, and an ability for a subtest to describe why it skips.

Tested on power9, skylakex, haswell, broadwell, westmere, sandybridge and ivybridge.
May skip/warn on other architectures if metrics are invalid. In particular s390 is untested, but its expressions are trivial. The untested architectures with expressions are power8, cascadelakex, tremontx, skylake, jaketown, ivytown and variants of haswell and broadwell.

v3. addresses review comments from John Garry <[email protected]>, Jiri Olsa <[email protected]> and Arnaldo Carvalho de Melo <[email protected]>.
v2. changes the commit message as event parsing errors no longer cause the test to fail.

---
 tools/perf/tests/builtin-test.c |  16 ++-
 tools/perf/tests/pmu-events.c   | 168 ++++++++++++++++++++++++++++++--
 tools/perf/tests/tests.h        |   4 +
 3 files changed, 181 insertions(+), 7 deletions(-)
tools/perf/tests/builtin-test.c +15 -1
index 3471ec52ea11..21552e965545 100644
@@ -75,6 +75,13 @@ static struct test generic_tests[] = {
 	{
 		.desc = "PMU events",
 		.func = test__pmu_events,
+		.subtest = {
+			.skip_if_fail	= false,
+			.get_nr		= test__pmu_events_subtest_get_nr,
+			.get_desc	= test__pmu_events_subtest_get_desc,
+			.skip_reason	= test__pmu_events_subtest_skip_reason,
+		},
+
 	},
 	{
 		.desc = "DSO data read",
@@ -409,6 +416,7 @@ static int run_test(struct test *test, int subtest)
 
 static int test_and_print(struct test *t, bool force_skip, int subtest)
 {
+	const char *skip_reason = NULL;
 	int err;
 
 	if (!force_skip) {
@@ -430,7 +438,13 @@ static int test_and_print(struct test *t, bool force_skip, int subtest)
 		pr_info(" Ok\n");
 		break;
 	case TEST_SKIP:
-		color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
+		if (t->subtest.skip_reason)
+			skip_reason = t->subtest.skip_reason(subtest);
+		if (skip_reason) {
+			color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (%s)\n",
+				      skip_reason);
+		} else
+			color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
 		break;
 	case TEST_FAIL:
 	default:
tools/perf/tests/pmu-events.c +162 -6

192 lines not on this page · raw message

tools/perf/tests/tests.h +4 -0
index d6d4ac34eeb7..6c6c4b6a4796 100644
@@ -34,6 +34,7 @@ struct test {
 		bool skip_if_fail;
 		int (*get_nr)(void);
 		const char *(*get_desc)(int subtest);
+		const char *(*skip_reason)(int subtest);
 	} subtest;
 	bool (*is_supported)(void);
 	void *priv;
@@ -50,6 +51,9 @@ int test__perf_evsel__tp_sched_test(struct test *test, int subtest);
 int test__syscall_openat_tp_fields(struct test *test, int subtest);
 int test__pmu(struct test *test, int subtest);
 int test__pmu_events(struct test *test, int subtest);
+const char *test__pmu_events_subtest_get_desc(int subtest);
+const char *test__pmu_events_subtest_skip_reason(int subtest);
+int test__pmu_events_subtest_get_nr(void);
 int test__attr(struct test *test, int subtest);
 int test__dso_data(struct test *test, int subtest);
 int test__dso_data_cache(struct test *test, int subtest);
Signature · 1 line
2.26.2.645.ge9eca65c58-goog