Skip to content

Commit c2a449a

Browse files
vittyvksean-jc
authored andcommitted
KVM: selftests: Fail tests when open() fails with !ENOENT
open_path_or_exit() is used for '/dev/kvm', '/dev/sev', and '/sys/module/%s/parameters/%s' and skipping test when the entry is missing is completely reasonable. Other errors, however, may indicate a real issue which is easy to miss. E.g. when 'hyperv_features' test was entering an infinite loop the output was: ./hyperv_features Testing access to Hyper-V specific MSRs 1..0 # SKIP - /dev/kvm not available (errno: 24) and this can easily get overlooked. Keep ENOENT case 'special' for skipping tests and fail when open() results in any other errno. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Link: https://lore.kernel.org/r/20240129085847.2674082-2-vkuznets@redhat.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 8ad4855 commit c2a449a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/testing/selftests/kvm/lib/kvm_util.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ int open_path_or_exit(const char *path, int flags)
2727
int fd;
2828

2929
fd = open(path, flags);
30-
__TEST_REQUIRE(fd >= 0, "%s not available (errno: %d)", path, errno);
30+
__TEST_REQUIRE(fd >= 0 || errno != ENOENT, "Cannot open %s: %s", path, strerror(errno));
31+
TEST_ASSERT(fd >= 0, "Failed to open '%s'", path);
3132

3233
return fd;
3334
}

0 commit comments

Comments
 (0)