Skip to content

Commit ba300a7

Browse files
committed
KVM: selftests: Play nice with EACCES errors in open_path_or_exit()
Expand the SKIP conditions of the open_path_or_exit() helper to skip on EACCES as well as ENOENT. Most often, lack of permissions to a file needed by a KVM selftests is due to a file being root-only by default, not because of any bug/misconfiguration that warrants failing a test. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 6e1cce7 commit ba300a7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ int __open_path_or_exit(const char *path, int flags, const char *enoent_help)
3737
return fd;
3838

3939
error:
40-
if (errno == ENOENT)
40+
if (errno == EACCES || errno == ENOENT)
4141
ksft_exit_skip("- Cannot open '%s': %s. %s\n",
42-
path, strerror(errno), enoent_help);
42+
path, strerror(errno),
43+
errno == EACCES ? "Root required?" : enoent_help);
4344
TEST_FAIL("Failed to open '%s'", path);
4445
}
4546

0 commit comments

Comments
 (0)