Commit 039f3555 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf test: Convert pfm tests to use test cases.

Use null terminated array of test cases rather than the previous sub
test functions.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarSohaib Mohamed <sohaib.amhmd@gmail.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Brendan Higgins <brendanhiggins@google.com>
Cc: Daniel Latypov <dlatypov@google.com>
Cc: David Gow <davidgow@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20211104064208.3156807-10-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 9be56d30
...@@ -11,27 +11,6 @@ ...@@ -11,27 +11,6 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#ifdef HAVE_LIBPFM
static int test__pfm_events(void);
static int test__pfm_group(void);
#endif
static const struct {
int (*func)(void);
const char *desc;
} pfm_testcase_table[] = {
#ifdef HAVE_LIBPFM
{
.func = test__pfm_events,
.desc = "test of individual --pfm-events",
},
{
.func = test__pfm_group,
.desc = "test groups of --pfm-events",
},
#endif
};
#ifdef HAVE_LIBPFM #ifdef HAVE_LIBPFM
static int count_pfm_events(struct perf_evlist *evlist) static int count_pfm_events(struct perf_evlist *evlist)
{ {
...@@ -44,7 +23,8 @@ static int count_pfm_events(struct perf_evlist *evlist) ...@@ -44,7 +23,8 @@ static int count_pfm_events(struct perf_evlist *evlist)
return count; return count;
} }
static int test__pfm_events(void) static int test__pfm_events(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{ {
struct evlist *evlist; struct evlist *evlist;
struct option opt; struct option opt;
...@@ -104,7 +84,8 @@ static int test__pfm_events(void) ...@@ -104,7 +84,8 @@ static int test__pfm_events(void)
return 0; return 0;
} }
static int test__pfm_group(void) static int test__pfm_group(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{ {
struct evlist *evlist; struct evlist *evlist;
struct option opt; struct option opt;
...@@ -187,37 +168,28 @@ static int test__pfm_group(void) ...@@ -187,37 +168,28 @@ static int test__pfm_group(void)
} }
return 0; return 0;
} }
#endif #else
static int test__pfm_events(struct test_suite *test __maybe_unused,
static const char *test__pfm_subtest_get_desc(int i) int subtest __maybe_unused)
{
if (i < 0 || i >= (int)ARRAY_SIZE(pfm_testcase_table))
return NULL;
return pfm_testcase_table[i].desc;
}
static int test__pfm_subtest_get_nr(void)
{ {
return (int)ARRAY_SIZE(pfm_testcase_table); return TEST_SKIP;
} }
static int test__pfm(struct test_suite *test __maybe_unused, int i __maybe_unused) static int test__pfm_group(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{ {
#ifdef HAVE_LIBPFM
if (i < 0 || i >= (int)ARRAY_SIZE(pfm_testcase_table))
return TEST_FAIL;
return pfm_testcase_table[i].func();
#else
return TEST_SKIP; return TEST_SKIP;
#endif
} }
#endif
static struct test_case pfm_tests[] = {
TEST_CASE_REASON("test of individual --pfm-events", pfm_events, "not compiled in"),
TEST_CASE_REASON("test groups of --pfm-events", pfm_group, "not compiled in"),
{ .name = NULL, }
};
struct test_suite suite__pfm = { struct test_suite suite__pfm = {
.desc = "Test libpfm4 support", .desc = "Test libpfm4 support",
.func = test__pfm, .test_cases = pfm_tests,
.subtest = { .subtest = { .skip_if_fail = true }
.skip_if_fail = true,
.get_nr = test__pfm_subtest_get_nr,
.get_desc = test__pfm_subtest_get_desc,
}
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment