ios unit test cleanup

This commit is contained in:
John Smith
2022-01-31 08:52:11 -05:00
parent 4bdcbbdec9
commit cc328d30fa
9 changed files with 751 additions and 555 deletions

View File

@@ -11,7 +11,7 @@ crate-type = ["cdylib", "staticlib", "rlib"]
[features]
android_tests = []
ios_tests = []
ios_tests = [ "simplelog", "backtrace" ]
[dependencies]
capnp = { version = "^0", default_features = false }
@@ -126,14 +126,10 @@ rtnetlink = { version = "^0", default-features = false, features = [ "smol_socke
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "^0", features = [ "iptypes", "iphlpapi" ] }
# Dependencies for MacOS and iOS
#[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
# XXX
# Dependencies for iOS
[target.'cfg(target_os = "ios")'.dependencies]
simplelog = { version = "^0" }
backtrace = { version = "^0" }
simplelog = { version = "^0", optional = true }
backtrace = { version = "^0", optional = true }
# Rusqlite configuration to ensure platforms that don't come with sqlite get it bundled
# Except WASM which doesn't use sqlite

View File

@@ -25,8 +25,20 @@ do
echo Unsupported ARCH: $arch
continue
fi
HOMEBREW_DIR=$(dirname `which brew`)
CARGO_DIR=$(dirname `which cargo`)
env -i PATH=/usr/bin:/bin:/usr/local/bin:$HOMEBREW_DIR:$CARGO_DIR HOME="$HOME" USER="$USER" cargo $CARGO_TOOLCHAIN build $EXTRA_CARGO_OPTIONS --target $CARGO_TARGET --manifest-path $CARGO_MANIFEST_PATH
CARGO=`which cargo`
CARGO=${CARGO:=~/.cargo/bin/cargo}
CARGO_DIR=$(dirname $CARGO)
# Choose arm64 brew for unit tests by default if we are on M1
if [ -f /opt/homebrew/bin/brew ]; then
HOMEBREW_DIR=/opt/homebrew/bin
elif [ -f /usr/local/bin/brew ]; then
HOMEBREW_DIR=/usr/local/bin
else
HOMEBREW_DIR=$(dirname `which brew`)
fi
env -i PATH=/usr/bin:/bin:$HOMEBREW_DIR:$CARGO_DIR HOME="$HOME" USER="$USER" cargo $CARGO_TOOLCHAIN build $EXTRA_CARGO_OPTIONS --target $CARGO_TARGET --manifest-path $CARGO_MANIFEST_PATH
done

View File

@@ -1,29 +1,22 @@
use crate::xx::*;
use backtrace::Backtrace;
use lazy_static::*;
use log::*;
use simplelog::*;
use std::fs::OpenOptions;
use std::panic;
use std::path::{Path, PathBuf};
pub struct IOSGlobals {}
lazy_static! {
pub static ref IOS_GLOBALS: Arc<Mutex<Option<IOSGlobals>>> = Arc::new(Mutex::new(None));
}
pub fn veilid_core_setup_ios<'a>(
pub fn veilid_core_setup<'a>(
log_tag: &'a str,
terminal_log: Option<Level>,
file_log: Option<(Level, &Path)>,
) {
if let Err(e) = veilid_core_setup_ios_internal(log_tag, terminal_log, file_log) {
if let Err(e) = veilid_core_setup_internal(log_tag, terminal_log, file_log) {
panic!("failed to set up veilid-core: {}", e);
}
}
fn veilid_core_setup_ios_internal<'a>(
fn veilid_core_setup_internal<'a>(
_log_tag: &'a str,
terminal_log: Option<Level>,
file_log: Option<(Level, &Path)>,
@@ -94,6 +87,5 @@ fn veilid_core_setup_ios_internal<'a>(
error!("Backtrace:\n{:?}", bt);
}));
*IOS_GLOBALS.lock() = Some(IOSGlobals {});
Ok(())
}

View File

@@ -1,5 +1,5 @@
#[cfg(target_os = "android")]
pub mod android;
#[cfg(target_os = "ios")]
pub mod ios;
pub mod ios_test_setup;
pub mod network_interfaces;

View File

@@ -31,7 +31,7 @@ pub extern "C" fn run_veilid_core_tests() {
]
.iter()
.collect();
crate::intf::utils::ios::veilid_core_setup_ios(
crate::intf::utils::ios_test_setup::veilid_core_setup(
"veilid-core",
Some(Level::Trace),
Some((Level::Trace, log_path.as_path())),