Skip to contentSkip to conversation

kunit: Export kunit_running()

PATCH In review Arnd Bergmann 3 participants 4 messages Jan 17, 2023 – Jan 20, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 lib/kunit/test.c | 1 +
 1 file changed, 1 insertion(+)
lib/kunit/test.c +1 -0
index c9ebf975e56b..890ba5b3a981 100644
@@ -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)
 /*
Signature · 1 line
2.39.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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

Quoted 7 lines

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")

---

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.

Cheers,
-- David

Quoted 18 lines
 lib/kunit/test.c | 1 +
 1 file changed, 1 insertion(+)
lib/kunit/test.c +1 -1
index c9ebf975e56b..890ba5b3a981 100644
@@ -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

#2 lore raw

Hi David, Arnd,

Thanks for fixing this issue

Quoted 17 lines · David Gow
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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

Quoted 7 lines

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")

---

Thanks for fixing this!

Quoted 7 lines

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.

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

Maxime

#3 lore raw
Quoted 27 lines · Maxime Ripard

Hi David, Arnd,

Thanks for fixing this issue

Quoted 21 lines · David Gow
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

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

Quoted 7 lines

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")

---

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]/

Quoted 6 lines
Quoted 3 lines

But this looks good to fix it in the meantime.

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