Skip to contentSkip to conversation

How to run a single test on kselftest

PATCH Yunhong Jiang 1 participant 1 message Aug 14, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,
Can anyone give some hints on how to run a single test on the kselftest
framework? The reason that I want such support is because I have to run test cases inside emulator, which is very slow.

Per the kselftest documents, I can run kvm selftests with "make
-C tools/testing/selftests TARGETS=kvm run_tests", but it does not provide a mechanism to run a single test in KVM subsystem. It takes a very long time to finish the KVM subset testing inside the slow emulator while I'm only trying to replace/add one testcase.

Currently I modify the code like below, to run only a single test. Not
sure if there is a more generic way to do that. If no such mechanism and there are more people have similar need, is it possible to add it? I'm more than happy to contribute with guide.

Thank you
--jyh

tools/testing/selftests/kvm/Makefile +4 -2
index c692cc86e7da..25fce1a3ceb8 100644
@@ -56,7 +56,7 @@ LIBKVM_riscv += lib/riscv/processor.c
 LIBKVM_riscv += lib/riscv/ucall.c
 
 # Non-compiled test targets
-TEST_PROGS_x86_64 += x86_64/nx_huge_pages_test.sh
+#TEST_PROGS_x86_64 += x86_64/nx_huge_pages_test.sh
 
 # Compiled test targets
 TEST_GEN_PROGS_x86_64 = x86_64/cpuid_test
@@ -135,7 +135,7 @@ TEST_GEN_PROGS_x86_64 += kvm_binary_stats_test
 TEST_GEN_PROGS_x86_64 += system_counter_offset_test
 
 # Compiled outputs used by test targets
-TEST_GEN_PROGS_EXTENDED_x86_64 += x86_64/nx_huge_pages_test
+#TEST_GEN_PROGS_EXTENDED_x86_64 += x86_64/nx_huge_pages_test
 
 TEST_GEN_PROGS_aarch64 += aarch64/aarch32_id_regs
 TEST_GEN_PROGS_aarch64 += aarch64/arch_timer
@@ -186,6 +186,8 @@ TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(ARCH_DIR))
 TEST_GEN_PROGS_EXTENDED += $(TEST_GEN_PROGS_EXTENDED_$(ARCH_DIR))
 LIBKVM += $(LIBKVM_$(ARCH_DIR))
 
+TEST_GEN_PROGS = x86_64/cr4_cpuid_sync_test
+
 OVERRIDE_TARGETS = 1
 
 # lib.mak defines $(OUTPUT), prepends $(OUTPUT)/ to $(TEST_GEN_PROGS), and most