2022-07-15 04:24:10

by David Gow

[permalink] [raw]
Subject: [PATCH] mmc: sdhci-of-aspeed: test: Fix dependencies when KUNIT=m

While the sdhci-of-aspeed KUnit tests do work when builtin, and do work
when KUnit itself is being built as a module, the two together break.

This is because the KUnit tests (understandably) depend on KUnit, so a
built-in test cannot build if KUnit is a module.

Fix this by adding a dependency on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y),
which only excludes this one problematic configuration.

This was reported on a nasty openrisc-randconfig run by the kernel test
robot, though for some reason (compiler optimisations removing the test
code?) I wasn't able to reproduce it locally on x86:
https://lore.kernel.org/linux-mm/[email protected]/T/

Fixes: 291cd54e5b05 ("mmc: sdhci-of-aspeed: test: Use kunit_test_suite() macro")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: David Gow <[email protected]>
---
drivers/mmc/host/Kconfig | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 10c563999d3d..e63608834411 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -171,6 +171,7 @@ config MMC_SDHCI_OF_ASPEED
config MMC_SDHCI_OF_ASPEED_TEST
bool "Tests for the ASPEED SDHCI driver" if !KUNIT_ALL_TESTS
depends on MMC_SDHCI_OF_ASPEED && KUNIT
+ depends on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y)
default KUNIT_ALL_TESTS
help
Enable KUnit tests for the ASPEED SDHCI driver. Select this
--
2.37.0.170.g444d1eabd0-goog


2022-07-18 00:59:16

by Andrew Jeffery

[permalink] [raw]
Subject: Re: [PATCH] mmc: sdhci-of-aspeed: test: Fix dependencies when KUNIT=m



On Fri, 15 Jul 2022, at 13:33, David Gow wrote:
> While the sdhci-of-aspeed KUnit tests do work when builtin, and do work
> when KUnit itself is being built as a module, the two together break.
>
> This is because the KUnit tests (understandably) depend on KUnit, so a
> built-in test cannot build if KUnit is a module.
>
> Fix this by adding a dependency on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y),
> which only excludes this one problematic configuration.
>
> This was reported on a nasty openrisc-randconfig run by the kernel test
> robot, though for some reason (compiler optimisations removing the test
> code?) I wasn't able to reproduce it locally on x86:
> https://lore.kernel.org/linux-mm/[email protected]/T/
>
> Fixes: 291cd54e5b05 ("mmc: sdhci-of-aspeed: test: Use kunit_test_suite() macro")
> Reported-by: kernel test robot <[email protected]>
> Signed-off-by: David Gow <[email protected]>
> ---
> drivers/mmc/host/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
> index 10c563999d3d..e63608834411 100644
> --- a/drivers/mmc/host/Kconfig
> +++ b/drivers/mmc/host/Kconfig
> @@ -171,6 +171,7 @@ config MMC_SDHCI_OF_ASPEED
> config MMC_SDHCI_OF_ASPEED_TEST
> bool "Tests for the ASPEED SDHCI driver" if !KUNIT_ALL_TESTS
> depends on MMC_SDHCI_OF_ASPEED && KUNIT
> + depends on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y)

Should this replace the line above? Isn't it just more constrained?

Regardless, thanks for your work here, the kunit integration with the
ASPEED SDHCI driver bothered me a lot when I wrote it.

Andrew

2022-07-19 01:51:19

by David Gow

[permalink] [raw]
Subject: Re: [PATCH] mmc: sdhci-of-aspeed: test: Fix dependencies when KUNIT=m

On Mon, Jul 18, 2022 at 8:45 AM Andrew Jeffery <[email protected]> wrote:
>
>
>
> On Fri, 15 Jul 2022, at 13:33, David Gow wrote:
> > While the sdhci-of-aspeed KUnit tests do work when builtin, and do work
> > when KUnit itself is being built as a module, the two together break.
> >
> > This is because the KUnit tests (understandably) depend on KUnit, so a
> > built-in test cannot build if KUnit is a module.
> >
> > Fix this by adding a dependency on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y),
> > which only excludes this one problematic configuration.
> >
> > This was reported on a nasty openrisc-randconfig run by the kernel test
> > robot, though for some reason (compiler optimisations removing the test
> > code?) I wasn't able to reproduce it locally on x86:
> > https://lore.kernel.org/linux-mm/[email protected]/T/
> >
> > Fixes: 291cd54e5b05 ("mmc: sdhci-of-aspeed: test: Use kunit_test_suite() macro")
> > Reported-by: kernel test robot <[email protected]>
> > Signed-off-by: David Gow <[email protected]>
> > ---
> > drivers/mmc/host/Kconfig | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
> > index 10c563999d3d..e63608834411 100644
> > --- a/drivers/mmc/host/Kconfig
> > +++ b/drivers/mmc/host/Kconfig
> > @@ -171,6 +171,7 @@ config MMC_SDHCI_OF_ASPEED
> > config MMC_SDHCI_OF_ASPEED_TEST
> > bool "Tests for the ASPEED SDHCI driver" if !KUNIT_ALL_TESTS
> > depends on MMC_SDHCI_OF_ASPEED && KUNIT
> > + depends on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y)
>
> Should this replace the line above? Isn't it just more constrained?
>

We need both lines. The first ensures that both KUNIT and
MMC_SDHCI_OF_ASPEED are available, and the second just targets the
case where KUNIT=m and MMC_SDHCI_OF_ASPEED=y.
If we got rid of the first line, we could end up compiling this
without KUnit at all (if MMC_SDHCI_OF_ASPEED=m).

> Regardless, thanks for your work here, the kunit integration with the
> ASPEED SDHCI driver bothered me a lot when I wrote it.

No worries: we're all still figuring out exactly how these sorts of
tests should interact with modules, so it's been a great real-world
example for us to experiment with.

Cheers,
-- David


Attachments:
smime.p7s (3.91 kB)
S/MIME Cryptographic Signature

2022-07-19 02:56:29

by Andrew Jeffery

[permalink] [raw]
Subject: Re: [PATCH] mmc: sdhci-of-aspeed: test: Fix dependencies when KUNIT=m



On Tue, 19 Jul 2022, at 11:11, David Gow wrote:
> On Mon, Jul 18, 2022 at 8:45 AM Andrew Jeffery <[email protected]> wrote:
>>
>>
>>
>> On Fri, 15 Jul 2022, at 13:33, David Gow wrote:
>> > While the sdhci-of-aspeed KUnit tests do work when builtin, and do work
>> > when KUnit itself is being built as a module, the two together break.
>> >
>> > This is because the KUnit tests (understandably) depend on KUnit, so a
>> > built-in test cannot build if KUnit is a module.
>> >
>> > Fix this by adding a dependency on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y),
>> > which only excludes this one problematic configuration.
>> >
>> > This was reported on a nasty openrisc-randconfig run by the kernel test
>> > robot, though for some reason (compiler optimisations removing the test
>> > code?) I wasn't able to reproduce it locally on x86:
>> > https://lore.kernel.org/linux-mm/[email protected]/T/
>> >
>> > Fixes: 291cd54e5b05 ("mmc: sdhci-of-aspeed: test: Use kunit_test_suite() macro")
>> > Reported-by: kernel test robot <[email protected]>
>> > Signed-off-by: David Gow <[email protected]>
>> > ---
>> > drivers/mmc/host/Kconfig | 1 +
>> > 1 file changed, 1 insertion(+)
>> >
>> > diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
>> > index 10c563999d3d..e63608834411 100644
>> > --- a/drivers/mmc/host/Kconfig
>> > +++ b/drivers/mmc/host/Kconfig
>> > @@ -171,6 +171,7 @@ config MMC_SDHCI_OF_ASPEED
>> > config MMC_SDHCI_OF_ASPEED_TEST
>> > bool "Tests for the ASPEED SDHCI driver" if !KUNIT_ALL_TESTS
>> > depends on MMC_SDHCI_OF_ASPEED && KUNIT
>> > + depends on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y)
>>
>> Should this replace the line above? Isn't it just more constrained?
>>
>
> We need both lines. The first ensures that both KUNIT and
> MMC_SDHCI_OF_ASPEED are available, and the second just targets the
> case where KUNIT=m and MMC_SDHCI_OF_ASPEED=y.
> If we got rid of the first line, we could end up compiling this
> without KUnit at all (if MMC_SDHCI_OF_ASPEED=m).

Ah, yes. Fair enough!

Acked-by: Andrew Jeffery <[email protected]>

2022-07-19 09:01:16

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH] mmc: sdhci-of-aspeed: test: Fix dependencies when KUNIT=m

On Fri, 15 Jul 2022 at 06:04, David Gow <[email protected]> wrote:
>
> While the sdhci-of-aspeed KUnit tests do work when builtin, and do work
> when KUnit itself is being built as a module, the two together break.
>
> This is because the KUnit tests (understandably) depend on KUnit, so a
> built-in test cannot build if KUnit is a module.
>
> Fix this by adding a dependency on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y),
> which only excludes this one problematic configuration.
>
> This was reported on a nasty openrisc-randconfig run by the kernel test
> robot, though for some reason (compiler optimisations removing the test
> code?) I wasn't able to reproduce it locally on x86:
> https://lore.kernel.org/linux-mm/[email protected]/T/
>
> Fixes: 291cd54e5b05 ("mmc: sdhci-of-aspeed: test: Use kunit_test_suite() macro")
> Reported-by: kernel test robot <[email protected]>
> Signed-off-by: David Gow <[email protected]>

I assume this should go together with the other recent kunit patches,
so please add:

Acked-by: Ulf Hansson <[email protected]>

Kind regards
Uffe

> ---
> drivers/mmc/host/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
> index 10c563999d3d..e63608834411 100644
> --- a/drivers/mmc/host/Kconfig
> +++ b/drivers/mmc/host/Kconfig
> @@ -171,6 +171,7 @@ config MMC_SDHCI_OF_ASPEED
> config MMC_SDHCI_OF_ASPEED_TEST
> bool "Tests for the ASPEED SDHCI driver" if !KUNIT_ALL_TESTS
> depends on MMC_SDHCI_OF_ASPEED && KUNIT
> + depends on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y)
> default KUNIT_ALL_TESTS
> help
> Enable KUnit tests for the ASPEED SDHCI driver. Select this
> --
> 2.37.0.170.g444d1eabd0-goog
>

2022-08-03 21:14:42

by Brendan Higgins

[permalink] [raw]
Subject: Re: [PATCH] mmc: sdhci-of-aspeed: test: Fix dependencies when KUNIT=m

On Fri, Jul 15, 2022 at 12:04 AM David Gow <[email protected]> wrote:
>
> While the sdhci-of-aspeed KUnit tests do work when builtin, and do work
> when KUnit itself is being built as a module, the two together break.
>
> This is because the KUnit tests (understandably) depend on KUnit, so a
> built-in test cannot build if KUnit is a module.
>
> Fix this by adding a dependency on (MMC_SDHCI_OF_ASPEED=m || KUNIT=y),
> which only excludes this one problematic configuration.
>
> This was reported on a nasty openrisc-randconfig run by the kernel test
> robot, though for some reason (compiler optimisations removing the test
> code?) I wasn't able to reproduce it locally on x86:
> https://lore.kernel.org/linux-mm/[email protected]/T/
>
> Fixes: 291cd54e5b05 ("mmc: sdhci-of-aspeed: test: Use kunit_test_suite() macro")
> Reported-by: kernel test robot <[email protected]>
> Signed-off-by: David Gow <[email protected]>

Acked-by: Brendan Higgins <[email protected]>