This commit is contained in:
John Smith 2022-11-27 22:33:41 -05:00
parent a34da6ff75
commit d99273334d
66 changed files with 374 additions and 254 deletions

3
Cargo.lock generated
View File

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

View File

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

View File

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

View File

@ -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"

View File

@ -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"

View File

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

View File

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

View File

@ -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<Mutex<Option<AndroidGlobals>>> = 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<T>
where
F: FnOnce() -> JniResult<T>,
{
env.push_local_frame(s)?;
let out = f();
env.pop_local_frame(JObject::null())?;
out
}

View File

@ -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",
];

View File

@ -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<Box<dyn SharedLogger>> = 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::<String>() {
error!("panic payload: {:?}", s);
} else if let Some(a) = panic_info.payload().downcast_ref::<std::fmt::Arguments>() {
error!("panic payload: {:?}", a);
} else {
error!("no panic payload");
}
error!("Backtrace:\n{:?}", bt);
}));
Ok(())
}

View File

@ -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 = "<group>"; };
4317C6BB2694A676009C717F /* veilid-tools.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "veilid-tools.h"; sourceTree = "<group>"; };
4317C6BC2694A676009C717F /* veilid-tools.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "veilid-tools.c"; sourceTree = "<group>"; };
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 = "<group>"; };
43C436B1268904AC002D11C5 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
43C436B3268904AC002D11C5 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
43C436B6268904AC002D11C5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
43C436B8268904AD002D11C5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
43C436BB268904AD002D11C5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
43C436BD268904AD002D11C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4317C6BA3694A675009C717F /* veilidtools-tests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "veilidtools-tests-Bridging-Header.h"; sourceTree = "<group>"; };
4317C6BB3694A676009C717F /* veilid-tools.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "veilid-tools.h"; sourceTree = "<group>"; };
4317C6BC3694A676009C717F /* veilid-tools.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "veilid-tools.c"; sourceTree = "<group>"; };
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 = "<group>"; };
43C436B1368904AC002D11C5 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
43C436B3368904AC002D11C5 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
43C436B6368904AC002D11C5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
43C436B8368904AD002D11C5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
43C436BB368904AD002D11C5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
43C436BD368904AD002D11C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* 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 = "<group>";
};
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 = "<group>";
};
43C436AD268904AC002D11C5 /* Products */ = {
43C436AD368904AC002D11C5 /* Products */ = {
isa = PBXGroup;
children = (
43C436AC268904AC002D11C5 /* veilidtools-tests.app */,
43C436AC368904AC002D11C5 /* veilidtools-tests.app */,
);
name = Products;
sourceTree = "<group>";
};
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 = "<group>";
@ -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 = "<group>";
};
43C436BA268904AD002D11C5 /* LaunchScreen.storyboard */ = {
43C436BA368904AD002D11C5 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
43C436BB268904AD002D11C5 /* Base */,
43C436BB368904AD002D11C5 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
@ -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 */;
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1410"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -14,7 +14,7 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43C436AB268904AC002D11C5"
BlueprintIdentifier = "43C436AB368904AC002D11C5"
BuildableName = "veilidtools-tests.app"
BlueprintName = "veilidtools-tests"
ReferencedContainer = "container:veilidtools-tests.xcodeproj">
@ -44,7 +44,7 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43C436AB268904AC002D11C5"
BlueprintIdentifier = "43C436AB368904AC002D11C5"
BuildableName = "veilidtools-tests.app"
BlueprintName = "veilidtools-tests"
ReferencedContainer = "container:veilidtools-tests.xcodeproj">
@ -61,7 +61,7 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43C436AB268904AC002D11C5"
BlueprintIdentifier = "43C436AB368904AC002D11C5"
BuildableName = "veilidtools-tests.app"
BlueprintName = "veilidtools-tests"
ReferencedContainer = "container:veilidtools-tests.xcodeproj">

View File

@ -6,12 +6,14 @@
//
import UIKit
import Darwin
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
run_veilid_tools_tests()
exit(0)
}

View File

@ -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::*;

View File

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

View File

@ -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::*;