@@ -197,6 +197,15 @@ void kunit_init_test(struct kunit *test, const char *name);
int kunit_run_tests(struct kunit_suite *suite);
+#if IS_BUILTIN(CONFIG_KUNIT)
+int kunit_run_all_tests(void);
+#else
+static inline int kunit_run_all_tests(void)
+{
+ return 0;
+}
+#endif /* IS_BUILTIN(CONFIG_KUNIT) */
+
/*
* If a test suite is built-in, module_init() gets translated into
* an initcall which we don't want as the idea is that for builtins
@@ -103,6 +103,8 @@
#define CREATE_TRACE_POINTS
#include <trace/events/initcall.h>
+#include <kunit/test.h>
+
static int kernel_init(void *);
extern void init_IRQ(void);
@@ -1201,6 +1203,8 @@ static noinline void __init kernel_init_freeable(void)
do_basic_setup();
+ kunit_run_all_tests();
+
console_on_rootfs();
/*
@@ -11,7 +11,7 @@ extern struct kunit_suite * const * const __kunit_suites_end[];
#if IS_BUILTIN(CONFIG_KUNIT)
-static int kunit_run_all_tests(void)
+int kunit_run_all_tests(void)
{
struct kunit_suite * const * const *suites, * const *subsuite;
bool has_test_failed = false;
@@ -31,6 +31,4 @@ static int kunit_run_all_tests(void)
return 0;
}
-late_initcall(kunit_run_all_tests);
-
#endif /* IS_BUILTIN(CONFIG_KUNIT) */