symlink-related tests: accept either ELOOP or ENOTDIR

when opening a symlink loop as directory, or nofollow opening a valid
symlink as directory.
This commit is contained in:
Pat Hickey
2021-01-11 15:16:18 -08:00
parent 2d2e6d16a1
commit 09861c20db
3 changed files with 23 additions and 20 deletions

View File

@@ -11,12 +11,12 @@ unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) {
wasi::path_symlink("target", dir_fd, "symlink").expect("creating a symlink");
// Try to open it as a directory with O_NOFOLLOW again.
assert_eq!(
wasi::path_open(dir_fd, 0, "symlink", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
.expect_err("opening a directory symlink as a directory should fail")
.raw_error(),
wasi::ERRNO_LOOP,
"errno should be ERRNO_LOOP",
let dir_open_errno = wasi::path_open(dir_fd, 0, "symlink", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
.expect_err("opening a directory symlink as a directory should fail")
.raw_error();
assert!(
dir_open_errno == wasi::ERRNO_LOOP || dir_open_errno == wasi::ERRNO_NOTDIR,
"errno should be ERRNO_LOOP or ERRNO_NOTDIR",
);
// Try to open it with just O_NOFOLLOW.
@@ -57,12 +57,12 @@ unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) {
wasi::path_symlink("target", dir_fd, "symlink").expect("creating a symlink");
// Try to open it as a directory with O_NOFOLLOW again.
assert_eq!(
wasi::path_open(dir_fd, 0, "symlink", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
.expect_err("opening a directory symlink as a directory should fail")
.raw_error(),
wasi::ERRNO_LOOP,
"errno should be ERRNO_LOOP",
let dir_open_errno = wasi::path_open(dir_fd, 0, "symlink", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
.expect_err("opening a directory symlink as a directory should fail")
.raw_error();
assert!(
dir_open_errno == wasi::ERRNO_LOOP || dir_open_errno == wasi::ERRNO_NOTDIR,
"errno should be ERRNO_LOOP or ERRNO_NOTDIR",
);
// Try to open it with just O_NOFOLLOW.