From 17f43d4cc347a54e34e7a0e65a34e5faef92919e Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Mon, 25 Jan 2021 17:13:33 -0800 Subject: [PATCH] path_link test: we no longer support symlink following just assert that setting the symlink following lookupflag gives an ERRNO_INVAL. --- crates/test-programs/TEST_FAILURES | 6 +-- .../wasi-tests/src/bin/path_link.rs | 42 ++----------------- 2 files changed, 5 insertions(+), 43 deletions(-) diff --git a/crates/test-programs/TEST_FAILURES b/crates/test-programs/TEST_FAILURES index 05697503c5..eec2301a84 100644 --- a/crates/test-programs/TEST_FAILURES +++ b/crates/test-programs/TEST_FAILURES @@ -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. @@ -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 diff --git a/crates/test-programs/wasi-tests/src/bin/path_link.rs b/crates/test-programs/wasi-tests/src/bin/path_link.rs index 7a441f4f50..f7f576f3ed 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_link.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_link.rs @@ -184,25 +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 + // Symlink following with path_link is rejected assert_eq!( wasi::path_link( dir_fd, @@ -211,30 +196,11 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) { dir_fd, "link", ) - .expect_err("creating a link to a dangling symlink following symlinks should fail") + .expect_err("calling path_link with LOOKUPFLAGS_SYMLINK_FOLLOW should fail") .raw_error(), - wasi::ERRNO_NOENT, - "errno should be ERRNO_NOENT" + wasi::ERRNO_INVAL, + "errno should be ERRNO_INVAL" ); - 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"); - - assert_eq!( - wasi::path_link( - dir_fd, - wasi::LOOKUPFLAGS_SYMLINK_FOLLOW, - "symlink", - dir_fd, - "link", - ) - .expect_err("creating a link to a symlink loop following symlinks") - .raw_error(), - wasi::ERRNO_LOOP, - "errno should be ERRNO_LOOP" - ); - wasi::path_unlink_file(dir_fd, "symlink").expect("removing a symlink"); // Clean up. wasi::path_unlink_file(dir_fd, "file").expect("removing a file");