Skip to content

Commit 291cd54

Browse files
sulixshuahkh
authored andcommitted
mmc: sdhci-of-aspeed: test: Use kunit_test_suite() macro
The kunit_test_suite() macro is no-longer incompatible with module_add, so its use can be reinstated. Since this fixes parsing with builtins and kunit_tool, also enable the test by default when KUNIT_ALL_TESTS is enabled. The test can now be run via kunit_tool with: ./tools/testing/kunit/kunit.py run --arch=x86_64 \ --kconfig_add CONFIG_OF=y --kconfig_add CONFIG_OF_ADDRESS=y \ --kconfig_add CONFIG_MMC=y --kconfig_add CONFIG_MMC_SDHCI=y \ --kconfig_add CONFIG_MMC_SDHCI_PLTFM=y \ --kconfig_add CONFIG_MMC_SDHCI_OF_ASPEED=y \ 'sdhci-of-aspeed' (It may be worth adding a .kunitconfig at some point, as there are enough dependencies to make that command scarily long.) Acked-by: Daniel Latypov <dlatypov@google.com> Acked-by: Ulf Hansson <ulf.hansson@linaro.org> Acked-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent fe5be80 commit 291cd54

3 files changed

Lines changed: 5 additions & 42 deletions

File tree

drivers/mmc/host/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ config MMC_SDHCI_OF_ASPEED
169169
If unsure, say N.
170170

171171
config MMC_SDHCI_OF_ASPEED_TEST
172-
bool "Tests for the ASPEED SDHCI driver"
173-
depends on MMC_SDHCI_OF_ASPEED && KUNIT=y
172+
bool "Tests for the ASPEED SDHCI driver" if !KUNIT_ALL_TESTS
173+
depends on MMC_SDHCI_OF_ASPEED && KUNIT
174+
default KUNIT_ALL_TESTS
174175
help
175176
Enable KUnit tests for the ASPEED SDHCI driver. Select this
176177
option only if you will boot the kernel for the purpose of running

drivers/mmc/host/sdhci-of-aspeed-test.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,4 @@ static struct kunit_suite aspeed_sdhci_test_suite = {
9696
.test_cases = aspeed_sdhci_test_cases,
9797
};
9898

99-
static struct kunit_suite *aspeed_sdc_test_suite_array[] = {
100-
&aspeed_sdhci_test_suite,
101-
NULL,
102-
};
103-
104-
static struct kunit_suite **aspeed_sdc_test_suites
105-
__used __section(".kunit_test_suites") = aspeed_sdc_test_suite_array;
99+
kunit_test_suite(aspeed_sdhci_test_suite);

drivers/mmc/host/sdhci-of-aspeed.c

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -606,25 +606,6 @@ static struct platform_driver aspeed_sdc_driver = {
606606

607607
#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST)
608608
#include "sdhci-of-aspeed-test.c"
609-
610-
static inline int aspeed_sdc_tests_init(void)
611-
{
612-
return __kunit_test_suites_init(aspeed_sdc_test_suites);
613-
}
614-
615-
static inline void aspeed_sdc_tests_exit(void)
616-
{
617-
__kunit_test_suites_exit(aspeed_sdc_test_suites);
618-
}
619-
#else
620-
static inline int aspeed_sdc_tests_init(void)
621-
{
622-
return 0;
623-
}
624-
625-
static inline void aspeed_sdc_tests_exit(void)
626-
{
627-
}
628609
#endif
629610

630611
static int __init aspeed_sdc_init(void)
@@ -637,27 +618,14 @@ static int __init aspeed_sdc_init(void)
637618

638619
rc = platform_driver_register(&aspeed_sdc_driver);
639620
if (rc < 0)
640-
goto cleanup_sdhci;
641-
642-
rc = aspeed_sdc_tests_init();
643-
if (rc < 0) {
644-
platform_driver_unregister(&aspeed_sdc_driver);
645-
goto cleanup_sdhci;
646-
}
647-
648-
return 0;
649-
650-
cleanup_sdhci:
651-
platform_driver_unregister(&aspeed_sdhci_driver);
621+
platform_driver_unregister(&aspeed_sdhci_driver);
652622

653623
return rc;
654624
}
655625
module_init(aspeed_sdc_init);
656626

657627
static void __exit aspeed_sdc_exit(void)
658628
{
659-
aspeed_sdc_tests_exit();
660-
661629
platform_driver_unregister(&aspeed_sdc_driver);
662630
platform_driver_unregister(&aspeed_sdhci_driver);
663631
}

0 commit comments

Comments
 (0)