diff --git a/crates/test-programs/tests/wasm_tests/runtime/cap_std_sync.rs b/crates/test-programs/tests/wasm_tests/runtime/cap_std_sync.rs index f969218b07..63984b4236 100644 --- a/crates/test-programs/tests/wasm_tests/runtime/cap_std_sync.rs +++ b/crates/test-programs/tests/wasm_tests/runtime/cap_std_sync.rs @@ -37,10 +37,16 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any .env("NO_RENAME_DIR_TO_EMPTY_DIR", "1")? .env("NO_DANGLING_DIRECTORY", "1")?; } - #[cfg(unix)] + #[cfg(all(unix, not(target_os = "macos")))] { builder = builder.env("ERRNO_MODE_UNIX", "1")?; } + #[cfg(target_os = "macos")] + { + builder = builder + .env("ERRNO_MODE_MACOS", "1")? + .env("NO_FD_ALLOCATE", "1")?; + } // cap-std-sync does not yet support the sync family of fdflags builder = builder.env("NO_FDFLAGS_SYNC_SUPPORT", "1")?; 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 ce1eeee0f2..2ca485dc15 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 @@ -10,6 +10,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(), + macos => wasi::ERRNO_PERM, unix => wasi::ERRNO_ISDIR, windows => wasi::ERRNO_ACCES ); diff --git a/crates/test-programs/wasi-tests/src/config.rs b/crates/test-programs/wasi-tests/src/config.rs index 8bb77e6aee..eb8a7e52fd 100644 --- a/crates/test-programs/wasi-tests/src/config.rs +++ b/crates/test-programs/wasi-tests/src/config.rs @@ -9,6 +9,7 @@ pub struct TestConfig { enum ErrnoMode { Unix, + MacOS, Windows, Permissive, } @@ -17,6 +18,8 @@ impl TestConfig { pub fn from_env() -> Self { let errno_mode = if std::env::var("ERRNO_MODE_UNIX").is_ok() { ErrnoMode::Unix + } else if std::env::var("ERRNO_MODE_MACOS").is_ok() { + ErrnoMode::MacOS } else if std::env::var("ERRNO_MODE_WINDOWS").is_ok() { ErrnoMode::Windows } else { @@ -38,7 +41,13 @@ impl TestConfig { } pub fn errno_expect_unix(&self) -> bool { match self.errno_mode { - ErrnoMode::Unix => true, + ErrnoMode::Unix | ErrnoMode::MacOS => true, + _ => false, + } + } + pub fn errno_expect_macos(&self) -> bool { + match self.errno_mode { + ErrnoMode::MacOS => true, _ => false, } } diff --git a/crates/test-programs/wasi-tests/src/lib.rs b/crates/test-programs/wasi-tests/src/lib.rs index 5507f470ee..ee2ec88488 100644 --- a/crates/test-programs/wasi-tests/src/lib.rs +++ b/crates/test-programs/wasi-tests/src/lib.rs @@ -77,6 +77,14 @@ macro_rules! assert_errno { assert_errno!(e, $($rest)+, $i); } }; + ($s:expr, macos => $i:expr, $( $rest:tt )+) => { + let e = $s; + if $crate::TESTCONFIG.errno_expect_macos() { + assert_errno!(e, $i); + } else { + assert_errno!(e, $($rest)+, $i); + } + }; ($s:expr, unix => $i:expr, $( $rest:tt )+) => { let e = $s; if $crate::TESTCONFIG.errno_expect_unix() {