Re: [PATCH v4 3/4] selftests/livepatch: build the test modules against the kernel in O=
From: Petr Mladek
Date: Mon Nov 23 2026 - 09:10:01 EST
On Tue 2026-11-10 11:10:49, Sasha Levin wrote:
> Documentation/dev-tools/kselftest.rst describes building the selftests
> for a kernel built in a separate output directory:
>
> make O=/tmp/kselftest TARGETS=livepatch kselftest
>
> The livepatch test modules are not built against the kernel in
> /tmp/kselftest, but against the running kernel, using its devel files
> in /lib/modules/$(uname -r)/build. When those are not installed, the
> modules are silently left out. Only an explicit KDIR=/tmp/kselftest
> builds them for the kernel in /tmp/kselftest.
>
> When KDIR is not set, use the output directory given with O= or
> KBUILD_OUTPUT if a kernel was built there, then the kernel source tree
> if the kernel was built in it, and only then the running kernel.
>
> The selftests also pass their O= on to the module build, and the kernel
> Makefile takes it as the kernel build directory instead of KDIR. The
> top-level selftests Makefile passes O= even when it is empty, so on a
> Debian machine with the devel files of the running kernel installed,
>
> make -C tools/testing/selftests TARGETS=livepatch
>
> uses the source part of the devel files as the build directory and
> fails:
>
> /usr/src/linux-headers-6.19.13+deb14-common/Makefile:798: /usr/src/linux-headers-6.19.13+deb14-common/include/config/auto.conf: No such file or directory
>
> Do not pass O= and KBUILD_OUTPUT on to the module build, since KDIR
> already names the kernel build directory.
>
> Fixes: c4bbe83d27c2 ("livepatch: Move tests from lib/livepatch to selftests/livepatch")
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
The patch looks and seems to work reasonably well.
Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
Tested-by: Petr Mladek <pmladek@xxxxxxxx>
Best Regards,
Petr