Message ID | 20220621085345.603820-1-davidgow@google.com |
---|---|
Headers | show |
Series | Rework KUnit test execution in modules | expand |
On Tue, Jun 21, 2022 at 1:54 AM David Gow <davidgow@google.com> wrote: > > 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' With this, we can maybe revive https://lore.kernel.org/lkml/20220214184104.1710107-1-dlatypov@google.com by tacking it onto this series if a v3 goes out. There is the open question of whether we should put UML-specific config options in the file, though. If we decide we don't want that, then we can defer it until I send out the patches for "repeatable --kunitconfig" and we can add the uml_pci.config file. > > Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> > Signed-off-by: David Gow <davidgow@google.com> Acked-by: Daniel Latypov <dlatypov@google.com> LGTM.
On Tue, Jun 21, 2022 at 1:54 AM David Gow <davidgow@google.com> wrote: > > 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.) > > Signed-off-by: David Gow <davidgow@google.com> Acked-by: Daniel Latypov <dlatypov@google.com> Minor, optional suggestion below. > static int __init aspeed_sdc_init(void) > @@ -639,12 +620,6 @@ static int __init aspeed_sdc_init(void) > if (rc < 0) > goto cleanup_sdhci; > > - rc = aspeed_sdc_tests_init(); > - if (rc < 0) { > - platform_driver_unregister(&aspeed_sdc_driver); > - goto cleanup_sdhci; > - } > - > return 0; > > cleanup_sdhci: This goto was added in 4af307f57426 ("mmc: sdhci-of-aspeed: Fix kunit-related build error") to allow for this extra call to aspeed_sdc_tests_init(). This could now be reverted back to what is rc = platform_driver_register(&aspeed_sdc_driver); if (rc < 0) platform_driver_unregister(&aspeed_sdhci_driver); return rc; but let's see what the maintainers think.
On Tue, Jun 21, 2022 at 4:54 PM David Gow <davidgow@google.com> wrote: > > 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> > Signed-off-by: David Gow <davidgow@google.com> > --- > > Changes since v1: > https://lore.kernel.org/linux-kselftest/20220618090310.1174932-4-davidgow@google.com/ > - Actually include the Kconfig changes, which were mistakenly added to > the next patch in the series in v1. > - Add Acked-by tag from Mika Westerberg > > --- > drivers/thunderbolt/Kconfig | 5 +++-- > drivers/thunderbolt/domain.c | 3 --- > drivers/thunderbolt/tb.h | 8 -------- > drivers/thunderbolt/test.c | 12 +----------- > 4 files changed, 4 insertions(+), 24 deletions(-) > > diff --git a/drivers/thunderbolt/Kconfig b/drivers/thunderbolt/Kconfig > index 4bfec8a28064..2a063d344b94 100644 > --- a/drivers/thunderbolt/Kconfig > +++ b/drivers/thunderbolt/Kconfig > @@ -28,8 +28,9 @@ 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 KUNIT > + default KUNIT_ALL_TESTS > FYI: It turns out we can't just replace the "depends on KUNIT=y" with "depends on KUNIT" here, as it's still possible to have CONFIG_USB4=y and CONFIG_KUNIT=m, which would lead to missing KUnit symbols during link. What does work is adding, in addition to "depends on KUNIT": depends on (USB4=m || KUNIT=y) Which will prevent the tests from being enabled in this situation. I'll wait another day or so before sending out a v3 with this fixed, in case there are any other issues which arise. Cheers, -- David
On Wed, 22 Jun 2022 at 00:19, Daniel Latypov <dlatypov@google.com> wrote: > > On Tue, Jun 21, 2022 at 1:54 AM David Gow <davidgow@google.com> wrote: > > > > 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.) > > > > Signed-off-by: David Gow <davidgow@google.com> > > Acked-by: Daniel Latypov <dlatypov@google.com> > > Minor, optional suggestion below. > > > static int __init aspeed_sdc_init(void) > > @@ -639,12 +620,6 @@ static int __init aspeed_sdc_init(void) > > if (rc < 0) > > goto cleanup_sdhci; > > > > - rc = aspeed_sdc_tests_init(); > > - if (rc < 0) { > > - platform_driver_unregister(&aspeed_sdc_driver); > > - goto cleanup_sdhci; > > - } > > - > > return 0; > > > > cleanup_sdhci: > > This goto was added in 4af307f57426 ("mmc: sdhci-of-aspeed: Fix > kunit-related build error") to allow for this extra call to > aspeed_sdc_tests_init(). > > This could now be reverted back to what is > rc = platform_driver_register(&aspeed_sdc_driver); > if (rc < 0) > platform_driver_unregister(&aspeed_sdhci_driver); > > return rc; > > but let's see what the maintainers think. I don't have a strong opinion on this, feel free to pick any of the options. Acked-by: Ulf Hansson <ulf.hansson@linaro.org> Kind regards Uffe