[Devel] [PATCH RHEL10 COMMIT] selftests: do not hide a missing kernel build tree
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Aug 14 14:11:16 MSK 2026
The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.4.vz10
------>
commit c07a6860abc51ad6a6f2ac2f2b64d444be88de54
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date: Thu Aug 13 19:20:09 2026 +0200
selftests: do not hide a missing kernel build tree
The livepatch and cgroup test module Makefiles wrap their recipes into a
KDIR existence test:
# Ensure that KDIR exists, otherwise skip the compilation
modules:
ifneq ("$(wildcard $(KDIR))", "")
$(Q)$(MAKE) -C $(KDIR) modules KBUILD_EXTMOD=$(TESTMODS_DIR)
endif
so the test modules are silently not built when KDIR is not there: the
target simply loses its recipe and make reports success. The test comes
from commit 54ee3526796f ("selftests: livepatch: Avoid running the tests
if kernel-devel is missing"), which was a reaction to a kernel test robot
build failure report, and the cgroup Makefile copied the pattern later.
bpf/test_kmods and mm/page_frag never had such a test and simply fail, so
the tree is not consistent about it either.
A silent skip is the worst possible outcome for a packaged testsuite: the
test modules are missing from the rpm, the build log says nothing about
it, and the failure only surfaces on a test node as a test which cannot
find its module, far away from the cause.
Nothing is lost by dropping it, because the selftests framework already
implements the "do not fail everything because of one target" policy and
kernel packaging passes FORCE_TARGETS=1 exactly because it wants to know
whether every test module has been built:
all:
@ret=1; \
for TARGET in $(TARGETS); do \
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET \
O=$(abs_objtree) \
$(if $(FORCE_TARGETS),|| exit); \
ret=$$((ret * $$?)); \
done; exit $$ret;
So drop the tests and let make -C fail and say why. This also puts the
two Makefiles back in line with bpf/test_kmods and mm/page_frag.
https://virtuozzo.atlassian.net/browse/VSTOR-139647
Feature: fix selftests
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
tools/testing/selftests/cgroup/test_modules/Makefile | 6 ------
tools/testing/selftests/livepatch/test_modules/Makefile | 6 ------
2 files changed, 12 deletions(-)
diff --git a/tools/testing/selftests/cgroup/test_modules/Makefile b/tools/testing/selftests/cgroup/test_modules/Makefile
index 3f39eeda3a92b..38121d783d921 100644
--- a/tools/testing/selftests/cgroup/test_modules/Makefile
+++ b/tools/testing/selftests/cgroup/test_modules/Makefile
@@ -4,14 +4,8 @@ KDIR ?= /lib/modules/$(shell uname -r)/build
obj-m += cg_freezer_hang.o \
cg_freezer_kthread.o
-# Ensure that KDIR exists, otherwise skip the compilation
modules:
-ifneq ("$(wildcard $(KDIR))", "")
$(Q)$(MAKE) -C $(KDIR) modules KBUILD_EXTMOD=$(TESTMODS_DIR)
-endif
-# Ensure that KDIR exists, otherwise skip the clean target
clean:
-ifneq ("$(wildcard $(KDIR))", "")
$(Q)$(MAKE) -C $(KDIR) clean KBUILD_EXTMOD=$(TESTMODS_DIR)
-endif
diff --git a/tools/testing/selftests/livepatch/test_modules/Makefile b/tools/testing/selftests/livepatch/test_modules/Makefile
index 939230e571f5d..34e2f76fb4cec 100644
--- a/tools/testing/selftests/livepatch/test_modules/Makefile
+++ b/tools/testing/selftests/livepatch/test_modules/Makefile
@@ -14,14 +14,8 @@ obj-m += test_klp_atomic_replace.o \
test_klp_state3.o \
test_klp_syscall.o
-# Ensure that KDIR exists, otherwise skip the compilation
modules:
-ifneq ("$(wildcard $(KDIR))", "")
$(Q)$(MAKE) -C $(KDIR) modules KBUILD_EXTMOD=$(TESTMODS_DIR)
-endif
-# Ensure that KDIR exists, otherwise skip the clean target
clean:
-ifneq ("$(wildcard $(KDIR))", "")
$(Q)$(MAKE) -C $(KDIR) clean KBUILD_EXTMOD=$(TESTMODS_DIR)
-endif
More information about the Devel
mailing list