diff options
author | Ian Rogers <irogers@google.com> | 2021-11-03 23:41:53 -0700 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2021-11-13 10:32:26 -0300 |
commit | 78244d2e21146b88faffe2653397f0fa176794f1 (patch) | |
tree | 144bc5773f869af96eebb1ad63326a96ffdc415b /tools/perf/tests/tests.h | |
parent | f832044c8e8a92ab418bf11d10b18e7ffe024190 (diff) |
perf test: Add test case struct.
Add a test case struct mirroring the 'struct kunit_case'. Use the struct
with the DEFINE_SUITE macro, where the single test is turned into a test
case. Update the helpers in builtin-test to handle test cases.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
Acked-by: Jiri 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-8-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests/tests.h')
-rw-r--r-- | tools/perf/tests/tests.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 5139e24973cc..71b8d2c88e5c 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -31,6 +31,12 @@ struct test_suite; typedef int (*test_fnptr)(struct test_suite *, int); +struct test_case { + const char *name; + const char *desc; + test_fnptr run_case; +}; + struct test_suite { const char *desc; test_fnptr func; @@ -40,6 +46,7 @@ struct test_suite { const char *(*get_desc)(int subtest); const char *(*skip_reason)(int subtest); } subtest; + struct test_case *test_cases; bool (*is_supported)(void); void *priv; }; @@ -47,10 +54,21 @@ struct test_suite { #define DECLARE_SUITE(name) \ extern struct test_suite suite__##name; -#define DEFINE_SUITE(description, name) \ - struct test_suite suite__##name = { \ - .desc = description, \ - .func = test__##name, \ +#define TEST_CASE(description, _name) \ + { \ + .name = #_name, \ + .desc = description, \ + .run_case = test__##_name, \ + } + +#define DEFINE_SUITE(description, _name) \ + struct test_case tests__##_name[] = { \ + TEST_CASE(description, _name), \ + { .name = NULL, } \ + }; \ + struct test_suite suite__##_name = { \ + .desc = description, \ + .test_cases = tests__##_name, \ } /* Tests */ |