From d20a6ba5e3be5f8d9002c6c5a5d4dfecc5dc48f9 Mon Sep 17 00:00:00 2001 From: Joe Fradley Date: Tue, 23 Aug 2022 07:24:54 -0700 Subject: kunit: add kunit.enable to enable/disable KUnit test This patch adds the kunit.enable module parameter that will need to be set to true in addition to KUNIT being enabled for KUnit tests to run. The default value is true giving backwards compatibility. However, for the production+testing use case the new config option KUNIT_DEFAULT_ENABLED can be set to N requiring the tester to opt-in by passing kunit.enable=1 to the kernel. Signed-off-by: Joe Fradley Reviewed-by: David Gow Signed-off-by: Shuah Khan --- include/kunit/test.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/kunit/test.h b/include/kunit/test.h index 840a2c375065..a6d6892b7957 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -228,6 +228,8 @@ static inline void kunit_set_failure(struct kunit *test) WRITE_ONCE(test->status, KUNIT_FAILURE); } +bool kunit_enabled(void); + void kunit_init_test(struct kunit *test, const char *name, char *log); int kunit_run_tests(struct kunit_suite *suite); -- cgit v1.2.3 From 7d97635b72813d80f909ad24d7a64b2fe9a29c0b Mon Sep 17 00:00:00 2001 From: Joe Fradley Date: Tue, 23 Aug 2022 07:24:55 -0700 Subject: kunit: no longer call module_info(test, "Y") for kunit modules Because KUnit test execution is not a guarantee with the kunit.enable parameter we want to be careful to only taint the kernel when actual tests run. Calling module_info(test, "Y") for every KUnit module automatically causes the kernel to be tainted upon module load. Therefore, we're removing this call and relying on the KUnit framework to taint the kernel or not. Signed-off-by: Joe Fradley Reviewed-by: David Gow Reviewed-by: Brendan Higgins Signed-off-by: Shuah Khan --- include/kunit/test.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/kunit/test.h b/include/kunit/test.h index a6d6892b7957..20cc4770cb3f 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -253,7 +253,6 @@ static inline int kunit_run_all_tests(void) #endif /* IS_BUILTIN(CONFIG_KUNIT) */ #define __kunit_test_suites(unique_array, ...) \ - MODULE_INFO(test, "Y"); \ static struct kunit_suite *unique_array[] \ __aligned(sizeof(struct kunit_suite *)) \ __used __section(".kunit_test_suites") = { __VA_ARGS__ } -- cgit v1.2.3