Files
wasmtime/crates/test-programs/wasi-tests/src/config.rs
Pat Hickey 9ee613a0b7 wasi-common: deprecate fd_allocate (#6217)
* wasi-common: remove allocate from WasiFile trait, always fail with NOTSUP

This operation from cloudabi is linux-specific, isn't even
supported across all linux filesystems, and has no support on macos
or windows. Rather than ship spotty support, it has been removed
from preview 2, and we are no longer supporting it in preview 1 as
well.

The preview 1 implementation will still check if fd is a file, and has
rights, just to reject those cases with the errors expected.

* wasi-tests: expect fd_allocate to always fail now.

rewrite the file_allocate test to just check for failure.

remove use of fd_allocate from fd_advise test, and remove test
configuration setting used for excluding use of fd_allocate on macos and
windows.
2023-04-17 21:35:28 +00:00

64 lines
1.8 KiB
Rust

pub struct TestConfig {
errno_mode: ErrnoMode,
no_dangling_filesystem: bool,
no_rename_dir_to_empty_dir: bool,
no_fdflags_sync_support: bool,
}
enum ErrnoMode {
Unix,
MacOS,
Windows,
Permissive,
}
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 {
ErrnoMode::Permissive
};
let no_dangling_filesystem = std::env::var("NO_DANGLING_FILESYSTEM").is_ok();
let no_rename_dir_to_empty_dir = std::env::var("NO_RENAME_DIR_TO_EMPTY_DIR").is_ok();
let no_fdflags_sync_support = std::env::var("NO_FDFLAGS_SYNC_SUPPORT").is_ok();
TestConfig {
errno_mode,
no_dangling_filesystem,
no_rename_dir_to_empty_dir,
no_fdflags_sync_support,
}
}
pub fn errno_expect_unix(&self) -> bool {
match self.errno_mode {
ErrnoMode::Unix | ErrnoMode::MacOS => true,
_ => false,
}
}
pub fn errno_expect_macos(&self) -> bool {
match self.errno_mode {
ErrnoMode::MacOS => true,
_ => false,
}
}
pub fn errno_expect_windows(&self) -> bool {
match self.errno_mode {
ErrnoMode::Windows => true,
_ => false,
}
}
pub fn support_dangling_filesystem(&self) -> bool {
!self.no_dangling_filesystem
}
pub fn support_rename_dir_to_empty_dir(&self) -> bool {
!self.no_rename_dir_to_empty_dir
}
pub fn support_fdflags_sync(&self) -> bool {
!self.no_fdflags_sync_support
}
}