diff --git a/Cargo.lock b/Cargo.lock index a66192cd..b754585c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5759,7 +5759,7 @@ dependencies = [ "rand 0.7.3", "send_wrapper 0.6.0", "serial_test", - "simplelog 0.9.0", + "simplelog 0.12.0", "static_assertions", "stop-token", "thiserror", @@ -5767,6 +5767,7 @@ dependencies = [ "tokio-util", "tracing", "tracing-android", + "tracing-subscriber", "tracing-wasm", "wasm-bindgen", "wasm-bindgen-futures", diff --git a/veilid-core/src/intf/native/utils/android/mod.rs b/veilid-core/src/intf/native/utils/android/mod.rs index d7bdd15b..a6e3097a 100644 --- a/veilid-core/src/intf/native/utils/android/mod.rs +++ b/veilid-core/src/intf/native/utils/android/mod.rs @@ -46,22 +46,23 @@ pub fn veilid_core_setup_android<'a>( log_tag: &'a str, log_level: VeilidConfigLogLevel, ) { - // Set up subscriber and layers - let subscriber = Registry::default(); - let mut layers = Vec::new(); - let mut filters = BTreeMap::new(); - let filter = VeilidLayerFilter::new(log_level, None); - let layer = tracing_android::layer(log_tag) - .expect("failed to set up android logging") - .with_filter(filter.clone()); - filters.insert("system", filter); - layers.push(layer.boxed()); - - let subscriber = subscriber.with(layers); - subscriber - .try_init() - .expect("failed to init android tracing"); + cfg_if! { + if #[cfg(feature = "tracing")] { + // Set up subscriber and layers + let subscriber = Registry::default(); + let mut layers = Vec::new(); + let filter = VeilidLayerFilter::new(log_level, None); + let layer = tracing_android::layer(log_tag) + .expect("failed to set up android logging") + .with_filter(filter.clone()); + layers.push(layer.boxed()); + let subscriber = subscriber.with(layers); + subscriber + .try_init() + .expect("failed to init android tracing"); + } + } // Set up panic hook for backtraces panic::set_hook(Box::new(|panic_info| { let bt = Backtrace::new(); diff --git a/veilid-core/src/intf/native/utils/ios_test_setup.rs b/veilid-core/src/intf/native/utils/ios/mod.rs similarity index 100% rename from veilid-core/src/intf/native/utils/ios_test_setup.rs rename to veilid-core/src/intf/native/utils/ios/mod.rs diff --git a/veilid-core/tests/node.rs b/veilid-core/tests/node.rs deleted file mode 100644 index da301eeb..00000000 --- a/veilid-core/tests/node.rs +++ /dev/null @@ -1,83 +0,0 @@ -//! Test suite for NodeJS -#![cfg(target_arch = "wasm32")] - -use veilid_core::tests::common::*; -use veilid_core::xx::*; -use wasm_bindgen_test::*; - -wasm_bindgen_test_configure!(); - -extern crate wee_alloc; -#[global_allocator] -static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; - -static SETUP_ONCE: Once = Once::new(); -pub fn setup() -> () { - SETUP_ONCE.call_once(|| { - console_error_panic_hook::set_once(); - wasm_logger::init(wasm_logger::Config::new(log::Level::Trace)); - }); -} - -#[wasm_bindgen_test] -async fn run_test_dht_key() { - setup(); - - test_dht_key::test_all().await; -} - -#[wasm_bindgen_test] -async fn run_test_host_interface() { - setup(); - - test_host_interface::test_all().await; -} - -#[wasm_bindgen_test] -async fn run_test_veilid_core() { - setup(); - - test_veilid_core::test_all().await; -} - -#[wasm_bindgen_test] -async fn run_test_config() { - setup(); - - test_veilid_config::test_all().await; -} - -#[wasm_bindgen_test] -async fn run_test_connection_table() { - setup(); - - test_connection_table::test_all().await; -} - -#[wasm_bindgen_test] -async fn run_test_table_store() { - setup(); - - test_table_store::test_all().await; -} - -#[wasm_bindgen_test] -async fn run_test_crypto() { - setup(); - - test_crypto::test_all().await; -} - -#[wasm_bindgen_test] -async fn run_test_envelope_receipt() { - setup(); - - test_envelope_receipt::test_all().await; -} - -#[wasm_bindgen_test] -async fn run_test_async_tag_lock() { - setup(); - - test_async_tag_lock::test_all().await; -} diff --git a/veilid-tools/Cargo.toml b/veilid-tools/Cargo.toml index 2095866f..05732f9b 100644 --- a/veilid-tools/Cargo.toml +++ b/veilid-tools/Cargo.toml @@ -6,22 +6,23 @@ edition = "2021" license = "LGPL-2.0-or-later OR MPL-2.0 OR (MIT AND BSD-3-Clause)" [lib] -crate-type = ["rlib"] +# Staticlib for iOS tests, rlib for everything else +crate-type = [ "staticlib", "rlib" ] [features] -default = [ "tracing" ] +default = [] rt-async-std = [ "async-std", "async_executors/async_std", ] rt-tokio = [ "tokio", "tokio-util", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer", ] android_tests = [] -ios_tests = [ "simplelog" ] +ios_tests = [] tracking = [] -tracing = [ "dep:tracing" ] -log = [ "dep:log" ] +tracing = [ "dep:tracing", "dep:tracing-subscriber" ] [dependencies] tracing = { version = "^0", features = ["log", "attributes"], optional = true } -log = { version = "^0", optional = true } +tracing-subscriber = { version = "^0", optional = true } +log = { version = "^0" } eyre = "^0" static_assertions = "^1" cfg-if = "^1" @@ -31,7 +32,7 @@ parking_lot = "^0" once_cell = "^1" owo-colors = "^3" stop-token = { version = "^0", default-features = false } -rand = "0.7" +rand = "^0.7" # Dependencies for native builds only # Linux, Windows, Mac, iOS, Android @@ -69,15 +70,13 @@ tracing-android = { version = "^0", optional = true } # Dependencies for iOS [target.'cfg(target_os = "ios")'.dependencies] -simplelog = { version = "^0", optional = true } +simplelog = { version = "^0.12", features = [ "test" ] } ### DEV DEPENDENCIES [dev-dependencies] serial_test = "^0" - -[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] -simplelog = { version = "^0", features=["test"] } +simplelog = { version = "^0.12", features = [ "test" ] } [target.'cfg(target_arch = "wasm32")'.dev-dependencies] console_error_panic_hook = "^0" @@ -91,3 +90,8 @@ parking_lot = { version = "^0", features = ["wasm-bindgen"]} [package.metadata.wasm-pack.profile.release] wasm-opt = ["-O", "--enable-mutable-globals"] + +[package.metadata.ios] +build_targets = ["aarch64-apple-ios", "aarch64-apple-ios-sim", "x86_64-apple-ios"] +deployment_target = "12.0" +build_id_prefix = "com.veilid.veilidtools" diff --git a/veilid-tools/ios_build.sh b/veilid-tools/ios_build.sh index 4eb08eca..c4aea7a4 100755 --- a/veilid-tools/ios_build.sh +++ b/veilid-tools/ios_build.sh @@ -1,20 +1,36 @@ #!/bin/bash SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -CARGO_MANIFEST_PATH=$(python -c "import os; print(os.path.realpath(\"$SCRIPTDIR/Cargo.toml\"))") +CARGO_MANIFEST_PATH=$(python3 -c "import os; print(os.path.realpath(\"$SCRIPTDIR/Cargo.toml\"))") +TARGET_PATH=$(python3 -c "import os; print(os.path.realpath(\"$SCRIPTDIR/../target\"))") +PACKAGE_NAME=$1 +shift # echo CARGO_MANIFEST_PATH: $CARGO_MANIFEST_PATH if [ "$CONFIGURATION" == "Debug" ]; then EXTRA_CARGO_OPTIONS="$@" + BUILD_MODE="debug" else EXTRA_CARGO_OPTIONS="$@ --release" + BUILD_MODE="release" fi ARCHS=${ARCHS:=arm64} + +if [ "$PLATFORM_NAME" == "iphonesimulator" ]; then + LIPO_OUT_NAME="lipo-ios-sim" +else + LIPO_OUT_NAME="lipo-ios" +fi + for arch in $ARCHS do if [ "$arch" == "arm64" ]; then echo arm64 - CARGO_TARGET=aarch64-apple-ios + if [ "$PLATFORM_NAME" == "iphonesimulator" ]; then + CARGO_TARGET=aarch64-apple-ios-sim + else + CARGO_TARGET=aarch64-apple-ios + fi #CARGO_TOOLCHAIN=+ios-arm64-1.57.0 CARGO_TOOLCHAIN= elif [ "$arch" == "x86_64" ]; then @@ -40,5 +56,10 @@ do 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 + + LIPOS="$LIPOS $TARGET_PATH/$CARGO_TARGET/$BUILD_MODE/lib$PACKAGE_NAME.a" + done +mkdir -p "$TARGET_PATH/$LIPO_OUT_NAME/$BUILD_MODE/" +lipo $LIPOS -create -output "$TARGET_PATH/$LIPO_OUT_NAME/$BUILD_MODE/lib$PACKAGE_NAME.a" diff --git a/veilid-tools/run_tests.sh b/veilid-tools/run_tests.sh index 065ec2ed..f53337b2 100755 --- a/veilid-tools/run_tests.sh +++ b/veilid-tools/run_tests.sh @@ -1,9 +1,26 @@ #!/bin/bash +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +pushd $SCRIPTDIR 2>/dev/null if [[ "$1" == "wasm" ]]; then WASM_BINDGEN_TEST_TIMEOUT=120 wasm-pack test --chrome --headless +elif [[ "$1" == "ios" ]]; then + SYMROOT=/tmp/testout + APPNAME=veilidtools-tests + BUNDLENAME=com.veilid.veilidtools-tests + + xcrun xcodebuild -project src/tests/ios/$APPNAME/$APPNAME.xcodeproj/ -scheme $APPNAME -destination "generic/platform=iOS Simulator" SYMROOT=$SYMROOT + ID=$(xcrun simctl create test-iphone com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro com.apple.CoreSimulator.SimRuntime.iOS-16-1 2>/dev/null) + xcrun simctl boot $ID + xcrun simctl bootstatus $ID + xcrun simctl install $ID $SYMROOT/Debug-iphonesimulator/$APPNAME.app + xcrun simctl launch --console $ID $BUNDLENAME + xcrun simctl delete all + rm -rf /tmp/testout else cargo test --features=rt-tokio cargo test --features=rt-async-std cargo test --features=rt-tokio,log --no-default-features cargo test --features=rt-async-std,log --no-default-features fi +popd 2>/dev/null \ No newline at end of file diff --git a/veilid-tools/src/lib.rs b/veilid-tools/src/lib.rs index 0838c00f..0f16316b 100644 --- a/veilid-tools/src/lib.rs +++ b/veilid-tools/src/lib.rs @@ -136,3 +136,10 @@ pub use wasm::*; // Tests must be public for wasm-pack tests pub mod tests; + +// For iOS tests + +#[no_mangle] +pub extern "C" fn main_rs() { + // start game code here +} diff --git a/veilid-tools/src/tests/android/mod.rs b/veilid-tools/src/tests/android/mod.rs new file mode 100644 index 00000000..6fb0ad83 --- /dev/null +++ b/veilid-tools/src/tests/android/mod.rs @@ -0,0 +1,80 @@ +use super::*; + +use jni::errors::Result as JniResult; +use jni::{objects::GlobalRef, objects::JObject, objects::JString, JNIEnv, JavaVM}; +use lazy_static::*; +use std::backtrace::Backtrace; +use std::panic; +use tracing::*; +use tracing_subscriber::prelude::*; +use tracing_subscriber::*; + +pub struct AndroidGlobals { + pub vm: JavaVM, + pub ctx: GlobalRef, +} + +impl Drop for AndroidGlobals { + fn drop(&mut self) { + // Ensure we're attached before dropping GlobalRef + self.vm.attach_current_thread_as_daemon().unwrap(); + } +} + +lazy_static! { + pub static ref ANDROID_GLOBALS: Arc>> = Arc::new(Mutex::new(None)); +} + +pub fn veilid_tools_setup_android_no_log<'a>(env: JNIEnv<'a>, ctx: JObject<'a>) { + *ANDROID_GLOBALS.lock() = Some(AndroidGlobals { + vm: env.get_java_vm().unwrap(), + ctx: env.new_global_ref(ctx).unwrap(), + }); +} + +pub fn veilid_tools_setup<'a>(env: JNIEnv<'a>, ctx: JObject<'a>, log_tag: &'a str) { + cfg_if! { + if #[cfg(feature = "tracing")] { + // Set up subscriber and layers + + let subscriber = Registry::default(); + let mut layers = Vec::new(); + let layer = tracing_android::layer(log_tag) + .expect("failed to set up android logging") + .with_filter(LevelFilter::TRACE); + layers.push(layer.boxed()); + + let subscriber = subscriber.with(layers); + subscriber + .try_init() + .expect("failed to init android tracing"); + } + } + + // Set up panic hook for backtraces + panic::set_hook(Box::new(|panic_info| { + let bt = Backtrace::capture(); + error!("Backtrace:\n{:?}", bt); + })); + + veilid_core_setup_android_no_log(env, ctx); +} + +pub fn get_android_globals() -> (JavaVM, GlobalRef) { + let globals_locked = ANDROID_GLOBALS.lock(); + let globals = globals_locked.as_ref().unwrap(); + let env = globals.vm.attach_current_thread_as_daemon().unwrap(); + let vm = env.get_java_vm().unwrap(); + let ctx = globals.ctx.clone(); + (vm, ctx) +} + +pub fn with_null_local_frame<'b, T, F>(env: JNIEnv<'b>, s: i32, f: F) -> JniResult +where + F: FnOnce() -> JniResult, +{ + env.push_local_frame(s)?; + let out = f(); + env.pop_local_frame(JObject::null())?; + out +} diff --git a/veilid-tools/src/tests/android/.gitignore b/veilid-tools/src/tests/android/veilidtools-tests/.gitignore similarity index 100% rename from veilid-tools/src/tests/android/.gitignore rename to veilid-tools/src/tests/android/veilidtools-tests/.gitignore diff --git a/veilid-tools/src/tests/android/.idea/.gitignore b/veilid-tools/src/tests/android/veilidtools-tests/.idea/.gitignore similarity index 100% rename from veilid-tools/src/tests/android/.idea/.gitignore rename to veilid-tools/src/tests/android/veilidtools-tests/.idea/.gitignore diff --git a/veilid-tools/src/tests/android/.idea/.name b/veilid-tools/src/tests/android/veilidtools-tests/.idea/.name similarity index 100% rename from veilid-tools/src/tests/android/.idea/.name rename to veilid-tools/src/tests/android/veilidtools-tests/.idea/.name diff --git a/veilid-tools/src/tests/android/.idea/compiler.xml b/veilid-tools/src/tests/android/veilidtools-tests/.idea/compiler.xml similarity index 100% rename from veilid-tools/src/tests/android/.idea/compiler.xml rename to veilid-tools/src/tests/android/veilidtools-tests/.idea/compiler.xml diff --git a/veilid-tools/src/tests/android/.idea/gradle.xml b/veilid-tools/src/tests/android/veilidtools-tests/.idea/gradle.xml similarity index 100% rename from veilid-tools/src/tests/android/.idea/gradle.xml rename to veilid-tools/src/tests/android/veilidtools-tests/.idea/gradle.xml diff --git a/veilid-tools/src/tests/android/.idea/jarRepositories.xml b/veilid-tools/src/tests/android/veilidtools-tests/.idea/jarRepositories.xml similarity index 100% rename from veilid-tools/src/tests/android/.idea/jarRepositories.xml rename to veilid-tools/src/tests/android/veilidtools-tests/.idea/jarRepositories.xml diff --git a/veilid-tools/src/tests/android/.idea/misc.xml b/veilid-tools/src/tests/android/veilidtools-tests/.idea/misc.xml similarity index 100% rename from veilid-tools/src/tests/android/.idea/misc.xml rename to veilid-tools/src/tests/android/veilidtools-tests/.idea/misc.xml diff --git a/veilid-tools/src/tests/android/.idea/vcs.xml b/veilid-tools/src/tests/android/veilidtools-tests/.idea/vcs.xml similarity index 100% rename from veilid-tools/src/tests/android/.idea/vcs.xml rename to veilid-tools/src/tests/android/veilidtools-tests/.idea/vcs.xml diff --git a/veilid-tools/src/tests/android/.project b/veilid-tools/src/tests/android/veilidtools-tests/.project similarity index 100% rename from veilid-tools/src/tests/android/.project rename to veilid-tools/src/tests/android/veilidtools-tests/.project diff --git a/veilid-tools/src/tests/android/.settings/org.eclipse.buildship.core.prefs b/veilid-tools/src/tests/android/veilidtools-tests/.settings/org.eclipse.buildship.core.prefs similarity index 100% rename from veilid-tools/src/tests/android/.settings/org.eclipse.buildship.core.prefs rename to veilid-tools/src/tests/android/veilidtools-tests/.settings/org.eclipse.buildship.core.prefs diff --git a/veilid-tools/src/tests/android/adb+.sh b/veilid-tools/src/tests/android/veilidtools-tests/adb+.sh similarity index 100% rename from veilid-tools/src/tests/android/adb+.sh rename to veilid-tools/src/tests/android/veilidtools-tests/adb+.sh diff --git a/veilid-tools/src/tests/android/app/.classpath b/veilid-tools/src/tests/android/veilidtools-tests/app/.classpath similarity index 100% rename from veilid-tools/src/tests/android/app/.classpath rename to veilid-tools/src/tests/android/veilidtools-tests/app/.classpath diff --git a/veilid-tools/src/tests/android/app/.gitignore b/veilid-tools/src/tests/android/veilidtools-tests/app/.gitignore similarity index 100% rename from veilid-tools/src/tests/android/app/.gitignore rename to veilid-tools/src/tests/android/veilidtools-tests/app/.gitignore diff --git a/veilid-tools/src/tests/android/app/.project b/veilid-tools/src/tests/android/veilidtools-tests/app/.project similarity index 100% rename from veilid-tools/src/tests/android/app/.project rename to veilid-tools/src/tests/android/veilidtools-tests/app/.project diff --git a/veilid-tools/src/tests/android/app/.settings/org.eclipse.buildship.core.prefs b/veilid-tools/src/tests/android/veilidtools-tests/app/.settings/org.eclipse.buildship.core.prefs similarity index 100% rename from veilid-tools/src/tests/android/app/.settings/org.eclipse.buildship.core.prefs rename to veilid-tools/src/tests/android/veilidtools-tests/app/.settings/org.eclipse.buildship.core.prefs diff --git a/veilid-tools/src/tests/android/app/CMakeLists.txt b/veilid-tools/src/tests/android/veilidtools-tests/app/CMakeLists.txt similarity index 100% rename from veilid-tools/src/tests/android/app/CMakeLists.txt rename to veilid-tools/src/tests/android/veilidtools-tests/app/CMakeLists.txt diff --git a/veilid-tools/src/tests/android/app/build.gradle b/veilid-tools/src/tests/android/veilidtools-tests/app/build.gradle similarity index 100% rename from veilid-tools/src/tests/android/app/build.gradle rename to veilid-tools/src/tests/android/veilidtools-tests/app/build.gradle diff --git a/veilid-tools/src/tests/android/app/cpplink.cpp b/veilid-tools/src/tests/android/veilidtools-tests/app/cpplink.cpp similarity index 100% rename from veilid-tools/src/tests/android/app/cpplink.cpp rename to veilid-tools/src/tests/android/veilidtools-tests/app/cpplink.cpp diff --git a/veilid-tools/src/tests/android/app/proguard-rules.pro b/veilid-tools/src/tests/android/veilidtools-tests/app/proguard-rules.pro similarity index 100% rename from veilid-tools/src/tests/android/app/proguard-rules.pro rename to veilid-tools/src/tests/android/veilidtools-tests/app/proguard-rules.pro diff --git a/veilid-tools/src/tests/android/app/src/main/AndroidManifest.xml b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/AndroidManifest.xml similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/AndroidManifest.xml rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/AndroidManifest.xml diff --git a/veilid-tools/src/tests/android/app/src/main/java/com/veilid/veilid-core/veilid-core_android_tests/MainActivity.java b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/java/com/veilid/veilid-core/veilid-core_android_tests/MainActivity.java similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/java/com/veilid/veilid-core/veilid-core_android_tests/MainActivity.java rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/java/com/veilid/veilid-core/veilid-core_android_tests/MainActivity.java diff --git a/veilid-tools/src/tests/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/drawable-v24/ic_launcher_foreground.xml similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/drawable-v24/ic_launcher_foreground.xml diff --git a/veilid-tools/src/tests/android/app/src/main/res/drawable/ic_launcher_background.xml b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/drawable/ic_launcher_background.xml rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/drawable/ic_launcher_background.xml diff --git a/veilid-tools/src/tests/android/app/src/main/res/layout/activity_main.xml b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/layout/activity_main.xml similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/layout/activity_main.xml rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/layout/activity_main.xml diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-hdpi/ic_launcher_round.png similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-hdpi/ic_launcher_round.png diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-mdpi/ic_launcher_round.png similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-mdpi/ic_launcher_round.png diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/veilid-tools/src/tests/android/app/src/main/res/values-night/themes.xml b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/values-night/themes.xml similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/values-night/themes.xml rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/values-night/themes.xml diff --git a/veilid-tools/src/tests/android/app/src/main/res/values/colors.xml b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/values/colors.xml similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/values/colors.xml rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/values/colors.xml diff --git a/veilid-tools/src/tests/android/app/src/main/res/values/strings.xml b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/values/strings.xml similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/values/strings.xml rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/values/strings.xml diff --git a/veilid-tools/src/tests/android/app/src/main/res/values/themes.xml b/veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/values/themes.xml similarity index 100% rename from veilid-tools/src/tests/android/app/src/main/res/values/themes.xml rename to veilid-tools/src/tests/android/veilidtools-tests/app/src/main/res/values/themes.xml diff --git a/veilid-tools/src/tests/android/build.gradle b/veilid-tools/src/tests/android/veilidtools-tests/build.gradle similarity index 100% rename from veilid-tools/src/tests/android/build.gradle rename to veilid-tools/src/tests/android/veilidtools-tests/build.gradle diff --git a/veilid-tools/src/tests/android/gradle.properties b/veilid-tools/src/tests/android/veilidtools-tests/gradle.properties similarity index 100% rename from veilid-tools/src/tests/android/gradle.properties rename to veilid-tools/src/tests/android/veilidtools-tests/gradle.properties diff --git a/veilid-tools/src/tests/android/gradle/wrapper/gradle-wrapper.jar b/veilid-tools/src/tests/android/veilidtools-tests/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from veilid-tools/src/tests/android/gradle/wrapper/gradle-wrapper.jar rename to veilid-tools/src/tests/android/veilidtools-tests/gradle/wrapper/gradle-wrapper.jar diff --git a/veilid-tools/src/tests/android/gradle/wrapper/gradle-wrapper.properties b/veilid-tools/src/tests/android/veilidtools-tests/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from veilid-tools/src/tests/android/gradle/wrapper/gradle-wrapper.properties rename to veilid-tools/src/tests/android/veilidtools-tests/gradle/wrapper/gradle-wrapper.properties diff --git a/veilid-tools/src/tests/android/gradlew b/veilid-tools/src/tests/android/veilidtools-tests/gradlew similarity index 100% rename from veilid-tools/src/tests/android/gradlew rename to veilid-tools/src/tests/android/veilidtools-tests/gradlew diff --git a/veilid-tools/src/tests/android/gradlew.bat b/veilid-tools/src/tests/android/veilidtools-tests/gradlew.bat similarity index 100% rename from veilid-tools/src/tests/android/gradlew.bat rename to veilid-tools/src/tests/android/veilidtools-tests/gradlew.bat diff --git a/veilid-tools/src/tests/android/install_on_all_devices.sh b/veilid-tools/src/tests/android/veilidtools-tests/install_on_all_devices.sh similarity index 100% rename from veilid-tools/src/tests/android/install_on_all_devices.sh rename to veilid-tools/src/tests/android/veilidtools-tests/install_on_all_devices.sh diff --git a/veilid-tools/src/tests/android/remove_from_all_devices.sh b/veilid-tools/src/tests/android/veilidtools-tests/remove_from_all_devices.sh similarity index 100% rename from veilid-tools/src/tests/android/remove_from_all_devices.sh rename to veilid-tools/src/tests/android/veilidtools-tests/remove_from_all_devices.sh diff --git a/veilid-tools/src/tests/android/settings.gradle b/veilid-tools/src/tests/android/veilidtools-tests/settings.gradle similarity index 100% rename from veilid-tools/src/tests/android/settings.gradle rename to veilid-tools/src/tests/android/veilidtools-tests/settings.gradle diff --git a/veilid-tools/src/tests/common/mod.rs b/veilid-tools/src/tests/common/mod.rs index 06433eae..393bcfa9 100644 --- a/veilid-tools/src/tests/common/mod.rs +++ b/veilid-tools/src/tests/common/mod.rs @@ -1,2 +1,27 @@ pub mod test_async_tag_lock; pub mod test_host_interface; + +#[allow(dead_code)] +pub static DEFAULT_LOG_IGNORE_LIST: [&str; 21] = [ + "mio", + "h2", + "hyper", + "tower", + "tonic", + "tokio", + "runtime", + "tokio_util", + "want", + "serial_test", + "async_std", + "async_io", + "polling", + "rustls", + "async_tungstenite", + "tungstenite", + "netlink_proto", + "netlink_sys", + "trust_dns_resolver", + "trust_dns_proto", + "attohttpc", +]; diff --git a/veilid-tools/src/tests/ios/mod.rs b/veilid-tools/src/tests/ios/mod.rs new file mode 100644 index 00000000..358955a8 --- /dev/null +++ b/veilid-tools/src/tests/ios/mod.rs @@ -0,0 +1,61 @@ +use super::*; + +use std::backtrace::Backtrace; +use std::panic; + +pub fn veilid_tools_setup<'a>() -> Result<(), String> { + cfg_if! { + if #[cfg(feature = "tracing")] { + use tracing_subscriber::{filter, fmt, prelude::*}; + let mut filters = filter::Targets::new(); + for ig in DEFAULT_LOG_IGNORE_LIST { + filters = filters.with_target(ig, filter::LevelFilter::OFF); + } + let fmt_layer = fmt::layer(); + tracing_subscriber::registry() + .with(filters) + .with(filter::LevelFilter::TRACE) + .with(fmt_layer) + .init(); + } else { + use simplelog::*; + let mut logs: Vec> = Vec::new(); + let mut cb = ConfigBuilder::new(); + for ig in DEFAULT_LOG_IGNORE_LIST { + cb.add_filter_ignore_str(ig); + } + logs.push(TermLogger::new( + LevelFilter::Trace, + cb.build(), + TerminalMode::Mixed, + ColorChoice::Auto, + )); + CombinedLogger::init(logs).map_err(|e| format!("logger init error: {}", e))?; + } + } + + panic::set_hook(Box::new(|panic_info| { + let bt = Backtrace::capture(); + if let Some(location) = panic_info.location() { + error!( + "panic occurred in file '{}' at line {}", + location.file(), + location.line(), + ); + } else { + error!("panic occurred but can't get location information..."); + } + if let Some(s) = panic_info.payload().downcast_ref::<&str>() { + error!("panic payload: {:?}", s); + } else if let Some(s) = panic_info.payload().downcast_ref::() { + error!("panic payload: {:?}", s); + } else if let Some(a) = panic_info.payload().downcast_ref::() { + error!("panic payload: {:?}", a); + } else { + error!("no panic payload"); + } + error!("Backtrace:\n{:?}", bt); + })); + + Ok(()) +} diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/project.pbxproj b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/project.pbxproj index b47f1821..51f168d3 100644 --- a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/project.pbxproj +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/project.pbxproj @@ -7,31 +7,31 @@ objects = { /* Begin PBXBuildFile section */ - 4317C6BD2694A676009C717F /* veilid-tools.c in Sources */ = {isa = PBXBuildFile; fileRef = 4317C6BC2694A676009C717F /* veilid-tools.c */; }; - 43C436B0268904AC002D11C5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C436AF268904AC002D11C5 /* AppDelegate.swift */; }; - 43C436B2268904AC002D11C5 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C436B1268904AC002D11C5 /* SceneDelegate.swift */; }; - 43C436B4268904AC002D11C5 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C436B3268904AC002D11C5 /* ViewController.swift */; }; - 43C436B7268904AC002D11C5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 43C436B5268904AC002D11C5 /* Main.storyboard */; }; - 43C436B9268904AD002D11C5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 43C436B8268904AD002D11C5 /* Assets.xcassets */; }; - 43C436BC268904AD002D11C5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 43C436BA268904AD002D11C5 /* LaunchScreen.storyboard */; }; + 4317C6BD3694A676009C717F /* (null) in Sources */ = {isa = PBXBuildFile; }; + 43C436B0368904AC002D11C5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C436AF368904AC002D11C5 /* AppDelegate.swift */; }; + 43C436B2368904AC002D11C5 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C436B1368904AC002D11C5 /* SceneDelegate.swift */; }; + 43C436B4368904AC002D11C5 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C436B3368904AC002D11C5 /* ViewController.swift */; }; + 43C436B7368904AC002D11C5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 43C436B5368904AC002D11C5 /* Main.storyboard */; }; + 43C436B9368904AD002D11C5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 43C436B8368904AD002D11C5 /* Assets.xcassets */; }; + 43C436BC368904AD002D11C5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 43C436BA368904AD002D11C5 /* LaunchScreen.storyboard */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 4317C6BA2694A675009C717F /* veilidtools-tests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "veilidtools-tests-Bridging-Header.h"; sourceTree = ""; }; - 4317C6BB2694A676009C717F /* veilid-tools.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "veilid-tools.h"; sourceTree = ""; }; - 4317C6BC2694A676009C717F /* veilid-tools.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "veilid-tools.c"; sourceTree = ""; }; - 43C436AC268904AC002D11C5 /* veilidtools-tests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "veilidtools-tests.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - 43C436AF268904AC002D11C5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 43C436B1268904AC002D11C5 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; - 43C436B3268904AC002D11C5 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - 43C436B6268904AC002D11C5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 43C436B8268904AD002D11C5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 43C436BB268904AD002D11C5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 43C436BD268904AD002D11C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 4317C6BA3694A675009C717F /* veilidtools-tests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "veilidtools-tests-Bridging-Header.h"; sourceTree = ""; }; + 4317C6BB3694A676009C717F /* veilid-tools.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "veilid-tools.h"; sourceTree = ""; }; + 4317C6BC3694A676009C717F /* veilid-tools.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "veilid-tools.c"; sourceTree = ""; }; + 43C436AC368904AC002D11C5 /* veilidtools-tests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "veilidtools-tests.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 43C436AF368904AC002D11C5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 43C436B1368904AC002D11C5 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 43C436B3368904AC002D11C5 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 43C436B6368904AC002D11C5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 43C436B8368904AD002D11C5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 43C436BB368904AD002D11C5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 43C436BD368904AD002D11C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 43C436A9268904AC002D11C5 /* Frameworks */ = { + 43C436A9368904AC002D11C5 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( @@ -41,43 +41,43 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 4317C6B7269490DA009C717F /* Frameworks */ = { + 4317C6B7369490DA009C717F /* Frameworks */ = { isa = PBXGroup; children = ( ); name = Frameworks; sourceTree = ""; }; - 43C436A3268904AC002D11C5 = { + 43C436A3368904AC002D11C5 = { isa = PBXGroup; children = ( - 4317C6BB2694A676009C717F /* veilid-tools.h */, - 4317C6BC2694A676009C717F /* veilid-tools.c */, - 43C436AE268904AC002D11C5 /* veilidtools-tests */, - 43C436AD268904AC002D11C5 /* Products */, - 4317C6B7269490DA009C717F /* Frameworks */, - 4317C6BA2694A675009C717F /* veilidtools-tests-Bridging-Header.h */, + 4317C6BB3694A676009C717F /* veilid-tools.h */, + 4317C6BC3694A676009C717F /* veilid-tools.c */, + 43C436AE368904AC002D11C5 /* veilidtools-tests */, + 43C436AD368904AC002D11C5 /* Products */, + 4317C6B7369490DA009C717F /* Frameworks */, + 4317C6BA3694A675009C717F /* veilidtools-tests-Bridging-Header.h */, ); sourceTree = ""; }; - 43C436AD268904AC002D11C5 /* Products */ = { + 43C436AD368904AC002D11C5 /* Products */ = { isa = PBXGroup; children = ( - 43C436AC268904AC002D11C5 /* veilidtools-tests.app */, + 43C436AC368904AC002D11C5 /* veilidtools-tests.app */, ); name = Products; sourceTree = ""; }; - 43C436AE268904AC002D11C5 /* veilidtools-tests */ = { + 43C436AE368904AC002D11C5 /* veilidtools-tests */ = { isa = PBXGroup; children = ( - 43C436AF268904AC002D11C5 /* AppDelegate.swift */, - 43C436B1268904AC002D11C5 /* SceneDelegate.swift */, - 43C436B3268904AC002D11C5 /* ViewController.swift */, - 43C436B5268904AC002D11C5 /* Main.storyboard */, - 43C436B8268904AD002D11C5 /* Assets.xcassets */, - 43C436BA268904AD002D11C5 /* LaunchScreen.storyboard */, - 43C436BD268904AD002D11C5 /* Info.plist */, + 43C436AF368904AC002D11C5 /* AppDelegate.swift */, + 43C436B1368904AC002D11C5 /* SceneDelegate.swift */, + 43C436B3368904AC002D11C5 /* ViewController.swift */, + 43C436B5368904AC002D11C5 /* Main.storyboard */, + 43C436B8368904AD002D11C5 /* Assets.xcassets */, + 43C436BA368904AD002D11C5 /* LaunchScreen.storyboard */, + 43C436BD368904AD002D11C5 /* Info.plist */, ); path = "veilidtools-tests"; sourceTree = ""; @@ -85,14 +85,14 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 43C436AB268904AC002D11C5 /* veilidtools-tests */ = { + 43C436AB368904AC002D11C5 /* veilidtools-tests */ = { isa = PBXNativeTarget; - buildConfigurationList = 43C436C0268904AD002D11C5 /* Build configuration list for PBXNativeTarget "veilidtools-tests" */; + buildConfigurationList = 43C436C0368904AD002D11C5 /* Build configuration list for PBXNativeTarget "veilidtools-tests" */; buildPhases = ( - 43C436C326893020002D11C5 /* Cargo Build */, - 43C436A8268904AC002D11C5 /* Sources */, - 43C436A9268904AC002D11C5 /* Frameworks */, - 43C436AA268904AC002D11C5 /* Resources */, + 43C436C336893020002D11C5 /* Cargo Build */, + 43C436A8368904AC002D11C5 /* Sources */, + 43C436A9368904AC002D11C5 /* Frameworks */, + 43C436AA368904AC002D11C5 /* Resources */, ); buildRules = ( ); @@ -100,25 +100,25 @@ ); name = "veilidtools-tests"; productName = "veilidtools-tests"; - productReference = 43C436AC268904AC002D11C5 /* veilidtools-tests.app */; + productReference = 43C436AC368904AC002D11C5 /* veilidtools-tests.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ - 43C436A4268904AC002D11C5 /* Project object */ = { + 43C436A4368904AC002D11C5 /* Project object */ = { isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1250; LastUpgradeCheck = 1250; TargetAttributes = { - 43C436AB268904AC002D11C5 = { + 43C436AB368904AC002D11C5 = { CreatedOnToolsVersion = 12.5.1; LastSwiftMigration = 1250; }; }; }; - buildConfigurationList = 43C436A7268904AC002D11C5 /* Build configuration list for PBXProject "veilidtools-tests" */; + buildConfigurationList = 43C436A7368904AC002D11C5 /* Build configuration list for PBXProject "veilidtools-tests" */; compatibilityVersion = "Xcode 9.3"; developmentRegion = en; hasScannedForEncodings = 0; @@ -126,31 +126,31 @@ en, Base, ); - mainGroup = 43C436A3268904AC002D11C5; - productRefGroup = 43C436AD268904AC002D11C5 /* Products */; + mainGroup = 43C436A3368904AC002D11C5; + productRefGroup = 43C436AD368904AC002D11C5 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( - 43C436AB268904AC002D11C5 /* veilidtools-tests */, + 43C436AB368904AC002D11C5 /* veilidtools-tests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - 43C436AA268904AC002D11C5 /* Resources */ = { + 43C436AA368904AC002D11C5 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 43C436BC268904AD002D11C5 /* LaunchScreen.storyboard in Resources */, - 43C436B9268904AD002D11C5 /* Assets.xcassets in Resources */, - 43C436B7268904AC002D11C5 /* Main.storyboard in Resources */, + 43C436BC368904AD002D11C5 /* LaunchScreen.storyboard in Resources */, + 43C436B9368904AD002D11C5 /* Assets.xcassets in Resources */, + 43C436B7368904AC002D11C5 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 43C436C326893020002D11C5 /* Cargo Build */ = { + 43C436C336893020002D11C5 /* Cargo Build */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; buildActionMask = 2147483647; @@ -167,37 +167,37 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "../../../../ios_build.sh --features ios_tests\n"; + shellScript = "../../../../ios_build.sh veilid_tools --features ios_tests,rt-tokio\n"; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - 43C436A8268904AC002D11C5 /* Sources */ = { + 43C436A8368904AC002D11C5 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 43C436B4268904AC002D11C5 /* ViewController.swift in Sources */, - 43C436B0268904AC002D11C5 /* AppDelegate.swift in Sources */, - 43C436B2268904AC002D11C5 /* SceneDelegate.swift in Sources */, - 4317C6BD2694A676009C717F /* veilid-tools.c in Sources */, + 43C436B4368904AC002D11C5 /* ViewController.swift in Sources */, + 43C436B0368904AC002D11C5 /* AppDelegate.swift in Sources */, + 43C436B2368904AC002D11C5 /* SceneDelegate.swift in Sources */, + 4317C6BD3694A676009C717F /* (null) in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ - 43C436B5268904AC002D11C5 /* Main.storyboard */ = { + 43C436B5368904AC002D11C5 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( - 43C436B6268904AC002D11C5 /* Base */, + 43C436B6368904AC002D11C5 /* Base */, ); name = Main.storyboard; sourceTree = ""; }; - 43C436BA268904AD002D11C5 /* LaunchScreen.storyboard */ = { + 43C436BA368904AD002D11C5 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( - 43C436BB268904AD002D11C5 /* Base */, + 43C436BB368904AD002D11C5 /* Base */, ); name = LaunchScreen.storyboard; sourceTree = ""; @@ -205,11 +205,11 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - 43C436BE268904AD002D11C5 /* Debug */ = { + 43C436BE368904AD002D11C5 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = arm64; + ARCHS = "$(ARCHS_STANDARD)"; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -264,14 +264,15 @@ SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; - 43C436BF268904AD002D11C5 /* Release */ = { + 43C436BF368904AD002D11C5 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = arm64; + ARCHS = "$(ARCHS_STANDARD)"; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -319,16 +320,18 @@ SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; name = Release; }; - 43C436C1268904AD002D11C5 /* Debug */ = { + 43C436C1368904AD002D11C5 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ZJPQSFX5MW; INFOPLIST_FILE = "veilidtools-tests/Info.plist"; @@ -338,16 +341,13 @@ "@executable_path/Frameworks", ); OTHER_LDFLAGS = ""; - "OTHER_LDFLAGS[sdk=iphoneos*]" = ( - "-L../../../../../target/aarch64-apple-ios/debug", - "-lveilid_tools", - ); "OTHER_LDFLAGS[sdk=iphonesimulator*]" = ( - "-L../../../../../target/x86_64-apple-ios/debug", + "-L../../../../../target/lipo-ios-sim/debug", "-lveilid_tools", ); PRODUCT_BUNDLE_IDENTIFIER = "com.veilid.veilidtools-tests"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "veilidtools-tests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -355,12 +355,13 @@ }; name = Debug; }; - 43C436C2268904AD002D11C5 /* Release */ = { + 43C436C2368904AD002D11C5 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ZJPQSFX5MW; INFOPLIST_FILE = "veilidtools-tests/Info.plist"; @@ -370,16 +371,13 @@ "@executable_path/Frameworks", ); OTHER_LDFLAGS = ""; - "OTHER_LDFLAGS[sdk=iphoneos*]" = ( - "-L../../../../../target/aarch64-apple-ios/release", - "-lveilid_tools", - ); "OTHER_LDFLAGS[sdk=iphonesimulator*]" = ( - "-L../../../../../target/x86_64-apple-ios/release", + "-L../../../../../target/lipo-ios-sim/release", "-lveilid_tools", ); PRODUCT_BUNDLE_IDENTIFIER = "com.veilid.veilidtools-tests"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "veilidtools-tests-Bridging-Header.h"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -389,25 +387,25 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 43C436A7268904AC002D11C5 /* Build configuration list for PBXProject "veilidtools-tests" */ = { + 43C436A7368904AC002D11C5 /* Build configuration list for PBXProject "veilidtools-tests" */ = { isa = XCConfigurationList; buildConfigurations = ( - 43C436BE268904AD002D11C5 /* Debug */, - 43C436BF268904AD002D11C5 /* Release */, + 43C436BE368904AD002D11C5 /* Debug */, + 43C436BF368904AD002D11C5 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 43C436C0268904AD002D11C5 /* Build configuration list for PBXNativeTarget "veilidtools-tests" */ = { + 43C436C0368904AD002D11C5 /* Build configuration list for PBXNativeTarget "veilidtools-tests" */ = { isa = XCConfigurationList; buildConfigurations = ( - 43C436C1268904AD002D11C5 /* Debug */, - 43C436C2268904AD002D11C5 /* Release */, + 43C436C1368904AD002D11C5 /* Debug */, + 43C436C2368904AD002D11C5 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; - rootObject = 43C436A4268904AC002D11C5 /* Project object */; + rootObject = 43C436A4368904AC002D11C5 /* Project object */; } diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/xcshareddata/xcschemes/veilidcore-tests.xcscheme b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/xcshareddata/xcschemes/veilidtools-tests.xcscheme similarity index 92% rename from veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/xcshareddata/xcschemes/veilidcore-tests.xcscheme rename to veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/xcshareddata/xcschemes/veilidtools-tests.xcscheme index f1525db5..ec28aa85 100644 --- a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/xcshareddata/xcschemes/veilidcore-tests.xcscheme +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/xcshareddata/xcschemes/veilidtools-tests.xcscheme @@ -1,6 +1,6 @@ @@ -44,7 +44,7 @@ runnableDebuggingMode = "0"> @@ -61,7 +61,7 @@ runnableDebuggingMode = "0"> diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/ViewController.swift b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/ViewController.swift index 922d5462..0f0cf31f 100644 --- a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/ViewController.swift +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/ViewController.swift @@ -6,12 +6,14 @@ // import UIKit +import Darwin class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() run_veilid_tools_tests() + exit(0) } diff --git a/veilid-tools/src/tests/mod.rs b/veilid-tools/src/tests/mod.rs index 0b6b6216..7208386a 100644 --- a/veilid-tools/src/tests/mod.rs +++ b/veilid-tools/src/tests/mod.rs @@ -1,3 +1,11 @@ +#[cfg(target_os = "android")] +mod android; pub mod common; +#[cfg(target_os = "ios")] +mod ios; #[cfg(not(target_arch = "wasm32"))] mod native; + +use super::*; + +pub use common::*; diff --git a/veilid-tools/src/tests/native/mod.rs b/veilid-tools/src/tests/native/mod.rs index 9ab6f14d..892e95b7 100644 --- a/veilid-tools/src/tests/native/mod.rs +++ b/veilid-tools/src/tests/native/mod.rs @@ -3,8 +3,7 @@ mod test_async_peek_stream; -use crate::tests::common::*; -use crate::*; +use super::*; #[cfg(all(target_os = "android", feature = "android_tests"))] use jni::{objects::JClass, objects::JObject, JNIEnv}; @@ -17,30 +16,15 @@ pub extern "system" fn Java_com_veilid_veilidtools_veilidtools_1android_1tests_M _class: JClass, ctx: JObject, ) { - crate::intf::utils::android::veilid_tools_setup_android( - env, - ctx, - "veilid_tools", - crate::veilid_config::VeilidConfigLogLevel::Trace, - ); + crate::tests::android::veilid_tools_setup(env, ctx, "veilid-tools"); run_all_tests(); } #[cfg(all(target_os = "ios", feature = "ios_tests"))] #[no_mangle] +#[allow(dead_code)] pub extern "C" fn run_veilid_tools_tests() { - let log_path: std::path::PathBuf = [ - std::env::var("HOME").unwrap().as_str(), - "Documents", - "veilid-tools.log", - ] - .iter() - .collect(); - crate::intf::utils::ios_test_setup::veilid_tools_setup( - "veilid-tools", - Some(Level::Trace), - Some((Level::Trace, log_path.as_path())), - ); + crate::tests::ios::veilid_tools_setup().expect("setup failed"); run_all_tests(); } @@ -88,43 +72,37 @@ fn exec_test_async_tag_lock() { cfg_if! { if #[cfg(test)] { - static DEFAULT_LOG_IGNORE_LIST: [&str; 21] = [ - "mio", - "h2", - "hyper", - "tower", - "tonic", - "tokio", - "runtime", - "tokio_util", - "want", - "serial_test", - "async_std", - "async_io", - "polling", - "rustls", - "async_tungstenite", - "tungstenite", - "netlink_proto", - "netlink_sys", - "trust_dns_resolver", - "trust_dns_proto", - "attohttpc", - ]; - use serial_test::serial; - use simplelog::*; use std::sync::Once; static SETUP_ONCE: Once = Once::new(); pub fn setup() { SETUP_ONCE.call_once(|| { - let mut cb = ConfigBuilder::new(); - for ig in DEFAULT_LOG_IGNORE_LIST { - cb.add_filter_ignore_str(ig); + + cfg_if! { + if #[cfg(feature = "tracing")] { + use tracing_subscriber::{filter, fmt, prelude::*}; + let mut filters = filter::Targets::new(); + for ig in DEFAULT_LOG_IGNORE_LIST { + filters = filters.with_target(ig, filter::LevelFilter::OFF); + } + let fmt_layer = fmt::layer(); + tracing_subscriber::registry() + .with(filters) + .with(filter::LevelFilter::TRACE) + .with(fmt_layer) + .init(); + } else { + use simplelog::*; + let mut cb = ConfigBuilder::new(); + for ig in DEFAULT_LOG_IGNORE_LIST { + cb.add_filter_ignore_str(ig); + } + TestLogger::init(LevelFilter::Trace, cb.build()).unwrap(); + } } - TestLogger::init(LevelFilter::Trace, cb.build()).unwrap(); + }); } diff --git a/veilid-tools/tests/web.rs b/veilid-tools/tests/web.rs index 6e4ba0f8..89905c70 100644 --- a/veilid-tools/tests/web.rs +++ b/veilid-tools/tests/web.rs @@ -1,7 +1,7 @@ //! Test suite for the Web and headless browsers. #![cfg(target_arch = "wasm32")] -use veilid_tools::tests::common::*; +use veilid_tools::tests::*; use veilid_tools::*; use wasm_bindgen_test::*;