wire env variables through test runner to TESTCONFIG
This commit is contained in:
@@ -28,6 +28,18 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any
|
||||
builder = builder.preopened_dir(preopen_dir, ".")?;
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
builder = builder
|
||||
.env("ERRNO_MODE_WINDOWS", "1")?
|
||||
.env("NO_DANGLING_SYMLINKS", "1")?
|
||||
.env("NO_FD_ALLOCATE", "1")?;
|
||||
}
|
||||
#[cfg(unix)]
|
||||
{
|
||||
builder = builder.env("ERRNO_MODE_UNIX", "1")?;
|
||||
}
|
||||
|
||||
let snapshot1 = wasi_c2_wasmtime::Wasi::new(&store, builder.build()?);
|
||||
|
||||
let mut linker = Linker::new(&store);
|
||||
|
||||
@@ -5,15 +5,15 @@ pub struct TestConfig {
|
||||
}
|
||||
|
||||
enum ErrnoMode {
|
||||
Linux,
|
||||
Unix,
|
||||
Windows,
|
||||
Permissive,
|
||||
}
|
||||
|
||||
impl TestConfig {
|
||||
pub fn from_env() -> Self {
|
||||
let errno_mode = if std::env::var("ERRNO_MODE_LINUX").is_ok() {
|
||||
ErrnoMode::Linux
|
||||
let errno_mode = if std::env::var("ERRNO_MODE_UNIX").is_ok() {
|
||||
ErrnoMode::Unix
|
||||
} else if std::env::var("ERRNO_MODE_WINDOWS").is_ok() {
|
||||
ErrnoMode::Windows
|
||||
} else {
|
||||
@@ -27,9 +27,9 @@ impl TestConfig {
|
||||
no_fd_allocate,
|
||||
}
|
||||
}
|
||||
pub fn errno_expect_linux(&self) -> bool {
|
||||
pub fn errno_expect_unix(&self) -> bool {
|
||||
match self.errno_mode {
|
||||
ErrnoMode::Linux => true,
|
||||
ErrnoMode::Unix => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ macro_rules! assert_errno {
|
||||
assert_errno!(e, $($rest),+, $i);
|
||||
}
|
||||
};
|
||||
($s:expr, linux => $i:expr, $( $rest:expr ),+) => {
|
||||
($s:expr, unix => $i:expr, $( $rest:expr ),+) => {
|
||||
let e = $s;
|
||||
if $crate::TESTCONFIG.errno_expect_linux() {
|
||||
if $crate::TESTCONFIG.errno_expect_unix() {
|
||||
assert_errno!(e, $i);
|
||||
} else {
|
||||
assert_errno!(e, $($rest),+, $i);
|
||||
|
||||
Reference in New Issue
Block a user