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 26ca315465..7dabc044df 100644 --- a/crates/test-programs/wasi-tests/src/bin/close_preopen.rs +++ b/crates/test-programs/wasi-tests/src/bin/close_preopen.rs @@ -1,6 +1,6 @@ use more_asserts::assert_gt; use std::{env, process}; -use wasi_tests::open_scratch_directory; +use wasi_tests::{assert_errno, open_scratch_directory}; unsafe fn test_close_preopen(dir_fd: wasi::Fd) { let pre_fd: wasi::Fd = (libc::STDERR_FILENO + 1) as wasi::Fd; @@ -17,12 +17,11 @@ unsafe fn test_close_preopen(dir_fd: wasi::Fd) { ); // Try to renumber over a preopened directory handle. - assert_eq!( + assert_errno!( wasi::fd_renumber(dir_fd, pre_fd) .expect_err("renumbering over a preopened file descriptor") .raw_error(), wasi::ERRNO_NOTSUP, - "errno should be ERRNO_NOTSUP", ); // Ensure that dir_fd is still open. @@ -34,12 +33,11 @@ unsafe fn test_close_preopen(dir_fd: wasi::Fd) { ); // Try to renumber a preopened directory handle. - assert_eq!( + assert_errno!( wasi::fd_renumber(pre_fd, dir_fd) .expect_err("renumbering over a preopened file descriptor") .raw_error(), wasi::ERRNO_NOTSUP, - "errno should be 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 47e2e3d580..4448ab9abd 100644 --- a/crates/test-programs/wasi-tests/src/bin/dangling_symlink.rs +++ b/crates/test-programs/wasi-tests/src/bin/dangling_symlink.rs @@ -1,26 +1,25 @@ use std::{env, process}; -use wasi_tests::open_scratch_directory; +use wasi_tests::{assert_errno, open_scratch_directory}; unsafe fn test_dangling_symlink(dir_fd: wasi::Fd) { // First create a dangling symlink. wasi::path_symlink("target", dir_fd, "symlink").expect("creating a symlink"); // Try to open it as a directory with O_NOFOLLOW. - let dir_open_errno = wasi::path_open(dir_fd, 0, "symlink", wasi::OFLAGS_DIRECTORY, 0, 0, 0) - .expect_err("opening a dangling symlink as a directory") - .raw_error(); - assert!( - dir_open_errno == wasi::ERRNO_NOTDIR || dir_open_errno == wasi::ERRNO_LOOP, - "errno should be ERRNO_NOTDIR or ERRNO_LOOP", + assert_errno!( + wasi::path_open(dir_fd, 0, "symlink", wasi::OFLAGS_DIRECTORY, 0, 0, 0) + .expect_err("opening a dangling symlink as a directory") + .raw_error(), + wasi::ERRNO_NOTDIR, + wasi::ERRNO_LOOP ); // Try to open it as a file with O_NOFOLLOW. - assert_eq!( + assert_errno!( 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, - "errno should be 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 fc6cd3eb03..a8d5c5b740 100644 --- a/crates/test-programs/wasi-tests/src/bin/directory_seek.rs +++ b/crates/test-programs/wasi-tests/src/bin/directory_seek.rs @@ -1,6 +1,6 @@ use more_asserts::assert_gt; use std::{env, process}; -use wasi_tests::open_scratch_directory; +use wasi_tests::{assert_errno, open_scratch_directory}; unsafe fn test_directory_seek(dir_fd: wasi::Fd) { // Create a directory in the scratch directory. @@ -24,12 +24,11 @@ unsafe fn test_directory_seek(dir_fd: wasi::Fd) { ); // Attempt to seek. - assert_eq!( + assert_errno!( wasi::fd_seek(fd, 0, wasi::WHENCE_CUR) .expect_err("seek on a directory") .raw_error(), wasi::ERRNO_BADF, - "errno should be 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 b5d43a278a..1d256cb7aa 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 @@ -1,6 +1,6 @@ use more_asserts::assert_gt; use std::{env, process}; -use wasi_tests::open_scratch_directory; +use wasi_tests::{assert_errno, open_scratch_directory}; unsafe fn test_file_seek_tell(dir_fd: wasi::Fd) { // Create a file in the scratch directory. @@ -57,16 +57,16 @@ unsafe fn test_file_seek_tell(dir_fd: wasi::Fd) { wasi::fd_seek(file_fd, 1000, wasi::WHENCE_CUR).expect("seeking beyond the end of the file"); // Seek before byte 0 is an error though - assert_eq!( + assert_errno!( wasi::fd_seek(file_fd, -2000, wasi::WHENCE_CUR) .expect_err("seeking before byte 0 should be an error") .raw_error(), wasi::ERRNO_INVAL, - "errno should be ERRNO_INVAL", ); // Check that fd_read properly updates the file offset - wasi::fd_seek(file_fd, 0, wasi::WHENCE_SET).expect("seeking to the beginning of the file again"); + wasi::fd_seek(file_fd, 0, wasi::WHENCE_SET) + .expect("seeking to the beginning of the file again"); let buffer = &mut [0u8; 100]; let iovec = wasi::Iovec { 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 b0c12b2e2c..2ffde029fa 100644 --- a/crates/test-programs/wasi-tests/src/bin/interesting_paths.rs +++ b/crates/test-programs/wasi-tests/src/bin/interesting_paths.rs @@ -1,6 +1,6 @@ use more_asserts::assert_gt; use std::{env, process}; -use wasi_tests::{create_file, open_scratch_directory}; +use wasi_tests::{assert_errno, create_file, open_scratch_directory}; unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) { // Create a directory in the scratch directory. @@ -13,12 +13,11 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) { create_file(dir_fd, "dir/nested/file"); // Now open it with an absolute path. - assert_eq!( + assert_errno!( 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, - "errno should be ERRNO_PERM" ); // Now open it with a path containing "..". @@ -40,34 +39,29 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) { wasi::fd_close(file_fd).expect("closing a file"); // Now open it with a trailing NUL. - assert_eq!( + assert_errno!( 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, - "errno should be ERRNO_ILSEQ", ); // Now open it with a trailing slash. - let one_trailing_slash_errno = wasi::path_open(dir_fd, 0, "dir/nested/file/", 0, 0, 0, 0) - .expect_err("opening a file with a trailing slash should fail") - .raw_error(); - assert!( - one_trailing_slash_errno == wasi::ERRNO_NOTDIR - || one_trailing_slash_errno == wasi::ERRNO_NOENT, - "errno should be ERRNO_NOTDIR or ERRNO_NOENT, got {}", - one_trailing_slash_errno + assert_errno!( + wasi::path_open(dir_fd, 0, "dir/nested/file/", 0, 0, 0, 0) + .expect_err("opening a file with a trailing slash should fail") + .raw_error(), + wasi::ERRNO_NOTDIR, + wasi::ERRNO_NOENT, ); // Now open it with trailing slashes. - let multi_trailing_slash_errno = wasi::path_open(dir_fd, 0, "dir/nested/file///", 0, 0, 0, 0) - .expect_err("opening a file with trailing slashes should fail") - .raw_error(); - assert!( - multi_trailing_slash_errno == wasi::ERRNO_NOTDIR - || multi_trailing_slash_errno == wasi::ERRNO_NOENT, - "errno should be ERRNO_NOTDIR or ERRNO_NOENT, got {}", - multi_trailing_slash_errno, + assert_errno!( + wasi::path_open(dir_fd, 0, "dir/nested/file///", 0, 0, 0, 0) + .expect_err("opening a file with trailing slashes should fail") + .raw_error(), + wasi::ERRNO_NOTDIR, + wasi::ERRNO_NOENT, ); // Now open the directory with a trailing slash. @@ -92,12 +86,11 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) { // Now open it with a path containing too many ".."s. let bad_path = format!("dir/nested/../../../{}/dir/nested/file", arg); - assert_eq!( + assert_errno!( 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, - "errno should be 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 a81944862c..dd5aaf71e9 100644 --- a/crates/test-programs/wasi-tests/src/bin/nofollow_errors.rs +++ b/crates/test-programs/wasi-tests/src/bin/nofollow_errors.rs @@ -1,7 +1,7 @@ use libc; use more_asserts::assert_gt; use std::{env, process}; -use wasi_tests::open_scratch_directory; +use wasi_tests::{assert_errno, open_scratch_directory}; unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) { // Create a directory for the symlink to point to. @@ -11,23 +11,21 @@ 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. - 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, got {}", - dir_open_errno, + assert_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(), + wasi::ERRNO_LOOP, + wasi::ERRNO_NOTDIR, ); // Try to open it with just O_NOFOLLOW. - let file_open_errno = wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0) - .expect_err("opening a symlink with O_NOFOLLOW should fail") - .raw_error(); - assert!( - file_open_errno == wasi::ERRNO_LOOP || file_open_errno == wasi::ERRNO_ACCES, - "errno should be ERRNO_LOOP or ERRNO_ACCES, got {}", - file_open_errno, + assert_errno!( + wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0) + .expect_err("opening a symlink with O_NOFOLLOW should fail") + .raw_error(), + wasi::ERRNO_LOOP, + wasi::ERRNO_ACCES, ); // Try to open it as a directory without O_NOFOLLOW. @@ -59,25 +57,24 @@ 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. - 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", + assert_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(), + wasi::ERRNO_LOOP, + wasi::ERRNO_NOTDIR ); // Try to open it with just O_NOFOLLOW. - assert_eq!( + assert_errno!( 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, - "errno should be ERRNO_LOOP", ); // Try to open it as a directory without O_NOFOLLOW. - assert_eq!( + assert_errno!( wasi::path_open( dir_fd, wasi::LOOKUPFLAGS_SYMLINK_FOLLOW, @@ -90,7 +87,6 @@ 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, - "errno should be 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 efcc6a46fa..e6c8f19569 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_filestat.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_filestat.rs @@ -1,6 +1,6 @@ use more_asserts::assert_gt; use std::{env, process}; -use wasi_tests::open_scratch_directory; +use wasi_tests::{assert_errno, open_scratch_directory}; unsafe fn test_path_filestat(dir_fd: wasi::Fd) { let mut fdstat = wasi::fd_fdstat_get(dir_fd).expect("fd_fdstat_get"); @@ -58,7 +58,7 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) { .expect("reading file stats after path_filestat_set_times"); assert_eq!(modified_file_stat.mtim, new_mtim, "mtim should change"); - assert_eq!( + assert_errno!( wasi::path_filestat_set_times( dir_fd, 0, @@ -69,8 +69,7 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) { ) .expect_err("MTIM and MTIM_NOW can't both be set") .raw_error(), - wasi::ERRNO_INVAL, - "errno should be ERRNO_INVAL" + wasi::ERRNO_INVAL ); // check if the times were untouched @@ -82,7 +81,7 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) { ); // Invalid arguments to set_times: - assert_eq!( + assert_errno!( wasi::path_filestat_set_times( dir_fd, 0, @@ -94,7 +93,6 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) { .expect_err("ATIM & ATIM_NOW can't both be set") .raw_error(), wasi::ERRNO_INVAL, - "errno should be 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 16d827e8dd..776c1ad036 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_link.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_link.rs @@ -1,6 +1,6 @@ use more_asserts::assert_gt; use std::{env, process}; -use wasi_tests::{create_file, open_scratch_directory}; +use wasi_tests::{assert_errno, create_file, open_scratch_directory}; const TEST_RIGHTS: wasi::Rights = wasi::RIGHTS_FD_READ | wasi::RIGHTS_PATH_LINK_SOURCE @@ -102,33 +102,30 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) { // Create a link to a path that already exists create_file(dir_fd, "link"); - assert_eq!( + assert_errno!( wasi::path_link(dir_fd, 0, "file", dir_fd, "link") .expect_err("creating a link to existing path should fail") .raw_error(), - wasi::ERRNO_EXIST, - "errno should be ERRNO_EXIST" + wasi::ERRNO_EXIST ); wasi::path_unlink_file(dir_fd, "link").expect("removing a file"); // Create a link to itself - assert_eq!( + assert_errno!( wasi::path_link(dir_fd, 0, "file", dir_fd, "file") .expect_err("creating a link to itself should fail") .raw_error(), - wasi::ERRNO_EXIST, - "errno should be ERRNO_EXIST" + wasi::ERRNO_EXIST ); // Create a link where target is a directory wasi::path_create_directory(dir_fd, "link").expect("creating a dir"); - assert_eq!( + assert_errno!( wasi::path_link(dir_fd, 0, "file", dir_fd, "link") .expect_err("creating a link where target is a directory should fail") .raw_error(), - wasi::ERRNO_EXIST, - "errno should be ERRNO_EXIST" + wasi::ERRNO_EXIST ); wasi::path_remove_directory(dir_fd, "link").expect("removing a dir"); @@ -136,23 +133,22 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) { wasi::path_create_directory(dir_fd, "subdir").expect("creating a subdirectory"); let subdir_fd = create_or_open(dir_fd, "subdir", wasi::OFLAGS_DIRECTORY); - let path_link_errno = wasi::path_link(dir_fd, 0, "subdir", dir_fd, "link") - .expect_err("creating a link to a directory should fail") - .raw_error(); - assert!( - path_link_errno == wasi::ERRNO_PERM || path_link_errno == wasi::ERRNO_ACCES, - "errno should be ERRNO_PERM or ERRNO_ACCES" + assert_errno!( + wasi::path_link(dir_fd, 0, "subdir", dir_fd, "link") + .expect_err("creating a link to a directory should fail") + .raw_error(), + wasi::ERRNO_PERM, + wasi::ERRNO_ACCES ); wasi::fd_close(subdir_fd).expect("close subdir before deleting it"); wasi::path_remove_directory(dir_fd, "subdir").expect("removing a subdirectory"); // Create a link to a file with trailing slash - assert_eq!( + assert_errno!( 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, - "errno should be ERRNO_NOENT" ); // XXX windows doesnt support dangling symlinks - rest of file @@ -176,12 +172,11 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) { // Create a link where target is a dangling symlink wasi::path_symlink("target", dir_fd, "symlink").expect("creating a dangling symlink"); - assert_eq!( + assert_errno!( 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, - "errno should be ERRNO_EXIST" ); wasi::path_unlink_file(dir_fd, "symlink").expect("removing a symlink"); @@ -189,7 +184,7 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) { wasi::path_symlink("target", dir_fd, "symlink").expect("creating a dangling symlink"); // Symlink following with path_link is rejected - assert_eq!( + assert_errno!( wasi::path_link( dir_fd, wasi::LOOKUPFLAGS_SYMLINK_FOLLOW, @@ -200,7 +195,6 @@ 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, - "errno should be 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 11e7fc4c99..b9279b029d 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 @@ -1,9 +1,9 @@ use std::{env, process}; -use wasi_tests::{create_file, open_scratch_directory}; +use wasi_tests::{assert_errno, create_file, open_scratch_directory}; unsafe fn test_path_open_create_existing(dir_fd: wasi::Fd) { create_file(dir_fd, "file"); - assert_eq!( + assert_errno!( wasi::path_open( dir_fd, 0, @@ -16,7 +16,6 @@ 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, - "errno should be 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 dd6e502361..09fdc34720 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 @@ -1,17 +1,16 @@ use std::{env, process}; -use wasi_tests::open_scratch_directory; +use wasi_tests::{assert_errno, open_scratch_directory}; unsafe fn test_dirfd_not_dir(dir_fd: wasi::Fd) { // Open a file. let file_fd = wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_CREAT, 0, 0, 0).expect("opening a file"); // Now try to open a file underneath it as if it were a directory. - assert_eq!( + assert_errno!( 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, - "errno should be ERRNO_NOTDIR" ); wasi::fd_close(file_fd).expect("closing a file"); } diff --git a/crates/test-programs/wasi-tests/src/bin/path_open_missing.rs b/crates/test-programs/wasi-tests/src/bin/path_open_missing.rs index 410b602c45..8074090b8d 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_open_missing.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_open_missing.rs @@ -1,21 +1,15 @@ use std::{env, process}; -use wasi_tests::{open_scratch_directory}; +use wasi_tests::{assert_errno, open_scratch_directory}; unsafe fn test_path_open_missing(dir_fd: wasi::Fd) { - assert_eq!( + assert_errno!( wasi::path_open( - dir_fd, - 0, - "file", - 0, // not passing O_CREAT here - 0, - 0, - 0, + dir_fd, 0, "file", 0, // not passing O_CREAT here + 0, 0, 0, ) .expect_err("trying to open a file that doesn't exist") .raw_error(), - wasi::ERRNO_NOENT, - "errno should be ERRNO_NOENT" + wasi::ERRNO_NOENT ); } diff --git a/crates/test-programs/wasi-tests/src/bin/path_open_read_without_rights.rs b/crates/test-programs/wasi-tests/src/bin/path_open_read_without_rights.rs index 26113c08c8..c67fbe1280 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_open_read_without_rights.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_open_read_without_rights.rs @@ -1,6 +1,5 @@ use std::{env, process}; -use wasi_tests::open_scratch_directory; -use wasi_tests::{create_file, drop_rights, fd_get_rights}; +use wasi_tests::{assert_errno, create_file, drop_rights, fd_get_rights, open_scratch_directory}; const TEST_FILENAME: &'static str = "file"; @@ -27,12 +26,11 @@ unsafe fn try_read_file(dir_fd: wasi::Fd) { }; // Since we no longer have the right to fd_read, trying to read a file // should be an error. - assert_eq!( + assert_errno!( wasi::fd_read(fd, &[iovec]) .expect_err("reading bytes from file should fail") .raw_error(), - wasi::ERRNO_NOTCAPABLE, - "the errno should be ENOTCAPABLE" + wasi::ERRNO_NOTCAPABLE ); } 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 37a9bf8169..950c35a731 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::{create_file, open_scratch_directory}; +use wasi_tests::{assert_errno, create_file, open_scratch_directory}; unsafe fn test_path_rename(dir_fd: wasi::Fd) { // First, try renaming a dir to nonexistent path @@ -11,12 +11,11 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) { wasi::path_rename(dir_fd, "source", dir_fd, "target").expect("renaming a directory"); // Check that source directory doesn't exist anymore - assert_eq!( + assert_errno!( wasi::path_open(dir_fd, 0, "source", wasi::OFLAGS_DIRECTORY, 0, 0, 0) .expect_err("opening a nonexistent path as a directory should fail") .raw_error(), - wasi::ERRNO_NOENT, - "errno should be ERRNO_NOENT" + wasi::ERRNO_NOENT ); // Check that target directory exists @@ -37,12 +36,11 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) { wasi::path_rename(dir_fd, "source", dir_fd, "target").expect("renaming a directory"); // Check that source directory doesn't exist anymore - assert_eq!( + 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, - "errno should be ERRNO_NOENT" + wasi::ERRNO_NOENT ); // Check that target directory exists @@ -62,21 +60,19 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) { wasi::path_create_directory(dir_fd, "target").expect("creating a directory"); create_file(dir_fd, "target/file"); - assert_eq!( + assert_errno!( wasi::path_rename(dir_fd, "source", dir_fd, "target") .expect_err("renaming directory to a nonempty directory") .raw_error(), - wasi::ERRNO_NOTEMPTY, - "errno should be ERRNO_NOTEMPTY" + wasi::ERRNO_NOTEMPTY ); // Try renaming dir to a file - assert_eq!( + assert_errno!( wasi::path_rename(dir_fd, "source", dir_fd, "target/file") .expect_err("renaming a directory to a file") .raw_error(), - wasi::ERRNO_NOTDIR, - "errno should be ERRNO_NOTDIR" + wasi::ERRNO_NOTDIR ); wasi::path_unlink_file(dir_fd, "target/file").expect("removing a file"); @@ -88,12 +84,11 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) { wasi::path_rename(dir_fd, "source", dir_fd, "target").expect("renaming a file"); // Check that source file doesn't exist anymore - assert_eq!( + assert_errno!( wasi::path_open(dir_fd, 0, "source", 0, 0, 0, 0) .expect_err("opening a nonexistent path should fail") .raw_error(), - wasi::ERRNO_NOENT, - "errno should be ERRNO_NOENT" + wasi::ERRNO_NOENT ); // Check that target file exists @@ -115,12 +110,11 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) { .expect("renaming file to another existing file"); // Check that source file doesn't exist anymore - assert_eq!( + assert_errno!( wasi::path_open(dir_fd, 0, "source", 0, 0, 0, 0) .expect_err("opening a nonexistent path") .raw_error(), - wasi::ERRNO_NOENT, - "errno should be ERRNO_NOENT" + wasi::ERRNO_NOENT ); // Check that target file exists @@ -139,12 +133,11 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) { create_file(dir_fd, "source"); wasi::path_create_directory(dir_fd, "target").expect("creating a directory"); - assert_eq!( + assert_errno!( wasi::path_rename(dir_fd, "source", dir_fd, "target") .expect_err("renaming a file to existing directory should fail") .raw_error(), - wasi::ERRNO_ISDIR, - "errno should be ERRNO_ISDIR" + wasi::ERRNO_ISDIR ); wasi::path_remove_directory(dir_fd, "target").expect("removing 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 9d22f4d0c0..67c6796098 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 @@ -1,5 +1,5 @@ use std::{env, process}; -use wasi_tests::{create_file, open_scratch_directory}; +use wasi_tests::{assert_errno, create_file, open_scratch_directory}; unsafe fn test_path_rename_trailing_slashes(dir_fd: wasi::Fd) { // Test renaming a file with a trailing slash in the name. @@ -9,26 +9,23 @@ unsafe fn test_path_rename_trailing_slashes(dir_fd: wasi::Fd) { .expect("no trailing slashes rename works"); wasi::path_rename(dir_fd, "target", dir_fd, "source").expect("rename it back to source"); - assert_eq!( + assert_errno!( 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, - "errno should be ERRNO_NOTDIR" ); - assert_eq!( + 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, - "errno should be ERRNO_NOTDIR" ); - assert_eq!( + 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, - "errno should be 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 0b285c3d56..748b8bd95d 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 @@ -1,15 +1,14 @@ use std::{env, process}; -use wasi_tests::{create_file, open_scratch_directory}; +use wasi_tests::{assert_errno, create_file, open_scratch_directory}; unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) { // XXX following section invalid on windows because its a dangling symlink // Dangling symlink: Link destination shouldn't end with a slash. - assert_eq!( + assert_errno!( wasi::path_symlink("source", dir_fd, "target/") .expect_err("link destination ending with a slash should fail") .raw_error(), wasi::ERRNO_NOENT, - "errno should be ERRNO_NOENT" ); // Dangling symlink: Without the trailing slash, this should succeed. @@ -19,24 +18,22 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) { // Link destination already exists, target has trailing slash. wasi::path_create_directory(dir_fd, "target").expect("creating a directory"); // XXX windows gives NOENT - assert_eq!( + assert_errno!( wasi::path_symlink("source", dir_fd, "target/") .expect_err("link destination already exists") .raw_error(), wasi::ERRNO_EXIST, - "errno should be ERRNO_EXIST" ); wasi::path_remove_directory(dir_fd, "target").expect("removing a directory"); // Link destination already exists, target has no trailing slash. wasi::path_create_directory(dir_fd, "target").expect("creating a directory"); // XXX windows gives NOENT - assert_eq!( + assert_errno!( wasi::path_symlink("source", dir_fd, "target") .expect_err("link destination already exists") .raw_error(), wasi::ERRNO_EXIST, - "errno should be ERRNO_EXIST" ); wasi::path_remove_directory(dir_fd, "target").expect("removing a directory"); @@ -44,13 +41,12 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) { create_file(dir_fd, "target"); // XXX windows gives NOENT - let dir_symlink_errno = wasi::path_symlink("source", dir_fd, "target/") - .expect_err("link destination already exists") - .raw_error(); - assert!( - dir_symlink_errno == wasi::ERRNO_EXIST || dir_symlink_errno == wasi::ERRNO_NOTDIR, - "errno should be ERRNO_EXIST or ERRNO_NOTDIR, got {}", - dir_symlink_errno + assert_errno!( + wasi::path_symlink("source", dir_fd, "target/") + .expect_err("link destination already exists") + .raw_error(), + wasi::ERRNO_EXIST, + wasi::ERRNO_NOTDIR, ); wasi::path_unlink_file(dir_fd, "target").expect("removing a file"); @@ -58,12 +54,11 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) { create_file(dir_fd, "target"); // XXX windows gives NOENT - assert_eq!( + assert_errno!( wasi::path_symlink("source", dir_fd, "target") .expect_err("link destination already exists") .raw_error(), wasi::ERRNO_EXIST, - "errno should be 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 ec6668566a..2b1df93644 100644 --- a/crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs +++ b/crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs @@ -1,6 +1,6 @@ use more_asserts::assert_gt; use std::{env, mem::MaybeUninit, process}; -use wasi_tests::open_scratch_directory; +use wasi_tests::{assert_errno, open_scratch_directory}; const CLOCK_ID: wasi::Userdata = 0x0123_45678; @@ -17,12 +17,11 @@ unsafe fn poll_oneoff_impl(r#in: &[wasi::Subscription]) -> Result = Vec::new(); - let error = wasi::poll_oneoff(r#in.as_ptr(), out.as_mut_ptr(), r#in.len()) - .expect_err("empty poll_oneoff should fail"); - assert_eq!( - error.raw_error(), + assert_errno!( + 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, - "error should be EINVAL" ); } @@ -43,11 +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_eq!( - event.error, - wasi::ERRNO_SUCCESS, - "the event.error should be set to ESUCCESS" - ); + assert_errno!(event.error, wasi::ERRNO_SUCCESS,); assert_eq!( event.r#type, wasi::EVENTTYPE_CLOCK, @@ -89,11 +84,7 @@ unsafe fn test_fd_readwrite(fd: wasi::Fd, error_code: wasi::Errno) { out[0].userdata, 1, "the event.userdata should contain fd userdata specified by the user" ); - assert_eq!( - out[0].error, error_code, - "the event.error should be set to {}", - error_code - ); + assert_errno!(out[0].error, error_code); assert_eq!( out[0].r#type, wasi::EVENTTYPE_FD_READ, @@ -103,11 +94,7 @@ unsafe fn test_fd_readwrite(fd: wasi::Fd, error_code: wasi::Errno) { out[1].userdata, 2, "the event.userdata should contain fd userdata specified by the user" ); - assert_eq!( - out[1].error, error_code, - "the event.error should be set to {}", - error_code - ); + assert_errno!(out[1].error, error_code); assert_eq!( out[1].r#type, wasi::EVENTTYPE_FD_WRITE, diff --git a/crates/test-programs/wasi-tests/src/bin/poll_oneoff_stdio.rs b/crates/test-programs/wasi-tests/src/bin/poll_oneoff_stdio.rs index 44caa47593..6a007c41ff 100644 --- a/crates/test-programs/wasi-tests/src/bin/poll_oneoff_stdio.rs +++ b/crates/test-programs/wasi-tests/src/bin/poll_oneoff_stdio.rs @@ -1,5 +1,5 @@ use std::mem::MaybeUninit; -use wasi_tests::{STDERR_FD, STDIN_FD, STDOUT_FD}; +use wasi_tests::{assert_errno, STDERR_FD, STDIN_FD, STDOUT_FD}; const CLOCK_ID: wasi::Userdata = 0x0123_45678; @@ -45,11 +45,7 @@ unsafe fn test_stdin_read() { let out = poll_oneoff_impl(&r#in).unwrap(); assert_eq!(out.len(), 1, "should return 1 event"); let event = &out[0]; - assert_eq!( - event.error, - wasi::ERRNO_SUCCESS, - "the event.error should be set to ESUCCESS" - ); + assert_errno!(event.error, wasi::ERRNO_SUCCESS); assert_eq!( event.r#type, wasi::EVENTTYPE_CLOCK, @@ -94,11 +90,7 @@ unsafe fn test_stdout_stderr_write() { out[0].userdata, 1, "the event.userdata should contain fd userdata specified by the user" ); - assert_eq!( - out[0].error, - wasi::ERRNO_SUCCESS, - "the event.error should be set to ERRNO_SUCCESS", - ); + assert_errno!(out[0].error, wasi::ERRNO_SUCCESS); assert_eq!( out[0].r#type, wasi::EVENTTYPE_FD_WRITE, @@ -108,11 +100,7 @@ unsafe fn test_stdout_stderr_write() { out[1].userdata, 2, "the event.userdata should contain fd userdata specified by the user" ); - assert_eq!( - out[1].error, - wasi::ERRNO_SUCCESS, - "the event.error should be set to ERRNO_SUCCESS", - ); + assert_errno!(out[1].error, wasi::ERRNO_SUCCESS); assert_eq!( out[1].r#type, wasi::EVENTTYPE_FD_WRITE, diff --git a/crates/test-programs/wasi-tests/src/bin/readlink.rs b/crates/test-programs/wasi-tests/src/bin/readlink.rs index c9c128286e..81fa33188d 100644 --- a/crates/test-programs/wasi-tests/src/bin/readlink.rs +++ b/crates/test-programs/wasi-tests/src/bin/readlink.rs @@ -1,5 +1,5 @@ use std::{env, process}; -use wasi_tests::{create_file, open_scratch_directory}; +use wasi_tests::{assert_errno, create_file, open_scratch_directory}; unsafe fn test_readlink(dir_fd: wasi::Fd) { // Create a file in the scratch directory. @@ -25,11 +25,7 @@ unsafe fn test_readlink(dir_fd: wasi::Fd) { let err = wasi::path_readlink(dir_fd, "symlink", buf.as_mut_ptr(), buf.len()) .err() .expect("readlink with too-small buffer should fail"); - assert_eq!( - err.raw_error(), - wasi::ERRNO_RANGE, - "readlink with too-small buffer should give ERANGE" - ); + assert_errno!(err.raw_error(), wasi::ERRNO_RANGE); // Clean up. wasi::path_unlink_file(dir_fd, "target").expect("removing a file"); 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 014d886d5b..1a5a1dd68a 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 @@ -1,5 +1,5 @@ use std::{env, process}; -use wasi_tests::{create_file, open_scratch_directory}; +use wasi_tests::{assert_errno, create_file, open_scratch_directory}; unsafe fn test_remove_directory_trailing_slashes(dir_fd: wasi::Fd) { // Create a directory in the scratch directory. @@ -21,22 +21,20 @@ unsafe fn test_remove_directory_trailing_slashes(dir_fd: wasi::Fd) { create_file(dir_fd, "file"); // Test that removing it with no trailing slash fails. - assert_eq!( + assert_errno!( 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, - "errno should be ERRNO_NOTDIR" ); // Test that removing it with a trailing slash fails. // XXX windows behavior here is NOENT instead of NOTDIR - assert_eq!( + assert_errno!( 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, - "errno should be ERRNO_NOTDIR" ); wasi::path_unlink_file(dir_fd, "file").expect("removing a file"); diff --git a/crates/test-programs/wasi-tests/src/bin/remove_nonempty_directory.rs b/crates/test-programs/wasi-tests/src/bin/remove_nonempty_directory.rs index daff21c2da..19488e748d 100644 --- a/crates/test-programs/wasi-tests/src/bin/remove_nonempty_directory.rs +++ b/crates/test-programs/wasi-tests/src/bin/remove_nonempty_directory.rs @@ -1,5 +1,5 @@ use std::{env, process}; -use wasi_tests::open_scratch_directory; +use wasi_tests::{assert_errno, open_scratch_directory}; unsafe fn test_remove_nonempty_directory(dir_fd: wasi::Fd) { // Create a directory in the scratch directory. @@ -9,12 +9,11 @@ unsafe fn test_remove_nonempty_directory(dir_fd: wasi::Fd) { wasi::path_create_directory(dir_fd, "dir/nested").expect("creating a subdirectory"); // Test that attempting to unlink the first directory returns the expected error code. - assert_eq!( + assert_errno!( wasi::path_remove_directory(dir_fd, "dir") .expect_err("remove_directory on a directory should return ENOTEMPTY") .raw_error(), - wasi::ERRNO_NOTEMPTY, - "errno should be ERRNO_NOTEMPTY", + wasi::ERRNO_NOTEMPTY ); // Removing the directories. diff --git a/crates/test-programs/wasi-tests/src/bin/renumber.rs b/crates/test-programs/wasi-tests/src/bin/renumber.rs index 9e411cdbd6..8f86f83cc5 100644 --- a/crates/test-programs/wasi-tests/src/bin/renumber.rs +++ b/crates/test-programs/wasi-tests/src/bin/renumber.rs @@ -1,6 +1,6 @@ use more_asserts::assert_gt; use std::{env, process}; -use wasi_tests::open_scratch_directory; +use wasi_tests::{assert_errno, open_scratch_directory}; unsafe fn test_renumber(dir_fd: wasi::Fd) { let pre_fd: wasi::Fd = (libc::STDERR_FILENO + 1) as wasi::Fd; @@ -49,12 +49,11 @@ unsafe fn test_renumber(dir_fd: wasi::Fd) { wasi::fd_renumber(fd_from, fd_to).expect("renumbering two descriptors"); // Ensure that fd_from is closed - assert_eq!( + assert_errno!( wasi::fd_close(fd_from) .expect_err("closing already closed file descriptor") .raw_error(), wasi::ERRNO_BADF, - "errno should be ERRNO_BADF" ); // Ensure that fd_to is still open. diff --git a/crates/test-programs/wasi-tests/src/bin/symlink_filestat.rs b/crates/test-programs/wasi-tests/src/bin/symlink_filestat.rs index 2d2cf9a0a6..c2b59221e2 100644 --- a/crates/test-programs/wasi-tests/src/bin/symlink_filestat.rs +++ b/crates/test-programs/wasi-tests/src/bin/symlink_filestat.rs @@ -3,7 +3,7 @@ use std::{env, process}; use wasi_tests::open_scratch_directory; unsafe fn test_path_filestat(dir_fd: wasi::Fd) { - let mut fdstat = wasi::fd_fdstat_get(dir_fd).expect("fd_fdstat_get"); + let fdstat = wasi::fd_fdstat_get(dir_fd).expect("fd_fdstat_get"); assert_ne!( fdstat.fs_rights_base & wasi::RIGHTS_PATH_FILESTAT_GET, 0, 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 6422aad53a..28dd21a1e1 100644 --- a/crates/test-programs/wasi-tests/src/bin/symlink_loop.rs +++ b/crates/test-programs/wasi-tests/src/bin/symlink_loop.rs @@ -1,17 +1,16 @@ use std::{env, process}; -use wasi_tests::open_scratch_directory; +use wasi_tests::{assert_errno, open_scratch_directory}; unsafe fn test_symlink_loop(dir_fd: wasi::Fd) { // Create a self-referencing symlink. wasi::path_symlink("symlink", dir_fd, "symlink").expect("creating a symlink"); // Try to open it. - assert_eq!( + assert_errno!( wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0) .expect_err("opening a self-referencing symlink") .raw_error(), wasi::ERRNO_LOOP, - "errno should be 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 f846370728..13391d6a77 100644 --- a/crates/test-programs/wasi-tests/src/bin/truncation_rights.rs +++ b/crates/test-programs/wasi-tests/src/bin/truncation_rights.rs @@ -1,5 +1,5 @@ use std::{env, process}; -use wasi_tests::{create_file, open_scratch_directory}; +use wasi_tests::{assert_errno, create_file, open_scratch_directory}; unsafe fn test_truncation_rights(dir_fd: wasi::Fd) { // Create a file in the scratch directory. @@ -64,12 +64,11 @@ unsafe fn test_truncation_rights(dir_fd: wasi::Fd) { // Test that we can't truncate the file without the // wasi_unstable::RIGHT_PATH_FILESTAT_SET_SIZE right. - assert_eq!( + assert_errno!( 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, - "errno should be 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 72b738cb7a..0079176cd6 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 @@ -1,5 +1,5 @@ use std::{env, process}; -use wasi_tests::{create_file, open_scratch_directory}; +use wasi_tests::{assert_errno, create_file, open_scratch_directory}; unsafe fn test_unlink_file_trailing_slashes(dir_fd: wasi::Fd) { // Create a directory in the scratch directory. @@ -7,22 +7,20 @@ unsafe fn test_unlink_file_trailing_slashes(dir_fd: wasi::Fd) { // Test that unlinking it fails. // XXX windows errno here is ACCES - assert_eq!( + assert_errno!( wasi::path_unlink_file(dir_fd, "dir") .expect_err("unlink_file on a directory should fail") .raw_error(), wasi::ERRNO_ISDIR, - "errno should be ERRNO_ISDIR" ); // Test that unlinking it with a trailing flash fails. // XXX windows errno here is ACCES - assert_eq!( + assert_errno!( wasi::path_unlink_file(dir_fd, "dir/") .expect_err("unlink_file on a directory should fail") .raw_error(), wasi::ERRNO_ISDIR, - "errno should be ERRNO_ISDIR" ); // Clean up. @@ -33,12 +31,11 @@ unsafe fn test_unlink_file_trailing_slashes(dir_fd: wasi::Fd) { // Test that unlinking it with a trailing flash fails. // XXX windows errno here is NOENT - assert_eq!( + assert_errno!( wasi::path_unlink_file(dir_fd, "file/") .expect_err("unlink_file with a trailing slash should fail") .raw_error(), wasi::ERRNO_NOTDIR, - "errno should be ERRNO_NOTDIR" ); // Test that unlinking it with no trailing flash succeeds.