2023-01-17 17:49:22

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH] kunit: Export kunit_running()

From: Arnd Bergmann <[email protected]>

Using kunit_fail_current_test() in a loadable module causes a link
error like:

ERROR: modpost: "kunit_running" [drivers/gpu/drm/vc4/vc4.ko] undefined!

Export the symbol to allow using it from modules.

Fixes: da43ff045c3f ("drm/vc4: tests: Fail the current test if we access a register")
Signed-off-by: Arnd Bergmann <[email protected]>
---
lib/kunit/test.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index c9ebf975e56b..890ba5b3a981 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -21,6 +21,7 @@
#include "try-catch-impl.h"

DEFINE_STATIC_KEY_FALSE(kunit_running);
+EXPORT_SYMBOL_GPL(kunit_running);

#if IS_BUILTIN(CONFIG_KUNIT)
/*
--
2.39.0


2023-01-18 00:56:01

by David Gow

[permalink] [raw]
Subject: Re: [PATCH] kunit: Export kunit_running()

On Wed, 18 Jan 2023 at 00:50, Arnd Bergmann <[email protected]> wrote:
>
> From: Arnd Bergmann <[email protected]>
>
> Using kunit_fail_current_test() in a loadable module causes a link
> error like:
>
> ERROR: modpost: "kunit_running" [drivers/gpu/drm/vc4/vc4.ko] undefined!
>
> Export the symbol to allow using it from modules.
>
> Fixes: da43ff045c3f ("drm/vc4: tests: Fail the current test if we access a register")
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---

Thanks for fixing this!

I think the longer-term solution for this is the "hooks" approach
(which works even when KUnit itself is built as a module):
https://lore.kernel.org/all/[email protected]/

But this looks good to fix it in the meantime.

Reviewed-by: David Gow <[email protected]>

Cheers,
-- David

> lib/kunit/test.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/lib/kunit/test.c b/lib/kunit/test.c
> index c9ebf975e56b..890ba5b3a981 100644
> --- a/lib/kunit/test.c
> +++ b/lib/kunit/test.c
> @@ -21,6 +21,7 @@
> #include "try-catch-impl.h"
>
> DEFINE_STATIC_KEY_FALSE(kunit_running);
> +EXPORT_SYMBOL_GPL(kunit_running);
>
> #if IS_BUILTIN(CONFIG_KUNIT)
> /*
> --
> 2.39.0
>


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

2023-01-18 12:20:21

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH] kunit: Export kunit_running()

Hi David, Arnd,

Thanks for fixing this issue

On Wed, Jan 18, 2023 at 08:37:26AM +0800, David Gow wrote:
> On Wed, 18 Jan 2023 at 00:50, Arnd Bergmann <[email protected]> wrote:
> >
> > From: Arnd Bergmann <[email protected]>
> >
> > Using kunit_fail_current_test() in a loadable module causes a link
> > error like:
> >
> > ERROR: modpost: "kunit_running" [drivers/gpu/drm/vc4/vc4.ko] undefined!
> >
> > Export the symbol to allow using it from modules.
> >
> > Fixes: da43ff045c3f ("drm/vc4: tests: Fail the current test if we access a register")
> > Signed-off-by: Arnd Bergmann <[email protected]>
> > ---
>
> Thanks for fixing this!
>
> I think the longer-term solution for this is the "hooks" approach
> (which works even when KUnit itself is built as a module):
> https://lore.kernel.org/all/[email protected]/
>
> But this looks good to fix it in the meantime.
>
> Reviewed-by: David Gow <[email protected]>

How do you want to merge that patch? Will you take it through your tree?

Maxime

2023-01-20 07:00:21

by David Gow

[permalink] [raw]
Subject: Re: [PATCH] kunit: Export kunit_running()

On Wed, 18 Jan 2023 at 19:02, Maxime Ripard <[email protected]> wrote:
>
> Hi David, Arnd,
>
> Thanks for fixing this issue
>
> On Wed, Jan 18, 2023 at 08:37:26AM +0800, David Gow wrote:
> > On Wed, 18 Jan 2023 at 00:50, Arnd Bergmann <[email protected]> wrote:
> > >
> > > From: Arnd Bergmann <[email protected]>
> > >
> > > Using kunit_fail_current_test() in a loadable module causes a link
> > > error like:
> > >
> > > ERROR: modpost: "kunit_running" [drivers/gpu/drm/vc4/vc4.ko] undefined!
> > >
> > > Export the symbol to allow using it from modules.
> > >
> > > Fixes: da43ff045c3f ("drm/vc4: tests: Fail the current test if we access a register")
> > > Signed-off-by: Arnd Bergmann <[email protected]>
> > > ---
> >
> > Thanks for fixing this!
> >
> > I think the longer-term solution for this is the "hooks" approach
> > (which works even when KUnit itself is built as a module):
> > https://lore.kernel.org/all/[email protected]/
> >
> > But this looks good to fix it in the meantime.
> >
> > Reviewed-by: David Gow <[email protected]>
>
> How do you want to merge that patch? Will you take it through your tree?
>

We'll take this via the kunit/kselftest tree, thanks!

Cheers,
-- David


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