Skip to contentSkip to conversation

runtime: Skip tests if the target "kernel" file doesn't exist

PATCH Applied Sean Christopherson 2 participants 5 messages May 29, 2025 – Jun 10, 2025 KVM

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

PATCH 1/1 runtime: Skip tests if the target "kernel" file doesn't exist

Skip the test if its target kernel/test file isn't available so that skipping a test that isn't supported for a given config doesn't require manually flagging the testcase in unittests.cfg. This fixes "failures" on x86 with CONFIG_EFI=y due to some tests not being built for EFI, but not being annotated in x86/unittests.cfg.

Alternatively, testcases could be marked noefi (or efi-only), but that'd require more manual effort, and there's no obvious advantage to doing so.

---
 scripts/runtime.bash | 5 +++++
 1 file changed, 5 insertions(+)
scripts/runtime.bash +5 -0
index ee229631..a94d940d 100644
@@ -150,6 +150,11 @@ function run()
         done
     fi
 
+    if [ ! -f "$kernel" ]; then
+        print_result "SKIP" $testname "" "Test file '$kernel' not found";
+        return 2;
+    fi
+
     log=$(premature_failure) && {
         skip=true
         if [ "${CONFIG_EFI}" == "y" ]; then

base-commit: 72d110d8286baf1b355301cc8c8bdb42be2663fb

Signature · 1 line
2.49.0.1204.g71687c7c1d-goog
#1 lore raw
Quoted 19 lines · Sean Christopherson

Skip the test if its target kernel/test file isn't available so that skipping a test that isn't supported for a given config doesn't require manually flagging the testcase in unittests.cfg. This fixes "failures" on x86 with CONFIG_EFI=y due to some tests not being built for EFI, but not being annotated in x86/unittests.cfg.

Alternatively, testcases could be marked noefi (or efi-only), but that'd require more manual effort, and there's no obvious advantage to doing so.

---
 scripts/runtime.bash | 5 +++++
 1 file changed, 5 insertions(+)
scripts/runtime.bash +0 -0
index ee229631..a94d940d 100644

scripts/runtime.bash function run() · line 157

Quoted 8 lines
scripts/runtime.bash +5 -0
@@ -150,6 +150,11 @@ function run()
         done
     fi
 
+    if [ ! -f "$kernel" ]; then
+        print_result "SKIP" $testname "" "Test file '$kernel' not found";
+        return 2;
+    fi
+

I see mkstandalone.sh already has something like this. There's still one other place, though, which is print_testname(). Should we filter tests from the listing that are missing their kernels?

Thanks,
drew

Quoted 8 lines
scripts/runtime.bash +0 -0
     log=$(premature_failure) && {
         skip=true
         if [ "${CONFIG_EFI}" == "y" ]; then

base-commit: 72d110d8286baf1b355301cc8c8bdb42be2663fb

Signature · 1 line
2.49.0.1204.g71687c7c1d-goog
author reviewer
#2 lore raw
Quoted 23 lines · Andrew Jones
Quoted 22 lines · Sean Christopherson

Skip the test if its target kernel/test file isn't available so that skipping a test that isn't supported for a given config doesn't require manually flagging the testcase in unittests.cfg. This fixes "failures" on x86 with CONFIG_EFI=y due to some tests not being built for EFI, but not being annotated in x86/unittests.cfg.

Alternatively, testcases could be marked noefi (or efi-only), but that'd require more manual effort, and there's no obvious advantage to doing so.

---
 scripts/runtime.bash | 5 +++++
 1 file changed, 5 insertions(+)
scripts/runtime.bash +0 -0
index ee229631..a94d940d 100644
@@ -150,6 +150,11 @@ function run()
         done
     fi
 
Quoted 9 lines

scripts/runtime.bash function run() · line 157

Quoted 5 lines
scripts/runtime.bash +5 -0
+    if [ ! -f "$kernel" ]; then
+        print_result "SKIP" $testname "" "Test file '$kernel' not found";
+        return 2;
+    fi
+

I see mkstandalone.sh already has something like this. There's still one other place, though, which is print_testname(). Should we filter tests from the listing that are missing their kernels?

Huh, TIL you can list testcases :-)

I would say no? Because then listing testcases would depend on a successful build, which would be annoying in a variety of scenarios.

It would also be weird to list testcases that are excluded based on e.g. arch, but not list testcases that are effectively excluded via Makefile.

Reviewed-by
#3 lore raw
Quoted 34 lines · Sean Christopherson
Quoted 23 lines · Andrew Jones
Quoted 22 lines · Sean Christopherson

Skip the test if its target kernel/test file isn't available so that skipping a test that isn't supported for a given config doesn't require manually flagging the testcase in unittests.cfg. This fixes "failures" on x86 with CONFIG_EFI=y due to some tests not being built for EFI, but not being annotated in x86/unittests.cfg.

Alternatively, testcases could be marked noefi (or efi-only), but that'd require more manual effort, and there's no obvious advantage to doing so.

---
 scripts/runtime.bash | 5 +++++
 1 file changed, 5 insertions(+)
scripts/runtime.bash +0 -0
index ee229631..a94d940d 100644
@@ -150,6 +150,11 @@ function run()
         done
     fi
 
Quoted 9 lines

scripts/runtime.bash function run() · line 157

Quoted 5 lines
scripts/runtime.bash +5 -0
+    if [ ! -f "$kernel" ]; then
+        print_result "SKIP" $testname "" "Test file '$kernel' not found";
+        return 2;
+    fi
+

I see mkstandalone.sh already has something like this. There's still one other place, though, which is print_testname(). Should we filter tests from the listing that are missing their kernels?

Quoted 7 lines

Huh, TIL you can list testcases :-)

I would say no? Because then listing testcases would depend on a successful build, which would be annoying in a variety of scenarios.

It would also be weird to list testcases that are excluded based on e.g. arch, but not list testcases that are effectively excluded via Makefile.

Sounds reasonable.

Thanks,
drew

author reviewer Applied
#4 lore raw
In reply to Sean Christopherson
Quoted 10 lines · Sean Christopherson

Skip the test if its target kernel/test file isn't available so that skipping a test that isn't supported for a given config doesn't require manually flagging the testcase in unittests.cfg. This fixes "failures" on x86 with CONFIG_EFI=y due to some tests not being built for EFI, but not being annotated in x86/unittests.cfg.

Alternatively, testcases could be marked noefi (or efi-only), but that'd require more manual effort, and there's no obvious advantage to doing so.

[...]

Applied to kvm-x86 next, thanks!

[1/1] runtime: Skip tests if the target "kernel" file doesn't exist

      https://github.com/kvm-x86/kvm-unit-tests/commit/7f528c1b474c

--
https://github.com/kvm-x86/kvm-unit-tests/tree/next