kfence: test: use new suite_{init/exit} support, add .kunitconfig
Currently, the kfence test suite could not run via "normal" means since KUnit didn't support per-suite setup/teardown. So it manually called internal kunit functions to run itself. This has some downsides, like missing TAP headers => can't use kunit.py to run or even parse the test results (w/o tweaks). Use the newly added support and convert it over, adding a .kunitconfig so it's even easier to run from kunit.py. People can now run the test via $ ./tools/testing/kunit/kunit.py run --kunitconfig=mm/kfence --arch=x86_64 ... [11:02:32] Testing complete. Passed: 23, Failed: 0, Crashed: 0, Skipped: 2, Errors: 0 [11:02:32] Elapsed time: 43.562s total, 0.003s configuring, 9.268s building, 34.281s running Cc: kasan-dev@googlegroups.com Signed-off-by: Daniel Latypov <dlatypov@google.com> Tested-by: David Gow <davidgow@google.com> Reviewed-by: Marco Elver <elver@google.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
parent
1cdba21db2
commit
3b91f82658
|
@ -0,0 +1,6 @@
|
||||||
|
CONFIG_KUNIT=y
|
||||||
|
CONFIG_KFENCE=y
|
||||||
|
CONFIG_KFENCE_KUNIT_TEST=y
|
||||||
|
|
||||||
|
# Additional dependencies.
|
||||||
|
CONFIG_FTRACE=y
|
|
@ -826,14 +826,6 @@ static void test_exit(struct kunit *test)
|
||||||
test_cache_destroy();
|
test_cache_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct kunit_suite kfence_test_suite = {
|
|
||||||
.name = "kfence",
|
|
||||||
.test_cases = kfence_test_cases,
|
|
||||||
.init = test_init,
|
|
||||||
.exit = test_exit,
|
|
||||||
};
|
|
||||||
static struct kunit_suite *kfence_test_suites[] = { &kfence_test_suite, NULL };
|
|
||||||
|
|
||||||
static void register_tracepoints(struct tracepoint *tp, void *ignore)
|
static void register_tracepoints(struct tracepoint *tp, void *ignore)
|
||||||
{
|
{
|
||||||
check_trace_callback_type_console(probe_console);
|
check_trace_callback_type_console(probe_console);
|
||||||
|
@ -847,11 +839,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 kfence_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 kfence_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
|
||||||
|
@ -859,18 +847,25 @@ static int __init kfence_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(kfence_test_suites);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kfence_test_exit(void)
|
static void kfence_suite_exit(struct kunit_suite *suite)
|
||||||
{
|
{
|
||||||
__kunit_test_suites_exit(kfence_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(kfence_test_init);
|
static struct kunit_suite kfence_test_suite = {
|
||||||
module_exit(kfence_test_exit);
|
.name = "kfence",
|
||||||
|
.test_cases = kfence_test_cases,
|
||||||
|
.init = test_init,
|
||||||
|
.exit = test_exit,
|
||||||
|
.suite_init = kfence_suite_init,
|
||||||
|
.suite_exit = kfence_suite_exit,
|
||||||
|
};
|
||||||
|
|
||||||
|
kunit_test_suites(&kfence_test_suite);
|
||||||
|
|
||||||
MODULE_LICENSE("GPL v2");
|
MODULE_LICENSE("GPL v2");
|
||||||
MODULE_AUTHOR("Alexander Potapenko <glider@google.com>, Marco Elver <elver@google.com>");
|
MODULE_AUTHOR("Alexander Potapenko <glider@google.com>, Marco Elver <elver@google.com>");
|
||||||
|
|
Loading…
Reference in New Issue