Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Sasha Levin <sashal@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
	Miroslav Benes <mbenes@suse.cz>,
	Joe Lawrence <joe.lawrence@redhat.com>,
	Song Liu <song@kernel.org>,
	Marcos Paulo de Souza <mpdesouza@suse.com>,
	Eva Kurchatova <eva.kurchatova@virtuozzo.com>,
	Yafang Shao <laoar.shao@gmail.com>, Shuah Khan <shuah@kernel.org>,
	live-patching@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/4] selftests/livepatch: clean the test modules without a kernel build directory
Date: Mon, 23 Nov 2026 11:23:11 +0100	[thread overview]
Message-ID: <awQUD16CDFpCTxaQ@pathway.suse.cz> (raw)
In-Reply-To: <20261110161050.2451750-3-sashal@kernel.org>

On Tue 2026-11-10 11:10:48, Sasha Levin wrote:
> "make clean" removes the test modules only when KDIR exists, and KDIR
> defaults to the build directory of the running kernel. Modules built
> for another kernel are therefore left in the source tree by a plain
> "make clean" on a machine without the running kernel's devel files,
> for example after building them as KernelCI does:
> 
>   make -C tools/testing/selftests O=<kernel> KDIR=<kernel> TARGETS=livepatch

The two parameters "O=<kernel> KDIR=<kernel>" do not make much sense
to me. The command starts compiling other selftests. I get:

$> make -C tools/testing/selftests  O=<kernel> KDIR=<kernel> TARGETS=livepatch
Makefile:4: *** Package alsa not found, please install alsa development package or add directory containing `alsa.pc` in PKG_CONFIG_PATH.  Stop.
test_execve.c:4:10: fatal error: cap-ng.h: No such file or directory
    4 | #include <cap-ng.h>
      |          ^~~~~~~~~~
compilation terminated.
make[1]: *** [../lib.mk:226: /prace/ai/kernel/linux-livepatching/tools/testing/selftests/capabilities/test_execve] Error 1
/usr/bin/ld.bfd: cannot find -lcap: No such file or directory
collect2: error: ld returned 1 exit status

It works well when I omit the two parameters:

$> make -C tools/testing/selftests TARGETS=livepatch
make: Entering directory '/prace/ai/kernel/linux-livepatching/tools/testing/selftests'
  CC       test_klp-call_getpid
env -u KBUILD_OUTPUT make -C /prace/ai/kernel/linux-livepatching modules KBUILD_EXTMOD=/prace/ai/kernel/linux-livepatching/tools/testing/selftests/livepatch/test_modules
  CC [M]  test_klp_atomic_replace.o
  CC [M]  test_klp_callbacks_busy.o

Are these parameters really used by the KernelCI?
Could you please provide link to a build log?

>   make -C tools/testing/selftests TARGETS=livepatch clean
> 
> Removing external modules does not need a configured kernel. Clean
> them through the kernel source tree that contains the selftests, and
> do not pass on O= or KBUILD_OUTPUT, which the kernel Makefile would
> take as its build directory.

> --- a/tools/testing/selftests/livepatch/test_modules/Makefile
> +++ b/tools/testing/selftests/livepatch/test_modules/Makefile
> @@ -32,8 +32,11 @@ ifdef BUILD_TEST_MODS
>  	$(Q)$(MAKE) -C $(KDIR) modules KBUILD_EXTMOD=$(TESTMODS_DIR)
>  endif
>  
> -# Ensure that KDIR exists, otherwise skip the clean target
> +# Cleaning external modules needs no configured kernel, so clean them
> +# through the kernel source tree that contains this directory. The kernel
> +# Makefile would take an O= or KBUILD_OUTPUT passed on from the selftests
> +# build as its build directory, so drop them.
> +clean: MAKEOVERRIDES := $(filter-out O=% KBUILD_OUTPUT=%,$(MAKEOVERRIDES))
>  clean:
> -ifneq ("$(wildcard $(KDIR))", "")
> -	$(Q)$(MAKE) -C $(KDIR) clean KBUILD_EXTMOD=$(TESTMODS_DIR)
> -endif
> +	$(Q)env -u KBUILD_OUTPUT $(MAKE) -C $(TESTMODS_DIR)/../../../../.. \
> +		clean KBUILD_EXTMOD=$(TESTMODS_DIR)

Otherwise, the change seems to do the job.
So, maybe just the sample command in the commit message is wrong.

Best Regards,
Petr

  reply	other threads:[~2026-11-23 10:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 16:10 [PATCH v4 0/4] selftests/livepatch: build and run the tests outside the running kernel Sasha Levin
2026-11-10 16:10 ` [PATCH v4 1/4] selftests/livepatch: skip the tests on kernels without livepatch Sasha Levin
2026-11-23 10:15   ` Petr Mladek
2026-11-10 16:10 ` [PATCH v4 2/4] selftests/livepatch: clean the test modules without a kernel build directory Sasha Levin
2026-11-23 10:23   ` Petr Mladek [this message]
2026-11-10 16:10 ` [PATCH v4 3/4] selftests/livepatch: build the test modules against the kernel in O= Sasha Levin
2026-11-10 16:10 ` [PATCH v4 4/4] selftests/livepatch: run the tests with prebuilt test modules Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awQUD16CDFpCTxaQ@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=eva.kurchatova@virtuozzo.com \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=laoar.shao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=mpdesouza@suse.com \
    --cc=sashal@kernel.org \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox