@@ -7,6 +7,7 @@
!*.S
!*.sh
!*.test
+default.test
!.gitignore
!config
!settings
@@ -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
@@ -330,11 +330,15 @@ $(SPLIT_TEST_GEN_PROGS): $(OUTPUT)/%: $(OUTPUT)/%.o $(OUTPUT)/$(ARCH)/%.o
$(SPLIT_TEST_GEN_OBJ): $(OUTPUT)/$(ARCH)/%.o: $(ARCH)/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
+# Default testcases for KVM selftests runner will be generated in this directory.
+DEFAULT_TESTCASES = testcases_default_gen
+
EXTRA_CLEAN += $(GEN_HDRS) \
$(LIBKVM_OBJS) \
$(SPLIT_TEST_GEN_OBJ) \
$(TEST_DEP_FILES) \
$(TEST_GEN_OBJ) \
+ $(OUTPUT)/$(DEFAULT_TESTCASES) \
cscope.*
$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c $(GEN_HDRS)
@@ -363,3 +367,23 @@ cscope:
find . -name '*.c' \
-exec realpath --relative-base=$(PWD) {} \;) | sort -u > cscope.files
cscope -b
+
+# Generate runner testcases in DEFAULT_TESTCASES directory.
+# $(OUTPUT) is either CWD or specified in the make command.
+tests_install: list_progs = $(patsubst $(OUTPUT)/%,%,$(TEST_GEN_PROGS))
+tests_install:
+ $(foreach tc, $(TEST_PROGS), \
+ $(shell mkdir -p $(OUTPUT)/$(DEFAULT_TESTCASES)/$(patsubst %.sh,%,$(tc))))
+ $(foreach tc, $(TEST_PROGS), \
+ $(shell echo $(tc) > $(patsubst %.sh,$(OUTPUT)/$(DEFAULT_TESTCASES)/%/default.test,$(tc))))
+
+ $(foreach tc, $(list_progs), \
+ $(shell mkdir -p $(OUTPUT)/$(DEFAULT_TESTCASES)/$(tc)))
+ $(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
+
+ @:
Add 'tests_install' rule in the Makefile.kvm to auto generate default testcases for KVM selftests runner. Preserve the hierarchy of test executables for autogenerated files. Remove these testcases on invocation of 'make clean'. Autogeneration of default test files allows runner to execute default testcases easily. These default testcases don't need to be checked in as they are just executing the test without any command line options. Signed-off-by: Vipin Sharma <vipinsh@google.com> --- tools/testing/selftests/kvm/.gitignore | 1 + tools/testing/selftests/kvm/Makefile.kvm | 26 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)