wire env variables through test runner to TESTCONFIG

This commit is contained in:
Pat Hickey
2021-01-28 11:34:18 -08:00
parent bbbe168ca1
commit e758318fee
3 changed files with 19 additions and 7 deletions

View File

@@ -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,
}
}

View File

@@ -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);