* [PATCH] selftests: livepatch: do not require a kernel build tree to run
@ 2026-09-06 20:49 Eva Kurchatova
2026-09-17 14:58 ` Petr Mladek
0 siblings, 1 reply; 2+ messages in thread
From: Eva Kurchatova @ 2026-09-06 20:49 UTC (permalink / raw)
To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Shuah Khan, Marcos Paulo de Souza
Cc: linux-kernel, Eva Kurchatova, Shuah Khan, live-patching,
linux-kselftest
setup_config() calls has_kdir(), which skips every livepatch test when
/lib/modules/$(uname -r)/build is missing. The tests do not compile
anything though, they insmod the pre-built modules from test_modules/,
so the check tests a proxy rather than the thing it cares about.
That proxy holds only for a source tree or a machine with kernel-devel
installed. A packaged testsuite ships the modules pre-built and runs on
machines with no kernel build tree at all, and there every single test
reports "ok ... # SKIP". A harness that looks for "not ok" then reports
the suite as passed, so the whole suite silently tests nothing.
Test for the modules instead. Missing modules still skip rather than
fail, which is what the KDIR check was there for, and the tests now run
wherever the modules are.
Fixes: 54ee3526796f ("selftests: livepatch: Avoid running the tests if kernel-devel is missing")
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
tools/testing/selftests/livepatch/functions.sh | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index a65b7b1ac8ad..492955ca2fa0 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -44,14 +44,12 @@ function is_root() {
fi
}
-# Check if we can compile the modules before loading them
-function has_kdir() {
- if [ -z "$KDIR" ]; then
- KDIR="/lib/modules/$(uname -r)/build"
- fi
+# Check that the test modules are there before loading them
+function has_test_modules() {
+ local mods=(test_modules/*.ko)
- if [ ! -d "$KDIR" ]; then
- echo "skip all tests: KDIR ($KDIR) not available to compile modules."
+ if [ ! -e "${mods[0]}" ]; then
+ echo "skip all tests: test modules are not built, run make first" >&2
exit $ksft_skip
fi
}
@@ -150,7 +148,7 @@ function cleanup() {
# the ftrace_enabled sysctl.
function setup_config() {
is_root
- has_kdir
+ has_test_modules
push_config
set_dynamic_debug
set_ftrace_enabled 1
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] selftests: livepatch: do not require a kernel build tree to run
2026-09-06 20:49 [PATCH] selftests: livepatch: do not require a kernel build tree to run Eva Kurchatova
@ 2026-09-17 14:58 ` Petr Mladek
0 siblings, 0 replies; 2+ messages in thread
From: Petr Mladek @ 2026-09-17 14:58 UTC (permalink / raw)
To: Eva Kurchatova
Cc: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Joe Lawrence,
Shuah Khan, Marcos Paulo de Souza, linux-kernel, Shuah Khan,
live-patching, linux-kselftest
On Sun 2026-09-06 23:49:28, Eva Kurchatova wrote:
> setup_config() calls has_kdir(), which skips every livepatch test when
> /lib/modules/$(uname -r)/build is missing.
Yes.
> The tests do not compile
> anything though,
How do you run the tests please? I personally do
$> cd <kernel_source>/tools/tests/selftests/livepatch
$> make run_test
And it does compile the test modules when they are not available
or when they are older than the timestamps of the related source
files.
I tried
make TARGETS="livepatch" kselftest
and it does the same.
> they insmod the pre-built modules from test_modules/,
> so the check tests a proxy rather than the thing it cares about.
What do you mean by proxy, please?
What is the thing that is cares about, please?
> That proxy holds only for a source tree or a machine with kernel-devel
> installed. A packaged testsuite ships the modules pre-built and runs on
> machines with no kernel build tree at all, and there every single test
> reports "ok ... # SKIP". A harness that looks for "not ok" then reports
> the suite as passed, so the whole suite silently tests nothing.
Could you please paste the real output here?
I agree that the string "ok ... # SKIP" is weird. It should
either be "ok" or "skipped". But I do not see any related
change in this patch. It keeps:
exit $ksft_skip
So, the behavior on failure is likely the same. It would be nice
to fix it but I guess that this is a generic problem in
the selftests framework.
> Test for the modules instead. Missing modules still skip rather than
> fail, which is what the KDIR check was there for, and the tests now run
> wherever the modules are.
This sounds strange as well. I guess that it is a problem with
translation. I am not a native speaker but the following would
make more sense to me:
<proposal>
Test for the modules instead. The tests will still be skipped when
the modules are missing. But the tests will run when pre-built
modules are there.
</proposal>
> --- a/tools/testing/selftests/livepatch/functions.sh
> +++ b/tools/testing/selftests/livepatch/functions.sh
> @@ -44,14 +44,12 @@ function is_root() {
> fi
> }
>
> -# Check if we can compile the modules before loading them
> -function has_kdir() {
> - if [ -z "$KDIR" ]; then
> - KDIR="/lib/modules/$(uname -r)/build"
> - fi
> +# Check that the test modules are there before loading them
> +function has_test_modules() {
> + local mods=(test_modules/*.ko)
>
> - if [ ! -d "$KDIR" ]; then
> - echo "skip all tests: KDIR ($KDIR) not available to compile modules."
> + if [ ! -e "${mods[0]}" ]; then
> + echo "skip all tests: test modules are not built, run make first" >&2
IMHO, "make" won't help when "$KDIR" is missing. I would prefer to keep
the KDIR test as well. I mean something like:
if [ ! -e "${mods[0]}" ] && [ ! -d "$KDIR" ]; then
echo "skip all tests: KDIR ($KDIR) not available to compile modules."
> exit $ksft_skip
> fi
> }
Best Regards,
Petr
PS: I am sorry for the late reply. We are overloaded. AI helps people
to write patches. But it is not good enough to help with review.
Sashiko AI was happy with this patch, see
https://sashiko.dev/#/patchset/20260906204932.2343013-1-eva.kurchatova%40virtuozzo.com
But I see it differently.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-17 14:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-06 20:49 [PATCH] selftests: livepatch: do not require a kernel build tree to run Eva Kurchatova
2026-09-17 14:58 ` Petr Mladek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox