init: main: add KUnit to kernel init

Remove KUnit from init calls entirely, instead call directly from
kernel_init().

Change-Id: I9d62fa64356f7971e24cd4a9651f6e9c38bf9e3b
Signed-off-by: Brendan Higgins <brendanhiggins@google.com>
diff --git a/include/test/test.h b/include/test/test.h
index 2a1765f..4b76282 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -187,6 +187,8 @@ int test_init_test(struct test *test, const char *name);
 
 int test_run_tests(struct test_module *module);
 
+int test_executor_init(void);
+
 void test_install_initcall(struct test_initcall *initcall);
 
 #define test_pure_initcall(fn) postcore_initcall(fn)
diff --git a/init/main.c b/init/main.c
index 18f8f01..7ddbf5e 100644
--- a/init/main.c
+++ b/init/main.c
@@ -102,6 +102,8 @@
 #define CREATE_TRACE_POINTS
 #include <trace/events/initcall.h>
 
+#include <test/test.h>
+
 static int kernel_init(void *);
 
 extern void init_IRQ(void);
@@ -1143,6 +1145,10 @@ static noinline void __init kernel_init_freeable(void)
 
 	do_basic_setup();
 
+#if IS_ENABLED(CONFIG_TEST)
+	test_executor_init();
+#endif
+
 	/* Open the /dev/console on the rootfs, this should never fail */
 	if (ksys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
 		pr_err("Warning: unable to open an initial console.\n");
diff --git a/test/test-executor.c b/test/test-executor.c
index d751fde..92a5289 100644
--- a/test/test-executor.c
+++ b/test/test-executor.c
@@ -18,7 +18,8 @@ static bool test_run_all_tests(void)
 	return !has_test_failed;
 }
 
-static int test_executor_init(void)
+
+int test_executor_init(void)
 {
 	if (test_run_all_tests())
 		return 0;
@@ -26,4 +27,3 @@ static int test_executor_init(void)
 		return -EFAULT;
 }
 
-late_initcall(test_executor_init);