diff --git a/crates/test-programs/tests/wasm_tests/runtime.rs b/crates/test-programs/tests/wasm_tests/runtime.rs index 6b00db61b4..2c3a6e3b3d 100644 --- a/crates/test-programs/tests/wasm_tests/runtime.rs +++ b/crates/test-programs/tests/wasm_tests/runtime.rs @@ -33,7 +33,8 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any builder = builder .env("ERRNO_MODE_WINDOWS", "1")? .env("NO_DANGLING_SYMLINKS", "1")? - .env("NO_FD_ALLOCATE", "1")?; + .env("NO_FD_ALLOCATE", "1")? + .env("NO_RENAME_DIR_TO_EMPTY_DIR", "1")?; } #[cfg(unix)] { diff --git a/crates/test-programs/wasi-tests/src/bin/close_preopen.rs b/crates/test-programs/wasi-tests/src/bin/close_preopen.rs index 7dabc044df..d2858e028f 100644 --- a/crates/test-programs/wasi-tests/src/bin/close_preopen.rs +++ b/crates/test-programs/wasi-tests/src/bin/close_preopen.rs @@ -8,12 +8,11 @@ unsafe fn test_close_preopen(dir_fd: wasi::Fd) { assert_gt!(dir_fd, pre_fd, "dir_fd number"); // Try to close a preopened directory handle. - assert_eq!( + assert_errno!( wasi::fd_close(pre_fd) .expect_err("closing a preopened file descriptor") .raw_error(), - wasi::ERRNO_NOTSUP, - "errno should ERRNO_NOTSUP", + wasi::ERRNO_NOTSUP ); // Try to renumber over a preopened directory handle. @@ -21,7 +20,7 @@ unsafe fn test_close_preopen(dir_fd: wasi::Fd) { wasi::fd_renumber(dir_fd, pre_fd) .expect_err("renumbering over a preopened file descriptor") .raw_error(), - wasi::ERRNO_NOTSUP, + wasi::ERRNO_NOTSUP ); // Ensure that dir_fd is still open. @@ -37,7 +36,7 @@ unsafe fn test_close_preopen(dir_fd: wasi::Fd) { wasi::fd_renumber(pre_fd, dir_fd) .expect_err("renumbering over a preopened file descriptor") .raw_error(), - wasi::ERRNO_NOTSUP, + wasi::ERRNO_NOTSUP ); // Ensure that dir_fd is still open. diff --git a/crates/test-programs/wasi-tests/src/bin/dangling_symlink.rs b/crates/test-programs/wasi-tests/src/bin/dangling_symlink.rs index 4448ab9abd..7d5e960322 100644 --- a/crates/test-programs/wasi-tests/src/bin/dangling_symlink.rs +++ b/crates/test-programs/wasi-tests/src/bin/dangling_symlink.rs @@ -19,7 +19,7 @@ unsafe fn test_dangling_symlink(dir_fd: wasi::Fd) { wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0) .expect_err("opening a dangling symlink as a file") .raw_error(), - wasi::ERRNO_LOOP, + wasi::ERRNO_LOOP ); // Clean up. diff --git a/crates/test-programs/wasi-tests/src/bin/directory_seek.rs b/crates/test-programs/wasi-tests/src/bin/directory_seek.rs index a8d5c5b740..7ccbceb8f7 100644 --- a/crates/test-programs/wasi-tests/src/bin/directory_seek.rs +++ b/crates/test-programs/wasi-tests/src/bin/directory_seek.rs @@ -28,7 +28,7 @@ unsafe fn test_directory_seek(dir_fd: wasi::Fd) { wasi::fd_seek(fd, 0, wasi::WHENCE_CUR) .expect_err("seek on a directory") .raw_error(), - wasi::ERRNO_BADF, + wasi::ERRNO_BADF ); // Check if we obtained the right to seek. diff --git a/crates/test-programs/wasi-tests/src/bin/file_seek_tell.rs b/crates/test-programs/wasi-tests/src/bin/file_seek_tell.rs index 1d256cb7aa..64646c4cd1 100644 --- a/crates/test-programs/wasi-tests/src/bin/file_seek_tell.rs +++ b/crates/test-programs/wasi-tests/src/bin/file_seek_tell.rs @@ -61,7 +61,7 @@ unsafe fn test_file_seek_tell(dir_fd: wasi::Fd) { wasi::fd_seek(file_fd, -2000, wasi::WHENCE_CUR) .expect_err("seeking before byte 0 should be an error") .raw_error(), - wasi::ERRNO_INVAL, + wasi::ERRNO_INVAL ); // Check that fd_read properly updates the file offset diff --git a/crates/test-programs/wasi-tests/src/bin/interesting_paths.rs b/crates/test-programs/wasi-tests/src/bin/interesting_paths.rs index 2ffde029fa..7e112167b8 100644 --- a/crates/test-programs/wasi-tests/src/bin/interesting_paths.rs +++ b/crates/test-programs/wasi-tests/src/bin/interesting_paths.rs @@ -17,7 +17,7 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) { wasi::path_open(dir_fd, 0, "/dir/nested/file", 0, 0, 0, 0) .expect_err("opening a file with an absolute path") .raw_error(), - wasi::ERRNO_PERM, + wasi::ERRNO_PERM ); // Now open it with a path containing "..". @@ -43,7 +43,7 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) { wasi::path_open(dir_fd, 0, "dir/nested/file\0", 0, 0, 0, 0) .expect_err("opening a file with a trailing NUL") .raw_error(), - wasi::ERRNO_ILSEQ, + wasi::ERRNO_ILSEQ ); // Now open it with a trailing slash. @@ -52,7 +52,7 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) { .expect_err("opening a file with a trailing slash should fail") .raw_error(), wasi::ERRNO_NOTDIR, - wasi::ERRNO_NOENT, + wasi::ERRNO_NOENT ); // Now open it with trailing slashes. @@ -61,7 +61,7 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) { .expect_err("opening a file with trailing slashes should fail") .raw_error(), wasi::ERRNO_NOTDIR, - wasi::ERRNO_NOENT, + wasi::ERRNO_NOENT ); // Now open the directory with a trailing slash. @@ -90,7 +90,7 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) { wasi::path_open(dir_fd, 0, &bad_path, 0, 0, 0, 0) .expect_err("opening a file with too many \"..\"s in the path should fail") .raw_error(), - wasi::ERRNO_PERM, + wasi::ERRNO_PERM ); wasi::path_unlink_file(dir_fd, "dir/nested/file") .expect("unlink_file on a symlink should succeed"); diff --git a/crates/test-programs/wasi-tests/src/bin/nofollow_errors.rs b/crates/test-programs/wasi-tests/src/bin/nofollow_errors.rs index dd5aaf71e9..50ba68e8ad 100644 --- a/crates/test-programs/wasi-tests/src/bin/nofollow_errors.rs +++ b/crates/test-programs/wasi-tests/src/bin/nofollow_errors.rs @@ -16,7 +16,7 @@ unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) { .expect_err("opening a directory symlink as a directory should fail") .raw_error(), wasi::ERRNO_LOOP, - wasi::ERRNO_NOTDIR, + wasi::ERRNO_NOTDIR ); // Try to open it with just O_NOFOLLOW. @@ -25,7 +25,7 @@ unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) { .expect_err("opening a symlink with O_NOFOLLOW should fail") .raw_error(), wasi::ERRNO_LOOP, - wasi::ERRNO_ACCES, + wasi::ERRNO_ACCES ); // Try to open it as a directory without O_NOFOLLOW. @@ -70,7 +70,7 @@ unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) { wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0) .expect_err("opening a symlink with NOFOLLOW should fail") .raw_error(), - wasi::ERRNO_LOOP, + wasi::ERRNO_LOOP ); // Try to open it as a directory without O_NOFOLLOW. @@ -86,7 +86,7 @@ unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) { ) .expect_err("opening a symlink to a file as a directory") .raw_error(), - wasi::ERRNO_NOTDIR, + wasi::ERRNO_NOTDIR ); // Clean up. diff --git a/crates/test-programs/wasi-tests/src/bin/path_filestat.rs b/crates/test-programs/wasi-tests/src/bin/path_filestat.rs index e6c8f19569..cb55e07b77 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_filestat.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_filestat.rs @@ -92,7 +92,7 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) { ) .expect_err("ATIM & ATIM_NOW can't both be set") .raw_error(), - wasi::ERRNO_INVAL, + wasi::ERRNO_INVAL ); wasi::fd_close(file_fd).expect("closing a file"); 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 776c1ad036..0178c529c6 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_link.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_link.rs @@ -148,7 +148,7 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) { wasi::path_link(dir_fd, 0, "file", dir_fd, "link/") .expect_err("creating a link to a file with trailing slash should fail") .raw_error(), - wasi::ERRNO_NOENT, + wasi::ERRNO_NOENT ); // XXX windows doesnt support dangling symlinks - rest of file @@ -176,7 +176,7 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) { wasi::path_link(dir_fd, 0, "file", dir_fd, "symlink") .expect_err("creating a link where target is a dangling symlink") .raw_error(), - wasi::ERRNO_EXIST, + wasi::ERRNO_EXIST ); wasi::path_unlink_file(dir_fd, "symlink").expect("removing a symlink"); @@ -194,7 +194,7 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) { ) .expect_err("calling path_link with LOOKUPFLAGS_SYMLINK_FOLLOW should fail") .raw_error(), - wasi::ERRNO_INVAL, + wasi::ERRNO_INVAL ); // Clean up. diff --git a/crates/test-programs/wasi-tests/src/bin/path_open_create_existing.rs b/crates/test-programs/wasi-tests/src/bin/path_open_create_existing.rs index b9279b029d..21abc0598a 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_open_create_existing.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_open_create_existing.rs @@ -15,7 +15,7 @@ unsafe fn test_path_open_create_existing(dir_fd: wasi::Fd) { ) .expect_err("trying to create a file that already exists") .raw_error(), - wasi::ERRNO_EXIST, + wasi::ERRNO_EXIST ); wasi::path_unlink_file(dir_fd, "file").expect("removing a file"); } diff --git a/crates/test-programs/wasi-tests/src/bin/path_open_dirfd_not_dir.rs b/crates/test-programs/wasi-tests/src/bin/path_open_dirfd_not_dir.rs index 09fdc34720..7fda00334c 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_open_dirfd_not_dir.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_open_dirfd_not_dir.rs @@ -10,7 +10,7 @@ unsafe fn test_dirfd_not_dir(dir_fd: wasi::Fd) { wasi::path_open(file_fd, 0, "foo", wasi::OFLAGS_CREAT, 0, 0, 0) .expect_err("non-directory base fd should get ERRNO_NOTDIR") .raw_error(), - wasi::ERRNO_NOTDIR, + wasi::ERRNO_NOTDIR ); wasi::fd_close(file_fd).expect("closing a file"); } diff --git a/crates/test-programs/wasi-tests/src/bin/path_rename.rs b/crates/test-programs/wasi-tests/src/bin/path_rename.rs index 950c35a731..79d4615a99 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_rename.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_rename.rs @@ -1,6 +1,6 @@ use more_asserts::assert_gt; use std::{env, process}; -use wasi_tests::{assert_errno, create_file, open_scratch_directory}; +use wasi_tests::{assert_errno, create_file, open_scratch_directory, TESTCONFIG}; unsafe fn test_path_rename(dir_fd: wasi::Fd) { // First, try renaming a dir to nonexistent path @@ -30,30 +30,32 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) { wasi::fd_close(fd).expect("closing a file"); wasi::path_remove_directory(dir_fd, "target").expect("removing a directory"); - // Now, try renaming renaming a dir to existing empty dir - wasi::path_create_directory(dir_fd, "source").expect("creating a directory"); - wasi::path_create_directory(dir_fd, "target").expect("creating a directory"); - wasi::path_rename(dir_fd, "source", dir_fd, "target").expect("renaming a directory"); + if TESTCONFIG.support_rename_dir_to_empty_dir() { + // Now, try renaming renaming a dir to existing empty dir + wasi::path_create_directory(dir_fd, "source").expect("creating a directory"); + wasi::path_create_directory(dir_fd, "target").expect("creating a directory"); + wasi::path_rename(dir_fd, "source", dir_fd, "target").expect("renaming a directory"); - // Check that source directory doesn't exist anymore - assert_errno!( - wasi::path_open(dir_fd, 0, "source", wasi::OFLAGS_DIRECTORY, 0, 0, 0) - .expect_err("opening a nonexistent path as a directory") - .raw_error(), - wasi::ERRNO_NOENT - ); + // Check that source directory doesn't exist anymore + assert_errno!( + wasi::path_open(dir_fd, 0, "source", wasi::OFLAGS_DIRECTORY, 0, 0, 0) + .expect_err("opening a nonexistent path as a directory") + .raw_error(), + wasi::ERRNO_NOENT + ); - // Check that target directory exists - fd = wasi::path_open(dir_fd, 0, "target", wasi::OFLAGS_DIRECTORY, 0, 0, 0) - .expect("opening renamed path as a directory"); - assert_gt!( - fd, - libc::STDERR_FILENO as wasi::Fd, - "file descriptor range check", - ); + // Check that target directory exists + fd = wasi::path_open(dir_fd, 0, "target", wasi::OFLAGS_DIRECTORY, 0, 0, 0) + .expect("opening renamed path as a directory"); + assert_gt!( + fd, + libc::STDERR_FILENO as wasi::Fd, + "file descriptor range check", + ); - wasi::fd_close(fd).expect("closing a file"); - wasi::path_remove_directory(dir_fd, "target").expect("removing a directory"); + wasi::fd_close(fd).expect("closing a file"); + wasi::path_remove_directory(dir_fd, "target").expect("removing a directory"); + } // Now, try renaming a dir to existing non-empty dir wasi::path_create_directory(dir_fd, "source").expect("creating a directory"); @@ -64,7 +66,8 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) { wasi::path_rename(dir_fd, "source", dir_fd, "target") .expect_err("renaming directory to a nonempty directory") .raw_error(), - wasi::ERRNO_NOTEMPTY + windows => wasi::ERRNO_ACCES, + unix => wasi::ERRNO_NOTEMPTY ); // Try renaming dir to a file @@ -128,7 +131,6 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) { wasi::fd_close(fd).expect("closing a file"); wasi::path_unlink_file(dir_fd, "target").expect("removing a file"); - // XXX windows does not support this operation // Try renaming to an (empty) directory instead create_file(dir_fd, "source"); wasi::path_create_directory(dir_fd, "target").expect("creating a directory"); diff --git a/crates/test-programs/wasi-tests/src/bin/path_rename_file_trailing_slashes.rs b/crates/test-programs/wasi-tests/src/bin/path_rename_file_trailing_slashes.rs index 67c6796098..b884a84d03 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_rename_file_trailing_slashes.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_rename_file_trailing_slashes.rs @@ -13,19 +13,19 @@ unsafe fn test_path_rename_trailing_slashes(dir_fd: wasi::Fd) { wasi::path_rename(dir_fd, "source/", dir_fd, "target") .expect_err("renaming a file with a trailing slash in the source name should fail") .raw_error(), - wasi::ERRNO_NOTDIR, + wasi::ERRNO_NOTDIR ); assert_errno!( wasi::path_rename(dir_fd, "source", dir_fd, "target/") .expect_err("renaming a file with a trailing slash in the destination name should fail") .raw_error(), - wasi::ERRNO_NOTDIR, + wasi::ERRNO_NOTDIR ); assert_errno!( wasi::path_rename(dir_fd, "source/", dir_fd, "target/") .expect_err("renaming a file with a trailing slash in the source and destination names should fail") .raw_error(), - wasi::ERRNO_NOTDIR, + wasi::ERRNO_NOTDIR ); wasi::path_unlink_file(dir_fd, "source").expect("removing a file"); } diff --git a/crates/test-programs/wasi-tests/src/bin/path_symlink_trailing_slashes.rs b/crates/test-programs/wasi-tests/src/bin/path_symlink_trailing_slashes.rs index 5a63a13fb8..95e53790c0 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_symlink_trailing_slashes.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_symlink_trailing_slashes.rs @@ -8,7 +8,7 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) { wasi::path_symlink("source", dir_fd, "target/") .expect_err("link destination ending with a slash should fail") .raw_error(), - wasi::ERRNO_NOENT, + wasi::ERRNO_NOENT ); // Dangling symlink: Without the trailing slash, this should succeed. @@ -34,7 +34,7 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) { wasi::path_symlink("source", dir_fd, "target") .expect_err("link destination already exists") .raw_error(), - wasi::ERRNO_EXIST, + wasi::ERRNO_EXIST ); wasi::path_remove_directory(dir_fd, "target").expect("removing a directory"); @@ -47,7 +47,7 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) { .expect_err("link destination already exists") .raw_error(), wasi::ERRNO_EXIST, - wasi::ERRNO_NOTDIR, + wasi::ERRNO_NOTDIR ); wasi::path_unlink_file(dir_fd, "target").expect("removing a file"); @@ -59,7 +59,7 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) { wasi::path_symlink("source", dir_fd, "target") .expect_err("link destination already exists") .raw_error(), - wasi::ERRNO_EXIST, + wasi::ERRNO_EXIST ); wasi::path_unlink_file(dir_fd, "target").expect("removing a file"); } diff --git a/crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs b/crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs index 2b1df93644..a680cf6309 100644 --- a/crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs +++ b/crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs @@ -21,7 +21,7 @@ unsafe fn test_empty_poll() { wasi::poll_oneoff(r#in.as_ptr(), out.as_mut_ptr(), r#in.len()) .expect_err("empty poll_oneoff should fail") .raw_error(), - wasi::ERRNO_INVAL, + wasi::ERRNO_INVAL ); } @@ -42,7 +42,7 @@ unsafe fn test_timeout() { let out = poll_oneoff_impl(&r#in).unwrap(); assert_eq!(out.len(), 1, "should return 1 event"); let event = &out[0]; - assert_errno!(event.error, wasi::ERRNO_SUCCESS,); + assert_errno!(event.error, wasi::ERRNO_SUCCESS); assert_eq!( event.r#type, wasi::EVENTTYPE_CLOCK, diff --git a/crates/test-programs/wasi-tests/src/bin/remove_directory_trailing_slashes.rs b/crates/test-programs/wasi-tests/src/bin/remove_directory_trailing_slashes.rs index 1a5a1dd68a..a7b296e703 100644 --- a/crates/test-programs/wasi-tests/src/bin/remove_directory_trailing_slashes.rs +++ b/crates/test-programs/wasi-tests/src/bin/remove_directory_trailing_slashes.rs @@ -25,7 +25,7 @@ unsafe fn test_remove_directory_trailing_slashes(dir_fd: wasi::Fd) { wasi::path_remove_directory(dir_fd, "file") .expect_err("remove_directory without a trailing slash on a file should fail") .raw_error(), - wasi::ERRNO_NOTDIR, + wasi::ERRNO_NOTDIR ); // Test that removing it with a trailing slash fails. @@ -34,7 +34,7 @@ unsafe fn test_remove_directory_trailing_slashes(dir_fd: wasi::Fd) { wasi::path_remove_directory(dir_fd, "file/") .expect_err("remove_directory with a trailing slash on a file should fail") .raw_error(), - wasi::ERRNO_NOTDIR, + wasi::ERRNO_NOTDIR ); wasi::path_unlink_file(dir_fd, "file").expect("removing a file"); diff --git a/crates/test-programs/wasi-tests/src/bin/renumber.rs b/crates/test-programs/wasi-tests/src/bin/renumber.rs index 8f86f83cc5..721c636362 100644 --- a/crates/test-programs/wasi-tests/src/bin/renumber.rs +++ b/crates/test-programs/wasi-tests/src/bin/renumber.rs @@ -53,7 +53,7 @@ unsafe fn test_renumber(dir_fd: wasi::Fd) { wasi::fd_close(fd_from) .expect_err("closing already closed file descriptor") .raw_error(), - wasi::ERRNO_BADF, + wasi::ERRNO_BADF ); // Ensure that fd_to is still open. diff --git a/crates/test-programs/wasi-tests/src/bin/symlink_loop.rs b/crates/test-programs/wasi-tests/src/bin/symlink_loop.rs index 28dd21a1e1..e6edae2392 100644 --- a/crates/test-programs/wasi-tests/src/bin/symlink_loop.rs +++ b/crates/test-programs/wasi-tests/src/bin/symlink_loop.rs @@ -10,7 +10,7 @@ unsafe fn test_symlink_loop(dir_fd: wasi::Fd) { wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0) .expect_err("opening a self-referencing symlink") .raw_error(), - wasi::ERRNO_LOOP, + wasi::ERRNO_LOOP ); // Clean up. diff --git a/crates/test-programs/wasi-tests/src/bin/truncation_rights.rs b/crates/test-programs/wasi-tests/src/bin/truncation_rights.rs index 13391d6a77..c28d11f1fa 100644 --- a/crates/test-programs/wasi-tests/src/bin/truncation_rights.rs +++ b/crates/test-programs/wasi-tests/src/bin/truncation_rights.rs @@ -68,7 +68,7 @@ unsafe fn test_truncation_rights(dir_fd: wasi::Fd) { wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_TRUNC, 0, 0, 0) .expect_err("truncating a file without path_filestat_set_size right") .raw_error(), - wasi::ERRNO_NOTCAPABLE, + wasi::ERRNO_NOTCAPABLE ); } diff --git a/crates/test-programs/wasi-tests/src/bin/unlink_file_trailing_slashes.rs b/crates/test-programs/wasi-tests/src/bin/unlink_file_trailing_slashes.rs index 0079176cd6..90c2f32ad7 100644 --- a/crates/test-programs/wasi-tests/src/bin/unlink_file_trailing_slashes.rs +++ b/crates/test-programs/wasi-tests/src/bin/unlink_file_trailing_slashes.rs @@ -11,7 +11,7 @@ unsafe fn test_unlink_file_trailing_slashes(dir_fd: wasi::Fd) { wasi::path_unlink_file(dir_fd, "dir") .expect_err("unlink_file on a directory should fail") .raw_error(), - wasi::ERRNO_ISDIR, + wasi::ERRNO_ISDIR ); // Test that unlinking it with a trailing flash fails. @@ -20,7 +20,7 @@ unsafe fn test_unlink_file_trailing_slashes(dir_fd: wasi::Fd) { wasi::path_unlink_file(dir_fd, "dir/") .expect_err("unlink_file on a directory should fail") .raw_error(), - wasi::ERRNO_ISDIR, + wasi::ERRNO_ISDIR ); // Clean up. @@ -35,7 +35,7 @@ unsafe fn test_unlink_file_trailing_slashes(dir_fd: wasi::Fd) { wasi::path_unlink_file(dir_fd, "file/") .expect_err("unlink_file with a trailing slash should fail") .raw_error(), - wasi::ERRNO_NOTDIR, + wasi::ERRNO_NOTDIR ); // Test that unlinking it with no trailing flash succeeds. diff --git a/crates/test-programs/wasi-tests/src/config.rs b/crates/test-programs/wasi-tests/src/config.rs index 109a1b21ca..132ac8dcb5 100644 --- a/crates/test-programs/wasi-tests/src/config.rs +++ b/crates/test-programs/wasi-tests/src/config.rs @@ -2,6 +2,7 @@ pub struct TestConfig { errno_mode: ErrnoMode, no_dangling_symlinks: bool, no_fd_allocate: bool, + no_rename_dir_to_empty_dir: bool, } enum ErrnoMode { @@ -21,10 +22,12 @@ impl TestConfig { }; let no_dangling_symlinks = std::env::var("NO_DANGLING_SYMLINKS").is_ok(); let no_fd_allocate = std::env::var("NO_FD_ALLOCATE").is_ok(); + let no_rename_dir_to_empty_dir = std::env::var("NO_RENAME_DIR_TO_EMPTY_DIR").is_ok(); TestConfig { errno_mode, no_dangling_symlinks, no_fd_allocate, + no_rename_dir_to_empty_dir, } } pub fn errno_expect_unix(&self) -> bool { @@ -45,4 +48,7 @@ impl TestConfig { pub fn support_fd_allocate(&self) -> bool { !self.no_fd_allocate } + pub fn support_rename_dir_to_empty_dir(&self) -> bool { + !self.no_rename_dir_to_empty_dir + } } diff --git a/crates/test-programs/wasi-tests/src/lib.rs b/crates/test-programs/wasi-tests/src/lib.rs index 0452573dda..5507f470ee 100644 --- a/crates/test-programs/wasi-tests/src/lib.rs +++ b/crates/test-programs/wasi-tests/src/lib.rs @@ -69,23 +69,20 @@ pub unsafe fn drop_rights(fd: wasi::Fd, drop_base: wasi::Rights, drop_inheriting #[macro_export] macro_rules! assert_errno { - ($s:expr, $( $i:expr ),+,) => { - assert_errno!($s, $( $i ),+) - }; - ($s:expr, windows => $i:expr, $( $rest:expr ),+) => { + ($s:expr, windows => $i:expr, $( $rest:tt )+) => { let e = $s; if $crate::TESTCONFIG.errno_expect_windows() { assert_errno!(e, $i); } else { - assert_errno!(e, $($rest),+, $i); + assert_errno!(e, $($rest)+, $i); } }; - ($s:expr, unix => $i:expr, $( $rest:expr ),+) => { + ($s:expr, unix => $i:expr, $( $rest:tt )+) => { let e = $s; if $crate::TESTCONFIG.errno_expect_unix() { assert_errno!(e, $i); } else { - assert_errno!(e, $($rest),+, $i); + assert_errno!(e, $($rest)+, $i); } }; ($s:expr, $( $i:expr ),+) => {