This adds a bit more build coverage for the tests even though these are
not expected to be enabled by normal users and distros. In order to make
this working we need to open-code kunit_test_suite() and call the
relevant functions directly in the driver init/exit hook.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
config USB4_KUNIT_TEST
bool "KUnit tests"
+ depends on USB4
depends on KUNIT=y
- depends on USB4=y
thunderbolt-${CONFIG_ACPI} += acpi.o
thunderbolt-$(CONFIG_DEBUG_FS) += debugfs.o
-
-obj-${CONFIG_USB4_KUNIT_TEST} += test.o
+thunderbolt-${CONFIG_USB4_KUNIT_TEST} += test.o
{
int ret;
+ tb_test_init();
+
tb_debugfs_init();
ret = tb_xdomain_init();
if (ret)
tb_xdomain_exit();
err_debugfs:
tb_debugfs_exit();
+ tb_test_exit();
return ret;
}
tb_nvm_exit();
tb_xdomain_exit();
tb_debugfs_exit();
+ tb_test_exit();
}
static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { }
#endif
+#ifdef CONFIG_USB4_KUNIT_TEST
+int tb_test_init(void);
+void tb_test_exit(void);
+#else
+static inline int tb_test_init(void) { return 0; }
+static inline void tb_test_exit(void) { }
+#endif
+
#endif
.name = "thunderbolt",
.test_cases = tb_test_cases,
};
-kunit_test_suite(tb_test_suite);
+
+static struct kunit_suite *tb_test_suites[] = { &tb_test_suite, NULL };
+
+int tb_test_init(void)
+{
+ return __kunit_test_suites_init(tb_test_suites);
+}
+
+void tb_test_exit(void)
+{
+ return __kunit_test_suites_exit(tb_test_suites);
+}