diff --git a/lib/kunit/test.c b/lib/kunit/test.c index 3bca3bf5c15b..c47bc34b97c0 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -52,6 +52,13 @@ void __kunit_fail_current_test(const char *file, int line, const char *fmt, ...) EXPORT_SYMBOL_GPL(__kunit_fail_current_test); #endif +/* + * Enable KUnit tests to run. + */ +static bool enable_param; +module_param_named(enable, enable_param, bool, 0); +MODULE_PARM_DESC(enable, "Enable KUnit tests to run"); + /* * KUnit statistic mode: * 0 - disabled @@ -568,6 +575,12 @@ int __kunit_test_suites_init(struct kunit_suite * const * const suites) { unsigned int i; + if (!enable_param) { + pr_info("kunit: deactivated, cannot load %s\n", + suites != NULL ? suites[0]->name : "NULL"); + return -1; + } + for (i = 0; suites[i] != NULL; i++) { kunit_init_suite(suites[i]); kunit_run_tests(suites[i]); @@ -585,6 +598,9 @@ void __kunit_test_suites_exit(struct kunit_suite **suites) { unsigned int i; + if (!enable_param) + return; + for (i = 0; suites[i] != NULL; i++) kunit_exit_suite(suites[i]);