Commit 2434031c authored by Marco Elver's avatar Marco Elver Committed by Shuah Khan

kcsan: test: use new suite_{init,exit} support

Use the newly added suite_{init,exit} support for suite-wide init and
cleanup. This avoids the unsupported method by which the test used to do
suite-wide init and cleanup (avoiding issues such as missing TAP
headers, and possible future conflicts).
Signed-off-by: default avatarMarco Elver <elver@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent b18d2847
...@@ -1565,14 +1565,6 @@ static void test_exit(struct kunit *test) ...@@ -1565,14 +1565,6 @@ static void test_exit(struct kunit *test)
torture_cleanup_end(); torture_cleanup_end();
} }
static struct kunit_suite kcsan_test_suite = {
.name = "kcsan",
.test_cases = kcsan_test_cases,
.init = test_init,
.exit = test_exit,
};
static struct kunit_suite *kcsan_test_suites[] = { &kcsan_test_suite, NULL };
__no_kcsan __no_kcsan
static void register_tracepoints(struct tracepoint *tp, void *ignore) static void register_tracepoints(struct tracepoint *tp, void *ignore)
{ {
...@@ -1588,11 +1580,7 @@ static void unregister_tracepoints(struct tracepoint *tp, void *ignore) ...@@ -1588,11 +1580,7 @@ static void unregister_tracepoints(struct tracepoint *tp, void *ignore)
tracepoint_probe_unregister(tp, probe_console, NULL); tracepoint_probe_unregister(tp, probe_console, NULL);
} }
/* static int kcsan_suite_init(struct kunit_suite *suite)
* We only want to do tracepoints setup and teardown once, therefore we have to
* customize the init and exit functions and cannot rely on kunit_test_suite().
*/
static int __init kcsan_test_init(void)
{ {
/* /*
* Because we want to be able to build the test as a module, we need to * Because we want to be able to build the test as a module, we need to
...@@ -1600,18 +1588,25 @@ static int __init kcsan_test_init(void) ...@@ -1600,18 +1588,25 @@ static int __init kcsan_test_init(void)
* won't work here. * won't work here.
*/ */
for_each_kernel_tracepoint(register_tracepoints, NULL); for_each_kernel_tracepoint(register_tracepoints, NULL);
return __kunit_test_suites_init(kcsan_test_suites); return 0;
} }
static void kcsan_test_exit(void) static void kcsan_suite_exit(struct kunit_suite *suite)
{ {
__kunit_test_suites_exit(kcsan_test_suites);
for_each_kernel_tracepoint(unregister_tracepoints, NULL); for_each_kernel_tracepoint(unregister_tracepoints, NULL);
tracepoint_synchronize_unregister(); tracepoint_synchronize_unregister();
} }
late_initcall_sync(kcsan_test_init); static struct kunit_suite kcsan_test_suite = {
module_exit(kcsan_test_exit); .name = "kcsan",
.test_cases = kcsan_test_cases,
.init = test_init,
.exit = test_exit,
.suite_init = kcsan_suite_init,
.suite_exit = kcsan_suite_exit,
};
kunit_test_suites(&kcsan_test_suite);
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Marco Elver <elver@google.com>"); MODULE_AUTHOR("Marco Elver <elver@google.com>");
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