]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
thunderbolt: Allow KUnit tests to be built also when CONFIG_USB4=m
authorMika Westerberg <mika.westerberg@linux.intel.com>
Mon, 24 Aug 2020 09:46:52 +0000 (12:46 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Wed, 16 Sep 2020 11:57:46 +0000 (14:57 +0300)
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>
drivers/thunderbolt/Kconfig
drivers/thunderbolt/Makefile
drivers/thunderbolt/domain.c
drivers/thunderbolt/tb.h
drivers/thunderbolt/test.c

index 2257c22f8ab36c03bad05f2f48d46c852b739b20..afa3551633aaf6422e1fa5226c225f0913dc43b6 100644 (file)
@@ -28,5 +28,5 @@ config USB4_DEBUGFS_WRITE
 
 config USB4_KUNIT_TEST
        bool "KUnit tests"
+       depends on USB4
        depends on KUNIT=y
-       depends on USB4=y
index 61d5dff445b60a9ad0cc7a38db4c3b30d66c03ce..5715373710723361ff927dcd9e7f2394a38142ba 100644 (file)
@@ -6,5 +6,4 @@ thunderbolt-objs += nvm.o retimer.o quirks.o
 
 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
index a0182bf5a5f8bcacaf6c087714975eb79f457345..f0de94f7acbf9ff82a13424666f393c7d54a8706 100644 (file)
@@ -827,6 +827,8 @@ int tb_domain_init(void)
 {
        int ret;
 
+       tb_test_init();
+
        tb_debugfs_init();
        ret = tb_xdomain_init();
        if (ret)
@@ -841,6 +843,7 @@ err_xdomain:
        tb_xdomain_exit();
 err_debugfs:
        tb_debugfs_exit();
+       tb_test_exit();
 
        return ret;
 }
@@ -852,4 +855,5 @@ void tb_domain_exit(void)
        tb_nvm_exit();
        tb_xdomain_exit();
        tb_debugfs_exit();
+       tb_test_exit();
 }
index 8b04a9deffc79652fdcf4793453df32e4b1c68f9..5687bcf38a9e23b8bd0916fd3d7bbeeb33bd2ae2 100644 (file)
@@ -1030,4 +1030,12 @@ static inline void tb_switch_debugfs_init(struct tb_switch *sw) { }
 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
index a4d78811f7e20bfaaab69310efa69c73775237bf..464c2d37b992e507b0ca76a907ac8d1e4a46c8a0 100644 (file)
@@ -1623,4 +1623,15 @@ static struct kunit_suite tb_test_suite = {
        .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);
+}