Skip to content

Commit

Permalink
path_link test: we no longer support symlink following
Browse files Browse the repository at this point in the history
just assert that setting the symlink following lookupflag gives an
ERRNO_INVAL.
  • Loading branch information
pchickey committed Jan 26, 2021
1 parent fded424 commit 17f43d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 43 deletions.
6 changes: 1 addition & 5 deletions crates/test-programs/TEST_FAILURES
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ TODOs:
fcntl on unix, reopenfile / require reopening on windows.



# Linux

* path_link
- need DirExt::hard_link that follows symlinks.
* path_rename_trailing_slashes
- trailing slash behavior of files is wrong: trailing slashes are ignored,
should cause an error.
Expand Down Expand Up @@ -40,8 +37,7 @@ TODOs:
- permission denied on windows to rename a dir to an existing empty dir

* path_link
- fails on the first dangling symlink, which is before the hard_link
following symlinks issue linux hits.
- fails on the first dangling symlink

## "Trailing slashes are a bonified boondoggle" - Dan

Expand Down
42 changes: 4 additions & 38 deletions crates/test-programs/wasi-tests/src/bin/path_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,43 +184,10 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) {
);
wasi::path_unlink_file(dir_fd, "symlink").expect("removing a symlink");

// Create a link to a file following symlinks
wasi::path_symlink("file", dir_fd, "symlink").expect("creating a valid symlink");
wasi::path_link(
dir_fd,
wasi::LOOKUPFLAGS_SYMLINK_FOLLOW,
"symlink",
dir_fd,
"link",
)
.expect("creating a link to a file following symlinks");
let link_fd = open_link(dir_fd, "link");
check_rights(file_fd, link_fd);
wasi::path_unlink_file(dir_fd, "link").expect("removing a link");
wasi::path_unlink_file(dir_fd, "symlink").expect("removing a symlink");

// Create a link where target is a dangling symlink following symlinks
wasi::path_symlink("target", dir_fd, "symlink").expect("creating a dangling symlink");

// If we do follow symlinks, this should fail
assert_eq!(
wasi::path_link(
dir_fd,
wasi::LOOKUPFLAGS_SYMLINK_FOLLOW,
"symlink",
dir_fd,
"link",
)
.expect_err("creating a link to a dangling symlink following symlinks should fail")
.raw_error(),
wasi::ERRNO_NOENT,
"errno should be ERRNO_NOENT"
);
wasi::path_unlink_file(dir_fd, "symlink").expect("removing a symlink");

// Create a link to a symlink loop following symlinks
wasi::path_symlink("symlink", dir_fd, "symlink").expect("creating a symlink loop");

// Symlink following with path_link is rejected
assert_eq!(
wasi::path_link(
dir_fd,
Expand All @@ -229,12 +196,11 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) {
dir_fd,
"link",
)
.expect_err("creating a link to a symlink loop following symlinks")
.expect_err("calling path_link with LOOKUPFLAGS_SYMLINK_FOLLOW should fail")
.raw_error(),
wasi::ERRNO_LOOP,
"errno should be ERRNO_LOOP"
wasi::ERRNO_INVAL,
"errno should be ERRNO_INVAL"
);
wasi::path_unlink_file(dir_fd, "symlink").expect("removing a symlink");

// Clean up.
wasi::path_unlink_file(dir_fd, "file").expect("removing a file");
Expand Down

0 comments on commit 17f43d4

Please sign in to comment.