OSDN Git Service

thunderbolt: test: Use kunit_test_suite() macro
authorDavid Gow <davidgow@google.com>
Sat, 9 Jul 2022 03:19:59 +0000 (11:19 +0800)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 11 Jul 2022 23:13:21 +0000 (17:13 -0600)
The new implementation of kunit_test_suite() for modules no longer
conflicts with module_init, so can now be used by the thunderbolt tests.

Also update the Kconfig entry to enable the test when KUNIT_ALL_TESTS is
enabled.

This means that kunit_tool can now successfully run and parse the test
results with, for example:
./tools/testing/kunit/kunit.py run --arch=x86_64 \
--kconfig_add CONFIG_PCI=y --kconfig_add CONFIG_USB4=y \
'thunderbolt'

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Daniel Latypov <dlatypov@google.com>
Acked-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
drivers/thunderbolt/Kconfig
drivers/thunderbolt/domain.c
drivers/thunderbolt/tb.h
drivers/thunderbolt/test.c

index 4bfec8a..e76a6c1 100644 (file)
@@ -28,8 +28,10 @@ config USB4_DEBUGFS_WRITE
          this for production systems or distro kernels.
 
 config USB4_KUNIT_TEST
-       bool "KUnit tests"
-       depends on KUNIT=y
+       bool "KUnit tests" if !KUNIT_ALL_TESTS
+       depends on (USB4=m || KUNIT=y)
+       depends on KUNIT
+       default KUNIT_ALL_TESTS
 
 config USB4_DMA_TEST
        tristate "DMA traffic test driver"
index 2889a21..99211f3 100644 (file)
@@ -872,7 +872,6 @@ int tb_domain_init(void)
 {
        int ret;
 
-       tb_test_init();
        tb_debugfs_init();
        tb_acpi_init();
 
@@ -890,7 +889,6 @@ err_xdomain:
 err_acpi:
        tb_acpi_exit();
        tb_debugfs_exit();
-       tb_test_exit();
 
        return ret;
 }
@@ -903,5 +901,4 @@ void tb_domain_exit(void)
        tb_xdomain_exit();
        tb_acpi_exit();
        tb_debugfs_exit();
-       tb_test_exit();
 }
index 4602c69..a831faa 100644 (file)
@@ -1271,12 +1271,4 @@ static inline void tb_service_debugfs_init(struct tb_service *svc) { }
 static inline void tb_service_debugfs_remove(struct tb_service *svc) { }
 #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 ee37f8b..24c06e7 100644 (file)
@@ -2817,14 +2817,4 @@ static struct kunit_suite tb_test_suite = {
        .test_cases = tb_test_cases,
 };
 
-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);
-}
+kunit_test_suite(tb_test_suite);