[PATCH v3 9/9] KVM: selftests: Provide README.rst for KVM selftests runner

Vipin Sharma vipinsh at google.com
Thu Oct 2 23:39:31 PDT 2025


On 2025-10-02 15:41:26, Marc Zyngier wrote:
> On Wed, 01 Oct 2025 18:32:25 +0100,
> Vipin Sharma <vipinsh at google.com> wrote:
> > 
> > On 2025-10-01 09:44:22, Marc Zyngier wrote:
> > 
> > > > +in `default.test` files. Each KVM selftest will have a directory in  which
> > > > +`default.test` file will be created with executable path relative to KVM
> > > > +selftest root directory i.e. `/tools/testing/selftests/kvm`.
> > > 
> > > Shouldn't this honor the existing build output directives? If it
> > > actually does, then you want to call this out.
> > > 
> > 
> > To generate default test files in a specific directory one can use
> > "OUTPUT" in the make command
> 
> The standard way to do this is documented in the top level Makefile:
> 
> <quote>
> # This does not need to match to the root of the kernel source tree.
> #
> # For example, you can do this:
> #
> #  cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
> #
> # If you want to save output files in a different location, there are
> # two syntaxes to specify it.
> #
> # 1) O=
> # Use "make O=dir/to/store/output/files/"
> #
> # 2) Set KBUILD_OUTPUT
> # Set the environment variable KBUILD_OUTPUT to point to the output directory.
> # export KBUILD_OUTPUT=dir/to/store/output/files/; make
> #
> # The O= assignment takes precedence over the KBUILD_OUTPUT environment
> # variable.
> </quote>
> 
> Your new infrastructure should support the existing mechanism (and
> avoid introducing a new one).
> 

Options "O" and "KBUILD_OUTPUT" are not supported by KVM makefile. I
tried running below commands in KVM selftest directory

  make O=~/some/dir
  make KBUILD_OUTPUT=~/some/dir

Both of the command generate output in the KVM selftest directory. So,
my new Makefile rule "tests_install" is behaving as per the current KVM
behavior.

However, building through kselftest Makefile do support "O" and
"KBUILD_OUTPUT". For example, if we are in kernel root directory,

  make O=~/some/dir -C tools/testing/selftests TARGETS=kvm

now output binaries will be generated in ~/some/dir. To make testcases
also be generated in the output directory below change is needed. 

diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
index 6bb63f88c0e6..a2b5c064d3a3 100644
--- a/tools/testing/selftests/kvm/Makefile.kvm
+++ b/tools/testing/selftests/kvm/Makefile.kvm
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 include ../../../build/Build.include
 
-all:
+all: tests_install
 
 LIBKVM += lib/assert.c
 LIBKVM += lib/elf.c
@@ -358,4 +358,7 @@ tests_install:
        $(foreach tc, $(list_progs), \
                $(shell echo $(tc) > $(patsubst %,$(OUTPUT)/$(DEFAULT_TESTCASES)/%/default.test,$(tc))))
 
+       @if [ ! -d $(OUTPUT)/runner ]; then             \
+               cp -r $(selfdir)/kvm/runner $(OUTPUT);  \
+       fi
        @:

Since testcases by themselves will not be useful, I have updated the
rule in the above diff to copy runner code as well to the output directory.

I think this brings my changes to honor existing build output
directives. Let me know if this needs some fixes.



More information about the kvm-riscv mailing list