diff --git a/Cargo.lock b/Cargo.lock index 8690c6fa..39b78d46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -334,18 +334,6 @@ version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" -[[package]] -name = "async-tls" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7e7fbc0843fc5ad3d5ca889c5b2bea9130984d34cd0e62db57ab70c2529a8e3" -dependencies = [ - "futures", - "rustls 0.18.1", - "webpki 0.21.4", - "webpki-roots 0.20.0", -] - [[package]] name = "async-tls" version = "0.11.0" @@ -354,7 +342,7 @@ checksum = "2f23d769dbf1838d5df5156e7b1ad404f4c463d1ac2c6aeb6cd943630f8a8400" dependencies = [ "futures-core", "futures-io", - "rustls 0.19.1", + "rustls", "webpki 0.21.4", "webpki-roots 0.21.1", ] @@ -376,7 +364,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5c45a0dd44b7e6533ac4e7acc38ead1a3b39885f5bbb738140d30ea528abc7c" dependencies = [ - "async-tls 0.9.0", "futures-io", "futures-util", "log", @@ -390,7 +377,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b750efd83b7e716a015eed5ebb583cda83c52d9b24a8f0125e5c48c3313c9f8" dependencies = [ - "async-tls 0.11.0", + "async-tls", "futures-io", "futures-util", "log", @@ -4309,19 +4296,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustls" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d1126dcf58e93cee7d098dbda643b5f92ed724f1f6a63007c1116eed6700c81" -dependencies = [ - "base64 0.12.3", - "log", - "ring", - "sct", - "webpki 0.21.4", -] - [[package]] name = "rustls" version = "0.19.1" @@ -5588,7 +5562,7 @@ dependencies = [ "async-lock", "async-std", "async-std-resolver", - "async-tls 0.11.0", + "async-tls", "async-tungstenite 0.18.0", "async_executors", "backtrace", @@ -5641,7 +5615,7 @@ dependencies = [ "rtnetlink", "rusqlite", "rust-fsm", - "rustls 0.19.1", + "rustls", "rustls-pemfile", "secrecy", "send_wrapper 0.6.0", @@ -5763,47 +5737,15 @@ dependencies = [ name = "veilid-tools" version = "0.1.0" dependencies = [ - "async-io", "async-lock", "async-std", - "async-std-resolver", - "async-tls 0.11.0", - "async-tungstenite 0.8.0", "async_executors", - "backtrace", - "blake3", - "bugsalot", - "bytecheck", "cfg-if 1.0.0", - "chacha20 0.8.2", - "chacha20poly1305", - "chrono", - "config", - "console_error_panic_hook", - "curve25519-dalek-ng", - "data-encoding", - "digest 0.9.0", - "directories", - "ed25519-dalek", - "enumset", "eyre", - "flume", "futures-util", - "generic-array", - "getrandom 0.2.8", - "hashlink 0.8.1", - "hex", - "ifstructs", - "igd", "jni", "jni-sys", "js-sys", - "json", - "keyring-manager", - "keyvaluedb", - "keyvaluedb-sqlite", - "keyvaluedb-web", - "lazy_static", "libc", "log", "maplit", @@ -5811,45 +5753,24 @@ dependencies = [ "ndk-glue", "nix 0.22.3", "once_cell", - "owning_ref", "owo-colors", "parking_lot 0.11.2", "rand 0.7.3", - "rkyv", - "rtnetlink", - "rusqlite", - "rustls 0.19.1", - "rustls-pemfile", - "secrecy", "send_wrapper 0.6.0", - "serde", - "serde-big-array", - "serde_json", "serial_test", "simplelog 0.9.0", - "socket2", "static_assertions", "stop-token", "thiserror", "tokio 1.22.0", - "tokio-stream", "tokio-util", "tracing", "tracing-android", - "trust-dns-resolver", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test", "wasm-logger", - "web-sys", - "webpki 0.21.4", - "webpki-roots 0.21.1", "wee_alloc", - "winapi 0.3.9", - "windows", - "windows-permissions", - "ws_stream_wasm", - "x25519-dalek-ng", ] [[package]] @@ -6060,15 +5981,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "webpki-roots" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f20dea7535251981a9670857150d571846545088359b28e4951d350bdaf179f" -dependencies = [ - "webpki 0.21.4", -] - [[package]] name = "webpki-roots" version = "0.21.1" diff --git a/veilid-core/src/tests/common/test_host_interface.rs b/veilid-core/src/tests/common/test_host_interface.rs index cc0f750e..322f5d5e 100644 --- a/veilid-core/src/tests/common/test_host_interface.rs +++ b/veilid-core/src/tests/common/test_host_interface.rs @@ -567,7 +567,7 @@ pub async fn test_all() { test_get_random_u32().await; test_sleep().await; #[cfg(not(target_arch = "wasm32"))] - test_network_interfaces().await; + test_network_interfaces().await; XXX KEEP THIS IN NATIVE TESTS test_must_join_single_future().await; test_eventual().await; test_eventual_value().await; diff --git a/veilid-core/tests/web.rs b/veilid-core/tests/web.rs index a5ac14b7..c4df57b1 100644 --- a/veilid-core/tests/web.rs +++ b/veilid-core/tests/web.rs @@ -23,13 +23,6 @@ pub fn setup() -> () { }); } -#[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(); @@ -37,48 +30,6 @@ async fn run_test_host_interface() { 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(); diff --git a/veilid-tools/Cargo.toml b/veilid-tools/Cargo.toml index 2e9aefc2..9d306626 100644 --- a/veilid-tools/Cargo.toml +++ b/veilid-tools/Cargo.toml @@ -9,14 +9,15 @@ license = "LGPL-2.0-or-later OR MPL-2.0 OR (MIT AND BSD-3-Clause)" crate-type = ["rlib"] [features] -default = [ "rt-tokio" ] -rt-async-std = [ "async-std", "async-std-resolver", "async_executors/async_std", "rtnetlink?/smol_socket" ] -rt-tokio = [ "tokio", "tokio-util", "tokio-stream", "trust-dns-resolver/tokio-runtime", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer", "rtnetlink?/tokio_socket" ] +default = [ "rt-tokio", "tracing" ] +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" ] tracking = [] tracing = [ "dep:tracing" ] +log = [ "dep:log" ] [dependencies] tracing = { version = "^0", features = ["log", "attributes"], optional = true } @@ -25,42 +26,12 @@ eyre = "^0" static_assertions = "^1" cfg-if = "^1" thiserror = "^1" -hex = "^0" -generic-array = "^0" -secrecy = "^0" -chacha20poly1305 = "^0" -chacha20 = "^0" -hashlink = { path = "../external/hashlink", features = ["serde_impl"] } -serde = { version = "^1", features = ["derive" ] } -serde_json = { version = "^1" } -serde-big-array = "^0" futures-util = { version = "^0", default_features = false, features = ["alloc"] } parking_lot = "^0" -lazy_static = "^1" -directories = "^4" once_cell = "^1" -json = "^0" -owning_ref = "^0" -flume = { version = "^0", features = ["async"] } -enumset = { version= "^1", features = ["serde"] } -backtrace = { version = "^0" } owo-colors = "^3" stop-token = { version = "^0", default-features = false } -ed25519-dalek = { version = "^1", default_features = false, features = ["alloc", "u64_backend"] } -x25519-dalek = { package = "x25519-dalek-ng", version = "^1", default_features = false, features = ["u64_backend"] } -curve25519-dalek = { package = "curve25519-dalek-ng", version = "^4", default_features = false, features = ["alloc", "u64_backend"] } -# ed25519-dalek needs rand 0.7 until it updates itself rand = "0.7" -# curve25519-dalek-ng is stuck on digest 0.9.0 -blake3 = { version = "1.1.0", default_features = false } -digest = "0.9.0" -rtnetlink = { version = "^0", default-features = false, optional = true } -async-std-resolver = { version = "^0", optional = true } -trust-dns-resolver = { version = "^0", optional = true } -keyvaluedb = { path = "../external/keyvaluedb/keyvaluedb" } -#rkyv = { version = "^0", default_features = false, features = ["std", "alloc", "strict", "size_32", "validation"] } -rkyv = { git = "https://github.com/rkyv/rkyv.git", rev = "57e2a8d", default_features = false, features = ["std", "alloc", "strict", "size_32", "validation"] } -bytecheck = "^0" # Dependencies for native builds only # Linux, Windows, Mac, iOS, Android @@ -68,25 +39,9 @@ bytecheck = "^0" async-std = { version = "^1", features = ["unstable"], optional = true} tokio = { version = "^1", features = ["full"], optional = true} tokio-util = { version = "^0", features = ["compat"], optional = true} -tokio-stream = { version = "^0", features = ["net"], optional = true} -async-io = { version = "^1" } -async-tungstenite = { version = "^0", features = ["async-tls"] } maplit = "^1" -config = { version = "^0", features = ["yaml"] } -keyring-manager = { path = "../external/keyring-manager" } -async-tls = "^0.11" -igd = { path = "../external/rust-igd" } -webpki = "^0" -webpki-roots = "^0" -rustls = "^0.19" -rustls-pemfile = "^0.2" futures-util = { version = "^0", default-features = false, features = ["async-await", "sink", "std", "io"] } -keyvaluedb-sqlite = { path = "../external/keyvaluedb/keyvaluedb-sqlite" } -data-encoding = { version = "^2" } -socket2 = "^0" -bugsalot = "^0" -chrono = "^0" libc = "^0" nix = "^0" @@ -95,30 +50,10 @@ nix = "^0" wasm-bindgen = "^0" js-sys = "^0" wasm-bindgen-futures = "^0" -keyvaluedb-web = { path = "../external/keyvaluedb/keyvaluedb-web" } -data-encoding = { version = "^2", default_features = false, features = ["alloc"] } -getrandom = { version = "^0.2", features = ["js"] } -ws_stream_wasm = "^0" async_executors = { version = "^0", default-features = false, features = [ "bindgen", "timer" ]} async-lock = "^2" send_wrapper = { version = "^0.6", features = ["futures"] } -wasm-logger = "^0" -# Configuration for WASM32 'web-sys' crate -[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys] -version = "^0" -features = [ - 'Document', - 'HtmlDocument', - # 'Element', - # 'HtmlElement', - # 'Node', - 'IdbFactory', - 'IdbOpenDbRequest', - 'Storage', - 'Location', - 'Window', -] # Dependencies for Android [target.'cfg(target_os = "android")'.dependencies] @@ -128,30 +63,15 @@ ndk = { version = "^0", features = ["trace"] } ndk-glue = { version = "^0", features = ["logger"] } tracing-android = { version = "^0" } -# Dependenices for all Unix (Linux, Android, MacOS, iOS) -[target.'cfg(unix)'.dependencies] -ifstructs = "^0" - -# Dependencies for Linux or Android -[target.'cfg(any(target_os = "android",target_os = "linux"))'.dependencies] -rtnetlink = { version = "^0", default-features = false } - # Dependencies for Windows -[target.'cfg(target_os = "windows")'.dependencies] -winapi = { version = "^0.3.9", features = [ "iptypes", "iphlpapi" ] } -windows = { version = "^0", features = [ "Win32_NetworkManagement_Dns", "Win32_Foundation", "alloc" ]} -windows-permissions = "^0" +# [target.'cfg(target_os = "windows")'.dependencies] +# windows = { version = "^0", features = [ "Win32_NetworkManagement_Dns", "Win32_Foundation", "alloc" ]} +# windows-permissions = "^0" # Dependencies for iOS [target.'cfg(target_os = "ios")'.dependencies] simplelog = { 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 -[target.'cfg(all(not(target_os = "ios"),not(target_os = "android"),not(target_arch = "wasm32")))'.dependencies.rusqlite] -version = "^0" -features = ["bundled"] - ### DEV DEPENDENCIES [dev-dependencies] @@ -162,7 +82,6 @@ simplelog = { version = "^0", features=["test"] } [target.'cfg(target_arch = "wasm32")'.dev-dependencies] wasm-bindgen-test = "^0" -console_error_panic_hook = "^0" wee_alloc = "^0" wasm-logger = "^0" diff --git a/veilid-tools/src/lib.rs b/veilid-tools/src/lib.rs index d5f6ac70..0838c00f 100644 --- a/veilid-tools/src/lib.rs +++ b/veilid-tools/src/lib.rs @@ -74,6 +74,7 @@ pub use std::net::{ pub use std::ops::{Fn, FnMut, FnOnce}; pub use std::pin::Pin; pub use std::rc::Rc; +pub use std::str::FromStr; pub use std::string::{String, ToString}; pub use std::sync::atomic::{AtomicBool, Ordering}; pub use std::sync::{Arc, Weak}; @@ -132,3 +133,6 @@ pub use timestamp::*; pub use tools::*; #[cfg(target_arch = "wasm32")] pub use wasm::*; + +// Tests must be public for wasm-pack tests +pub mod tests; diff --git a/veilid-tools/src/must_join_handle.rs b/veilid-tools/src/must_join_handle.rs index a9de40b7..ff7231f1 100644 --- a/veilid-tools/src/must_join_handle.rs +++ b/veilid-tools/src/must_join_handle.rs @@ -77,7 +77,7 @@ impl Future for MustJoinHandle { } } } - }else if #[cfg(target_arch = "wasm32")] { + } else if #[cfg(target_arch = "wasm32")] { Poll::Ready(t) } else { compile_error!("needs executor implementation") diff --git a/veilid-tools/src/split_url.rs b/veilid-tools/src/split_url.rs index 718d4946..9cfd8c94 100644 --- a/veilid-tools/src/split_url.rs +++ b/veilid-tools/src/split_url.rs @@ -9,7 +9,7 @@ use super::*; -use core::str::FromStr; +use std::str::FromStr; fn is_alphanum(c: u8) -> bool { matches!(c, diff --git a/veilid-tools/src/tests/.gitignore b/veilid-tools/src/tests/.gitignore new file mode 100644 index 00000000..e8c47856 --- /dev/null +++ b/veilid-tools/src/tests/.gitignore @@ -0,0 +1,4 @@ +# exclude everything +tmp/* +# exception to the rule +!tmp/.gitkeep diff --git a/veilid-tools/src/tests/android/.gitignore b/veilid-tools/src/tests/android/.gitignore new file mode 100644 index 00000000..82e4fd4b --- /dev/null +++ b/veilid-tools/src/tests/android/.gitignore @@ -0,0 +1,16 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +/.idea/deploymentTargetDropDown.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/veilid-tools/src/tests/android/.idea/.gitignore b/veilid-tools/src/tests/android/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/veilid-tools/src/tests/android/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/veilid-tools/src/tests/android/.idea/.name b/veilid-tools/src/tests/android/.idea/.name new file mode 100644 index 00000000..cde590be --- /dev/null +++ b/veilid-tools/src/tests/android/.idea/.name @@ -0,0 +1 @@ +Veilid Tools Tests \ No newline at end of file diff --git a/veilid-tools/src/tests/android/.idea/compiler.xml b/veilid-tools/src/tests/android/.idea/compiler.xml new file mode 100644 index 00000000..fb7f4a8a --- /dev/null +++ b/veilid-tools/src/tests/android/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/veilid-tools/src/tests/android/.idea/gradle.xml b/veilid-tools/src/tests/android/.idea/gradle.xml new file mode 100644 index 00000000..4989a70a --- /dev/null +++ b/veilid-tools/src/tests/android/.idea/gradle.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/veilid-tools/src/tests/android/.idea/jarRepositories.xml b/veilid-tools/src/tests/android/.idea/jarRepositories.xml new file mode 100644 index 00000000..a5f05cd8 --- /dev/null +++ b/veilid-tools/src/tests/android/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/veilid-tools/src/tests/android/.idea/misc.xml b/veilid-tools/src/tests/android/.idea/misc.xml new file mode 100644 index 00000000..ef61796f --- /dev/null +++ b/veilid-tools/src/tests/android/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/veilid-tools/src/tests/android/.idea/vcs.xml b/veilid-tools/src/tests/android/.idea/vcs.xml new file mode 100644 index 00000000..4fce1d86 --- /dev/null +++ b/veilid-tools/src/tests/android/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/veilid-tools/src/tests/android/.project b/veilid-tools/src/tests/android/.project new file mode 100644 index 00000000..cf0850ea --- /dev/null +++ b/veilid-tools/src/tests/android/.project @@ -0,0 +1,28 @@ + + + Veilid Tools Tests + Project android created by Buildship. + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.buildship.core.gradleprojectnature + + + + 0 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/veilid-tools/src/tests/android/.settings/org.eclipse.buildship.core.prefs b/veilid-tools/src/tests/android/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 00000000..094110d3 --- /dev/null +++ b/veilid-tools/src/tests/android/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,13 @@ +arguments= +auto.sync=false +build.scans.enabled=false +connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) +connection.project.dir= +eclipse.preferences.version=1 +gradle.user.home= +java.home=/opt/android-studio/jre +jvm.arguments= +offline.mode=false +override.workspace.settings=true +show.console.view=true +show.executions.view=true diff --git a/veilid-tools/src/tests/android/adb+.sh b/veilid-tools/src/tests/android/adb+.sh new file mode 100755 index 00000000..5aa7fbbf --- /dev/null +++ b/veilid-tools/src/tests/android/adb+.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# Script adb+ +# Usage +# You can run any command adb provide on all your current devices +# ./adb+ is the equivalent of ./adb -s +# +# Examples +# ./adb+ version +# ./adb+ install apidemo.apk +# ./adb+ uninstall com.example.android.apis + +adb devices | while read line +do + if [ ! "$line" = "" ] && [ `echo $line | awk '{print $2}'` = "device" ] + then + device=`echo $line | awk '{print $1}'` + echo "$device $@ ..." + adb -s $device $@ + fi +done diff --git a/veilid-tools/src/tests/android/app/.classpath b/veilid-tools/src/tests/android/app/.classpath new file mode 100644 index 00000000..4a04201c --- /dev/null +++ b/veilid-tools/src/tests/android/app/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/veilid-tools/src/tests/android/app/.gitignore b/veilid-tools/src/tests/android/app/.gitignore new file mode 100644 index 00000000..23c35ec2 --- /dev/null +++ b/veilid-tools/src/tests/android/app/.gitignore @@ -0,0 +1,4 @@ +/build +/.cxx + + diff --git a/veilid-tools/src/tests/android/app/.project b/veilid-tools/src/tests/android/app/.project new file mode 100644 index 00000000..c2e60fbb --- /dev/null +++ b/veilid-tools/src/tests/android/app/.project @@ -0,0 +1,34 @@ + + + VeilidTools Tests-app + Project VeilidTools Tests-app created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + + + 1635633714053 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/veilid-tools/src/tests/android/app/.settings/org.eclipse.buildship.core.prefs b/veilid-tools/src/tests/android/app/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 00000000..b1886adb --- /dev/null +++ b/veilid-tools/src/tests/android/app/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir=.. +eclipse.preferences.version=1 diff --git a/veilid-tools/src/tests/android/app/CMakeLists.txt b/veilid-tools/src/tests/android/app/CMakeLists.txt new file mode 100644 index 00000000..57518a5d --- /dev/null +++ b/veilid-tools/src/tests/android/app/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1) +project(cpplink CXX) +add_library(cpplink cpplink.cpp) \ No newline at end of file diff --git a/veilid-tools/src/tests/android/app/build.gradle b/veilid-tools/src/tests/android/app/build.gradle new file mode 100644 index 00000000..21c6c24a --- /dev/null +++ b/veilid-tools/src/tests/android/app/build.gradle @@ -0,0 +1,87 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.veilid.veilidtools.veilidtools_android_tests" + minSdkVersion 24 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + + ndk { + abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' + } + + // Required to copy libc++_shared.so + externalNativeBuild { + cmake { + arguments "-DANDROID_STL=c++_shared" + targets "cpplink" + } + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + ndkVersion '22.0.7026061' + + // Required to copy libc++_shared.so + externalNativeBuild { + cmake { + path file('CMakeLists.txt') + } + } +} + +dependencies { + implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.2' + implementation 'androidx.security:security-crypto:1.1.0-alpha03' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' +} + +apply plugin: 'org.mozilla.rust-android-gradle.rust-android' + +cargo { + module = "../../../../../veilid-tools" + libname = "veilid_tools" + targets = ["arm", "arm64", "x86", "x86_64"] + targetDirectory = "../../../../../target" + prebuiltToolchains = true + profile = gradle.startParameter.taskNames.any{it.toLowerCase().contains("debug")} ? "debug" : "release" + pythonCommand = "python3" + features { + defaultAnd("android_tests", "rt-tokio") + } +} + +afterEvaluate { + // The `cargoBuild` task isn't available until after evaluation. + android.applicationVariants.all { variant -> + def productFlavor = "" + variant.productFlavors.each { + productFlavor += "${it.name.capitalize()}" + } + def buildType = "${variant.buildType.name.capitalize()}" + tasks["generate${productFlavor}${buildType}Assets"].dependsOn(tasks["cargoBuild"]) + } +} + diff --git a/veilid-tools/src/tests/android/app/cpplink.cpp b/veilid-tools/src/tests/android/app/cpplink.cpp new file mode 100644 index 00000000..e69de29b diff --git a/veilid-tools/src/tests/android/app/proguard-rules.pro b/veilid-tools/src/tests/android/app/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/veilid-tools/src/tests/android/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/veilid-tools/src/tests/android/app/src/main/AndroidManifest.xml b/veilid-tools/src/tests/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..9c9b4431 --- /dev/null +++ b/veilid-tools/src/tests/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file 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/app/src/main/java/com/veilid/veilid-core/veilid-core_android_tests/MainActivity.java new file mode 100644 index 00000000..2b73f488 --- /dev/null +++ b/veilid-tools/src/tests/android/app/src/main/java/com/veilid/veilid-core/veilid-core_android_tests/MainActivity.java @@ -0,0 +1,37 @@ +package com.veilid.veilidtools.veilidtools_android_tests; + +import androidx.appcompat.app.AppCompatActivity; +import android.content.Context; +import android.os.Bundle; + +public class MainActivity extends AppCompatActivity { + + static { + System.loadLibrary("veilid_tools"); + } + + private static native void run_tests(Context context); + + private Thread testThread; + + class TestThread extends Thread { + private Context context; + + TestThread(Context context) { + this.context = context; + } + + public void run() { + run_tests(this.context); + } + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + this.testThread = new TestThread(this); + this.testThread.start(); + } +} diff --git a/veilid-tools/src/tests/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/veilid-tools/src/tests/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..2b068d11 --- /dev/null +++ b/veilid-tools/src/tests/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/veilid-tools/src/tests/android/app/src/main/res/drawable/ic_launcher_background.xml b/veilid-tools/src/tests/android/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..07d5da9c --- /dev/null +++ b/veilid-tools/src/tests/android/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/veilid-tools/src/tests/android/app/src/main/res/layout/activity_main.xml b/veilid-tools/src/tests/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..4fc24441 --- /dev/null +++ b/veilid-tools/src/tests/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/veilid-tools/src/tests/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 00000000..eca70cfe --- /dev/null +++ b/veilid-tools/src/tests/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file 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/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 00000000..eca70cfe --- /dev/null +++ b/veilid-tools/src/tests/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/veilid-tools/src/tests/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 00000000..a571e600 Binary files /dev/null and b/veilid-tools/src/tests/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/veilid-tools/src/tests/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 00000000..61da551c Binary files /dev/null and b/veilid-tools/src/tests/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/veilid-tools/src/tests/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 00000000..c41dd285 Binary files /dev/null and b/veilid-tools/src/tests/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/veilid-tools/src/tests/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 00000000..db5080a7 Binary files /dev/null and b/veilid-tools/src/tests/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/veilid-tools/src/tests/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 00000000..6dba46da Binary files /dev/null and b/veilid-tools/src/tests/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/veilid-tools/src/tests/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 00000000..da31a871 Binary files /dev/null and b/veilid-tools/src/tests/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..15ac6817 Binary files /dev/null and b/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 00000000..b216f2d3 Binary files /dev/null and b/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..f25a4197 Binary files /dev/null and b/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 00000000..e96783cc Binary files /dev/null and b/veilid-tools/src/tests/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/veilid-tools/src/tests/android/app/src/main/res/values-night/themes.xml b/veilid-tools/src/tests/android/app/src/main/res/values-night/themes.xml new file mode 100644 index 00000000..5ee570a8 --- /dev/null +++ b/veilid-tools/src/tests/android/app/src/main/res/values-night/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/veilid-tools/src/tests/android/app/src/main/res/values/colors.xml b/veilid-tools/src/tests/android/app/src/main/res/values/colors.xml new file mode 100644 index 00000000..f8c6127d --- /dev/null +++ b/veilid-tools/src/tests/android/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/veilid-tools/src/tests/android/app/src/main/res/values/strings.xml b/veilid-tools/src/tests/android/app/src/main/res/values/strings.xml new file mode 100644 index 00000000..ca58c272 --- /dev/null +++ b/veilid-tools/src/tests/android/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + VeilidTools Tests + \ No newline at end of file diff --git a/veilid-tools/src/tests/android/app/src/main/res/values/themes.xml b/veilid-tools/src/tests/android/app/src/main/res/values/themes.xml new file mode 100644 index 00000000..914f69d4 --- /dev/null +++ b/veilid-tools/src/tests/android/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/veilid-tools/src/tests/android/build.gradle b/veilid-tools/src/tests/android/build.gradle new file mode 100644 index 00000000..96496236 --- /dev/null +++ b/veilid-tools/src/tests/android/build.gradle @@ -0,0 +1,28 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + google() + jcenter() + } + dependencies { + classpath "com.android.tools.build:gradle:4.1.2" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +plugins { + id "org.mozilla.rust-android-gradle.rust-android" version "0.9.0" +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/veilid-tools/src/tests/android/gradle.properties b/veilid-tools/src/tests/android/gradle.properties new file mode 100644 index 00000000..52f5917c --- /dev/null +++ b/veilid-tools/src/tests/android/gradle.properties @@ -0,0 +1,19 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app"s APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true \ No newline at end of file diff --git a/veilid-tools/src/tests/android/gradle/wrapper/gradle-wrapper.jar b/veilid-tools/src/tests/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..f6b961fd Binary files /dev/null and b/veilid-tools/src/tests/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/veilid-tools/src/tests/android/gradle/wrapper/gradle-wrapper.properties b/veilid-tools/src/tests/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..3a56e3d2 --- /dev/null +++ b/veilid-tools/src/tests/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Jun 21 14:26:26 PDT 2021 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip diff --git a/veilid-tools/src/tests/android/gradlew b/veilid-tools/src/tests/android/gradlew new file mode 100755 index 00000000..cccdd3d5 --- /dev/null +++ b/veilid-tools/src/tests/android/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/veilid-tools/src/tests/android/gradlew.bat b/veilid-tools/src/tests/android/gradlew.bat new file mode 100644 index 00000000..e95643d6 --- /dev/null +++ b/veilid-tools/src/tests/android/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/veilid-tools/src/tests/android/install_on_all_devices.sh b/veilid-tools/src/tests/android/install_on_all_devices.sh new file mode 100755 index 00000000..f96d53b1 --- /dev/null +++ b/veilid-tools/src/tests/android/install_on_all_devices.sh @@ -0,0 +1,2 @@ +#!/bin/bash +./gradlew installDebug diff --git a/veilid-tools/src/tests/android/remove_from_all_devices.sh b/veilid-tools/src/tests/android/remove_from_all_devices.sh new file mode 100755 index 00000000..eea0ef7e --- /dev/null +++ b/veilid-tools/src/tests/android/remove_from_all_devices.sh @@ -0,0 +1,3 @@ +#!/bin/bash +./adb+.sh uninstall com.veilid.veilidtools.veilidtools_android_tests + diff --git a/veilid-tools/src/tests/android/settings.gradle b/veilid-tools/src/tests/android/settings.gradle new file mode 100644 index 00000000..ff5d71fe --- /dev/null +++ b/veilid-tools/src/tests/android/settings.gradle @@ -0,0 +1,2 @@ +include ':app' +rootProject.name = "Veilid Tools Tests" \ No newline at end of file diff --git a/veilid-tools/src/tests/common/mod.rs b/veilid-tools/src/tests/common/mod.rs new file mode 100644 index 00000000..06433eae --- /dev/null +++ b/veilid-tools/src/tests/common/mod.rs @@ -0,0 +1,2 @@ +pub mod test_async_tag_lock; +pub mod test_host_interface; diff --git a/veilid-tools/src/tests/common/test_async_tag_lock.rs b/veilid-tools/src/tests/common/test_async_tag_lock.rs new file mode 100644 index 00000000..c1b2ecc4 --- /dev/null +++ b/veilid-tools/src/tests/common/test_async_tag_lock.rs @@ -0,0 +1,158 @@ +use crate::*; + +pub async fn test_simple_no_contention() { + info!("test_simple_no_contention"); + + let table = AsyncTagLockTable::new(); + + let a1 = SocketAddr::new("1.2.3.4".parse().unwrap(), 1234); + let a2 = SocketAddr::new("6.9.6.9".parse().unwrap(), 6969); + + { + let g1 = table.lock_tag(a1).await; + let g2 = table.lock_tag(a2).await; + drop(g2); + drop(g1); + } + + { + let g1 = table.lock_tag(a1).await; + let g2 = table.lock_tag(a2).await; + drop(g1); + drop(g2); + } + + assert_eq!(table.len(), 0); +} + +pub async fn test_simple_single_contention() { + info!("test_simple_single_contention"); + + let table = AsyncTagLockTable::new(); + + let a1 = SocketAddr::new("1.2.3.4".parse().unwrap(), 1234); + + let g1 = table.lock_tag(a1).await; + + info!("locked"); + let t1 = spawn(async move { + // move the guard into the task + let _g1_take = g1; + // hold the guard for a bit + info!("waiting"); + sleep(1000).await; + // release the guard + info!("released"); + }); + + // wait to lock again, will contend until spawned task exits + let _g1_b = table.lock_tag(a1).await; + info!("locked"); + + // Ensure task is joined + t1.await; + + assert_eq!(table.len(), 1); +} + +pub async fn test_simple_double_contention() { + info!("test_simple_double_contention"); + + let table = AsyncTagLockTable::new(); + + let a1 = SocketAddr::new("1.2.3.4".parse().unwrap(), 1234); + let a2 = SocketAddr::new("6.9.6.9".parse().unwrap(), 6969); + + let g1 = table.lock_tag(a1).await; + let g2 = table.lock_tag(a2).await; + + info!("locked"); + let t1 = spawn(async move { + // move the guard into the tas + let _g1_take = g1; + // hold the guard for a bit + info!("waiting"); + sleep(1000).await; + // release the guard + info!("released"); + }); + let t2 = spawn(async move { + // move the guard into the task + let _g2_take = g2; + // hold the guard for a bit + info!("waiting"); + sleep(500).await; + // release the guard + info!("released"); + }); + + // wait to lock again, will contend until spawned task exits + let _g1_b = table.lock_tag(a1).await; + // wait to lock again, should complete immediately + let _g2_b = table.lock_tag(a2).await; + + info!("locked"); + + // Ensure tasks are joined + t1.await; + t2.await; + + assert_eq!(table.len(), 2); +} + +pub async fn test_parallel_single_contention() { + info!("test_parallel_single_contention"); + + let table = AsyncTagLockTable::new(); + + let a1 = SocketAddr::new("1.2.3.4".parse().unwrap(), 1234); + + let table1 = table.clone(); + let t1 = spawn(async move { + // lock the tag + let _g = table1.lock_tag(a1).await; + info!("locked t1"); + // hold the guard for a bit + info!("waiting t1"); + sleep(500).await; + // release the guard + info!("released t1"); + }); + + let table2 = table.clone(); + let t2 = spawn(async move { + // lock the tag + let _g = table2.lock_tag(a1).await; + info!("locked t2"); + // hold the guard for a bit + info!("waiting t2"); + sleep(500).await; + // release the guard + info!("released t2"); + }); + + let table3 = table.clone(); + let t3 = spawn(async move { + // lock the tag + let _g = table3.lock_tag(a1).await; + info!("locked t3"); + // hold the guard for a bit + info!("waiting t3"); + sleep(500).await; + // release the guard + info!("released t3"); + }); + + // Ensure tasks are joined + t1.await; + t2.await; + t3.await; + + assert_eq!(table.len(), 0); +} + +pub async fn test_all() { + test_simple_no_contention().await; + test_simple_single_contention().await; + test_parallel_single_contention().await; +} diff --git a/veilid-tools/src/tests/common/test_host_interface.rs b/veilid-tools/src/tests/common/test_host_interface.rs new file mode 100644 index 00000000..2d73c399 --- /dev/null +++ b/veilid-tools/src/tests/common/test_host_interface.rs @@ -0,0 +1,554 @@ +use crate::*; + +cfg_if! { + if #[cfg(target_arch = "wasm32")] { + use js_sys::*; + } else { + use std::time::{Duration, SystemTime}; + } +} + +pub async fn test_log() { + info!("testing log"); +} + +pub async fn test_get_timestamp() { + info!("testing get_timestamp"); + let t1 = get_timestamp(); + let t2 = get_timestamp(); + assert!(t2 >= t1); +} + +pub async fn test_eventual() { + info!("testing Eventual"); + { + let e1 = Eventual::new(); + let i1 = e1.instance_clone(1u32); + let i2 = e1.instance_clone(2u32); + let i3 = e1.instance_clone(3u32); + drop(i3); + let i4 = e1.instance_clone(4u32); + drop(i2); + + let jh = spawn(async move { + sleep(1000).await; + e1.resolve(); + }); + + assert_eq!(i1.await, 1u32); + assert_eq!(i4.await, 4u32); + + jh.await; + } + { + let e1 = Eventual::new(); + let i1 = e1.instance_clone(1u32); + let i2 = e1.instance_clone(2u32); + let i3 = e1.instance_clone(3u32); + let i4 = e1.instance_clone(4u32); + let e1_c1 = e1.clone(); + let jh = spawn(async move { + let i5 = e1.instance_clone(5u32); + let i6 = e1.instance_clone(6u32); + assert_eq!(i1.await, 1u32); + assert_eq!(i5.await, 5u32); + assert_eq!(i6.await, 6u32); + }); + sleep(1000).await; + let resolved = e1_c1.resolve(); + drop(i2); + drop(i3); + assert_eq!(i4.await, 4u32); + resolved.await; + jh.await; + } + { + let e1 = Eventual::new(); + let i1 = e1.instance_clone(1u32); + let i2 = e1.instance_clone(2u32); + let e1_c1 = e1.clone(); + let jh = spawn(async move { + assert_eq!(i1.await, 1u32); + assert_eq!(i2.await, 2u32); + }); + sleep(1000).await; + e1_c1.resolve().await; + + jh.await; + + e1_c1.reset(); + // + let j1 = e1.instance_clone(1u32); + let j2 = e1.instance_clone(2u32); + let jh = spawn(async move { + assert_eq!(j1.await, 1u32); + assert_eq!(j2.await, 2u32); + }); + sleep(1000).await; + e1_c1.resolve().await; + + jh.await; + + e1_c1.reset(); + } +} + +pub async fn test_eventual_value() { + info!("testing Eventual Value"); + { + let e1 = EventualValue::::new(); + let i1 = e1.instance(); + let i2 = e1.instance(); + let i3 = e1.instance(); + drop(i3); + let i4 = e1.instance(); + drop(i2); + + let e1_c1 = e1.clone(); + let jh = spawn(async move { + sleep(1000).await; + e1_c1.resolve(3u32); + }); + + i1.await; + i4.await; + jh.await; + assert_eq!(e1.take_value(), Some(3u32)); + } + { + let e1 = EventualValue::new(); + let i1 = e1.instance(); + let i2 = e1.instance(); + let i3 = e1.instance(); + let i4 = e1.instance(); + let e1_c1 = e1.clone(); + let jh = spawn(async move { + let i5 = e1.instance(); + let i6 = e1.instance(); + i1.await; + i5.await; + i6.await; + }); + sleep(1000).await; + let resolved = e1_c1.resolve(4u16); + drop(i2); + drop(i3); + i4.await; + resolved.await; + jh.await; + assert_eq!(e1_c1.take_value(), Some(4u16)); + } + { + let e1 = EventualValue::new(); + assert_eq!(e1.take_value(), None); + let i1 = e1.instance(); + let i2 = e1.instance(); + let e1_c1 = e1.clone(); + let jh = spawn(async move { + i1.await; + i2.await; + }); + sleep(1000).await; + e1_c1.resolve(5u32).await; + jh.await; + assert_eq!(e1_c1.take_value(), Some(5u32)); + e1_c1.reset(); + assert_eq!(e1_c1.take_value(), None); + // + let j1 = e1.instance(); + let j2 = e1.instance(); + let jh = spawn(async move { + j1.await; + j2.await; + }); + sleep(1000).await; + e1_c1.resolve(6u32).await; + jh.await; + assert_eq!(e1_c1.take_value(), Some(6u32)); + e1_c1.reset(); + assert_eq!(e1_c1.take_value(), None); + } +} + +pub async fn test_eventual_value_clone() { + info!("testing Eventual Value Clone"); + { + let e1 = EventualValueClone::::new(); + let i1 = e1.instance(); + let i2 = e1.instance(); + let i3 = e1.instance(); + drop(i3); + let i4 = e1.instance(); + drop(i2); + + let jh = spawn(async move { + sleep(1000).await; + e1.resolve(3u32); + }); + + assert_eq!(i1.await, 3); + assert_eq!(i4.await, 3); + + jh.await; + } + + { + let e1 = EventualValueClone::new(); + let i1 = e1.instance(); + let i2 = e1.instance(); + let i3 = e1.instance(); + let i4 = e1.instance(); + let e1_c1 = e1.clone(); + let jh = spawn(async move { + let i5 = e1.instance(); + let i6 = e1.instance(); + assert_eq!(i1.await, 4); + assert_eq!(i5.await, 4); + assert_eq!(i6.await, 4); + }); + sleep(1000).await; + let resolved = e1_c1.resolve(4u16); + drop(i2); + drop(i3); + assert_eq!(i4.await, 4); + resolved.await; + jh.await; + } + + { + let e1 = EventualValueClone::new(); + let i1 = e1.instance(); + let i2 = e1.instance(); + let e1_c1 = e1.clone(); + let jh = spawn(async move { + assert_eq!(i1.await, 5); + assert_eq!(i2.await, 5); + }); + sleep(1000).await; + e1_c1.resolve(5u32).await; + jh.await; + e1_c1.reset(); + // + let j1 = e1.instance(); + let j2 = e1.instance(); + let jh = spawn(async move { + assert_eq!(j1.await, 6); + assert_eq!(j2.await, 6); + }); + sleep(1000).await; + e1_c1.resolve(6u32).await; + jh.await; + e1_c1.reset(); + } +} +pub async fn test_interval() { + info!("testing interval"); + + let tick: Arc> = Arc::new(Mutex::new(0u32)); + let stopper = interval(1000, move || { + let tick = tick.clone(); + async move { + let mut tick = tick.lock(); + trace!("tick {}", tick); + *tick += 1; + } + }); + + sleep(5500).await; + + stopper.await; +} + +pub async fn test_timeout() { + info!("testing timeout"); + + let tick: Arc> = Arc::new(Mutex::new(0u32)); + let tick_1 = tick.clone(); + assert!( + timeout(2500, async move { + let mut tick = tick_1.lock(); + trace!("tick {}", tick); + sleep(1000).await; + *tick += 1; + trace!("tick {}", tick); + sleep(1000).await; + *tick += 1; + trace!("tick {}", tick); + sleep(1000).await; + *tick += 1; + trace!("tick {}", tick); + sleep(1000).await; + *tick += 1; + }) + .await + .is_err(), + "should have timed out" + ); + + let ticks = *tick.lock(); + assert!(ticks <= 2); +} + +pub async fn test_sleep() { + info!("testing sleep"); + cfg_if! { + if #[cfg(target_arch = "wasm32")] { + + let t1 = Date::now(); + intf::sleep(1000).await; + let t2 = Date::now(); + assert!((t2-t1) >= 1000.0); + + } else { + + let sys_time = SystemTime::now(); + let one_sec = Duration::from_secs(1); + + sleep(1000).await; + assert!(sys_time.elapsed().unwrap() >= one_sec); + } + } +} + +macro_rules! assert_split_url { + ($url:expr, $scheme:expr, $host:expr) => { + assert_eq!( + SplitUrl::from_str($url), + Ok(SplitUrl::new($scheme, None, $host, None, None)) + ); + }; + ($url:expr, $scheme:expr, $host:expr, $port:expr) => { + assert_eq!( + SplitUrl::from_str($url), + Ok(SplitUrl::new($scheme, None, $host, $port, None)) + ); + }; + ($url:expr, $scheme:expr, $host:expr, $port:expr, $path:expr) => { + assert_eq!( + SplitUrl::from_str($url), + Ok(SplitUrl::new( + $scheme, + None, + $host, + $port, + Some(SplitUrlPath::new( + $path, + Option::::None, + Option::::None + )) + )) + ); + }; + ($url:expr, $scheme:expr, $host:expr, $port:expr, $path:expr, $frag:expr, $query:expr) => { + assert_eq!( + SplitUrl::from_str($url), + Ok(SplitUrl::new( + $scheme, + None, + $host, + $port, + Some(SplitUrlPath::new($path, $frag, $query)) + )) + ); + }; +} + +macro_rules! assert_split_url_parse { + ($url:expr) => { + let url = $url; + let su1 = SplitUrl::from_str(url).expect("should parse"); + assert_eq!(su1.to_string(), url); + }; +} + +fn host>(s: S) -> SplitUrlHost { + SplitUrlHost::Hostname(s.as_ref().to_owned()) +} + +fn ip>(s: S) -> SplitUrlHost { + SplitUrlHost::IpAddr(IpAddr::from_str(s.as_ref()).unwrap()) +} + +pub async fn test_split_url() { + info!("testing split_url"); + + assert_split_url!("http://foo", "http", host("foo")); + assert_split_url!("http://foo:1234", "http", host("foo"), Some(1234)); + assert_split_url!("http://foo:1234/", "http", host("foo"), Some(1234), ""); + assert_split_url!( + "http://foo:1234/asdf/qwer", + "http", + host("foo"), + Some(1234), + "asdf/qwer" + ); + assert_split_url!("http://foo/", "http", host("foo"), None, ""); + assert_split_url!("http://11.2.3.144/", "http", ip("11.2.3.144"), None, ""); + assert_split_url!("http://[1111::2222]/", "http", ip("1111::2222"), None, ""); + assert_split_url!( + "http://[1111::2222]:123/", + "http", + ip("1111::2222"), + Some(123), + "" + ); + + assert_split_url!( + "http://foo/asdf/qwer", + "http", + host("foo"), + None, + "asdf/qwer" + ); + assert_split_url!( + "http://foo/asdf/qwer#3", + "http", + host("foo"), + None, + "asdf/qwer", + Some("3"), + Option::::None + ); + assert_split_url!( + "http://foo/asdf/qwer?xxx", + "http", + host("foo"), + None, + "asdf/qwer", + Option::::None, + Some("xxx") + ); + assert_split_url!( + "http://foo/asdf/qwer#yyy?xxx", + "http", + host("foo"), + None, + "asdf/qwer", + Some("yyy"), + Some("xxx") + ); + assert_err!(SplitUrl::from_str("://asdf")); + assert_err!(SplitUrl::from_str("")); + assert_err!(SplitUrl::from_str("::")); + assert_err!(SplitUrl::from_str("://:")); + assert_err!(SplitUrl::from_str("a://:")); + assert_err!(SplitUrl::from_str("a://:1243")); + assert_err!(SplitUrl::from_str("a://:65536")); + assert_err!(SplitUrl::from_str("a://:-16")); + assert_err!(SplitUrl::from_str("a:///")); + assert_err!(SplitUrl::from_str("a:///qwer:")); + assert_err!(SplitUrl::from_str("a:///qwer://")); + assert_err!(SplitUrl::from_str("a://qwer://")); + assert_err!(SplitUrl::from_str("a://[1111::2222]:/")); + assert_err!(SplitUrl::from_str("a://[1111::2222]:")); + + assert_split_url_parse!("sch://foo:bar@baz.com:1234/fnord#qux?zuz"); + assert_split_url_parse!("sch://foo:bar@baz.com:1234/fnord#qux"); + assert_split_url_parse!("sch://foo:bar@baz.com:1234/fnord?zuz"); + assert_split_url_parse!("sch://foo:bar@baz.com:1234/fnord/"); + assert_split_url_parse!("sch://foo:bar@baz.com:1234//"); + assert_split_url_parse!("sch://foo:bar@baz.com:1234"); + assert_split_url_parse!("sch://foo:bar@[1111::2222]:1234"); + assert_split_url_parse!("sch://foo:bar@[::]:1234"); + assert_split_url_parse!("sch://foo:bar@1.2.3.4:1234"); + assert_split_url_parse!("sch://@baz.com:1234"); + assert_split_url_parse!("sch://baz.com/asdf/asdf"); + assert_split_url_parse!("sch://baz.com/"); + assert_split_url_parse!("s://s"); +} + +pub async fn test_get_random_u64() { + info!("testing random number generator for u64"); + let t1 = get_timestamp(); + let count = 10000; + for _ in 0..count { + let _ = get_random_u64(); + } + let t2 = get_timestamp(); + let tdiff = ((t2 - t1) as f64) / 1000000.0f64; + info!( + "running network interface test with {} iterations took {} seconds", + count, tdiff + ); +} + +pub async fn test_get_random_u32() { + info!("testing random number generator for u32"); + let t1 = get_timestamp(); + let count = 10000; + for _ in 0..count { + let _ = get_random_u32(); + } + let t2 = get_timestamp(); + let tdiff = ((t2 - t1) as f64) / 1000000.0f64; + info!( + "running network interface test with {} iterations took {} seconds", + count, tdiff + ); +} + +pub async fn test_must_join_single_future() { + info!("testing must join single future"); + let sf = MustJoinSingleFuture::::new(); + assert_eq!(sf.check().await, Ok(None)); + assert_eq!( + sf.single_spawn(async { + sleep(2000).await; + 69 + }) + .await, + Ok((None, true)) + ); + assert_eq!(sf.check().await, Ok(None)); + assert_eq!(sf.single_spawn(async { panic!() }).await, Ok((None, false))); + assert_eq!(sf.join().await, Ok(Some(69))); + assert_eq!( + sf.single_spawn(async { + sleep(1000).await; + 37 + }) + .await, + Ok((None, true)) + ); + sleep(2000).await; + assert_eq!( + sf.single_spawn(async { + sleep(1000).await; + 27 + }) + .await, + Ok((Some(37), true)) + ); + sleep(2000).await; + assert_eq!(sf.join().await, Ok(Some(27))); + assert_eq!(sf.check().await, Ok(None)); +} + +pub async fn test_tools() { + info!("testing retry_falloff_log"); + let mut last_us = 0u64; + for x in 0..1024 { + let cur_us = x as u64 * 1000000u64; + if retry_falloff_log(last_us, cur_us, 10_000_000u64, 6_000_000_000u64, 2.0f64) { + info!(" retry at {} secs", timestamp_to_secs(cur_us)); + last_us = cur_us; + } + } +} + +pub async fn test_all() { + test_log().await; + test_get_timestamp().await; + test_tools().await; + test_split_url().await; + test_get_random_u64().await; + test_get_random_u32().await; + test_sleep().await; + #[cfg(not(target_arch = "wasm32"))] + test_must_join_single_future().await; + test_eventual().await; + test_eventual_value().await; + test_eventual_value_clone().await; + test_interval().await; + test_timeout().await; +} diff --git a/veilid-tools/src/tests/files/cert.pem b/veilid-tools/src/tests/files/cert.pem new file mode 100644 index 00000000..b86846ed --- /dev/null +++ b/veilid-tools/src/tests/files/cert.pem @@ -0,0 +1,88 @@ +Certificate: + Data: + Version: 3 (0x2) + Serial Number: + 12:ce:63:bd:90:f5:ab:de:6d:7f:d7:3e:f3:e6:bb + Signature Algorithm: sha256WithRSAEncryption + Issuer: CN=Veilid Test CA + Validity + Not Before: Nov 22 13:52:16 2021 GMT + Not After : Feb 25 13:52:16 2024 GMT + Subject: CN=Veilid Test Certificate + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + RSA Public-Key: (2048 bit) + Modulus: + 00:cb:2e:7a:47:81:be:6f:6b:53:37:51:c1:50:68: + 5a:44:3d:ba:b9:9b:78:40:84:35:d4:0e:e8:41:a6: + 0e:0a:b9:34:ae:97:a3:37:3e:81:ed:6c:0f:f8:8a: + 8b:0b:1a:ed:06:97:57:6d:49:a5:ec:b4:c4:d8:6d: + d2:57:c3:87:89:99:ee:b0:d7:c5:82:a1:dc:d5:98: + b3:ef:10:da:c0:5c:38:a2:bb:15:3e:0e:5e:bc:a0: + cd:a1:f0:07:67:bb:57:3f:89:cc:72:4f:bb:c0:a7: + ed:ad:15:07:61:c2:b4:21:73:39:00:9b:8f:aa:04: + 1b:c4:9d:d4:00:44:87:b1:79:b4:e1:4e:01:3c:ee: + a4:bb:f9:ad:5d:88:41:03:b4:bf:df:bf:71:24:ee: + 0b:69:59:55:dd:43:d1:91:04:de:98:9c:54:f2:ee: + 63:78:fe:76:19:bf:e6:5d:d6:58:81:3c:1b:02:3d: + 5d:cc:70:4a:c1:84:06:f6:1a:db:16:b0:e0:30:b0: + 3a:85:41:48:a1:88:c5:38:04:7b:03:c4:86:f0:da: + 1a:ff:bc:d1:ac:7f:cd:0c:e8:5a:42:5e:43:7f:0d: + 61:5d:41:67:0f:b8:07:47:21:93:44:b2:ab:fa:d8: + 69:bb:b9:6d:a1:56:6d:23:54:aa:49:67:e7:57:c6: + e9:c7 + Exponent: 65537 (0x10001) + X509v3 extensions: + X509v3 Basic Constraints: + CA:FALSE + X509v3 Subject Key Identifier: + 70:ED:B0:96:71:33:43:16:EF:32:FF:69:11:C9:F0:02:3F:6C:81:88 + X509v3 Authority Key Identifier: + keyid:5D:7F:8D:AF:1A:56:D3:F4:CA:3D:D3:6D:EF:50:11:F7:64:99:6F:02 + DirName:/CN=Veilid Test CA + serial:22:7A:2E:68:7C:DF:7B:81:85:1A:50:98:16:62:22:D0:0B:D6:1C:4A + + X509v3 Extended Key Usage: + TLS Web Server Authentication + X509v3 Key Usage: + Digital Signature, Key Encipherment + X509v3 Subject Alternative Name: + DNS:Veilid Test Certificate + Signature Algorithm: sha256WithRSAEncryption + b8:fc:ac:62:d6:95:af:09:db:24:7d:82:2c:02:e1:d0:7b:f5: + 69:03:a4:42:55:c6:0d:2a:f1:9d:0e:c4:9b:78:40:7d:0d:7d: + ec:66:f6:c4:6d:06:d0:5b:58:de:ba:e6:67:ea:af:41:a3:87: + b4:37:8b:a8:1f:51:ae:70:e0:0d:f5:51:0a:7a:b3:b3:1d:d1: + 77:92:63:35:ae:50:9e:04:3d:04:6e:f1:60:c8:e3:8f:1f:75: + 47:05:27:a0:ff:c5:1b:30:68:b2:f9:5b:e6:f2:81:0f:9b:f2: + e8:8c:9d:b6:57:b2:c1:29:e7:d0:d0:88:b3:ba:8e:78:2e:ef: + ce:03:a3:12:fa:b4:e9:4e:1f:de:1a:cb:77:72:6b:71:98:02: + 37:d2:b4:02:f0:2c:08:67:ca:75:0d:af:81:bf:f8:57:f8:d9: + 4a:93:4f:db:3c:e1:af:3e:ab:9c:fe:87:f0:3a:01:21:6a:5c: + 99:83:e3:03:47:98:15:23:24:b3:ee:29:27:f4:f1:34:c1:e4: + f8:39:5a:92:da:c7:08:dc:71:87:1c:ff:67:e7:ef:24:bc:34: + e3:4e:e0:16:12:84:60:d4:7f:a2:c0:5b:85:a9:c5:ef:78:0b: + c3:64:cb:b4:05:eb:51:e5:c1:0f:60:da:5c:98:08:bf:5d:b9: + 1d:33:a7:26 +-----BEGIN CERTIFICATE----- +MIIDjjCCAnagAwIBAgIPEs5jvZD1q95tf9c+8+a7MA0GCSqGSIb3DQEBCwUAMBkx +FzAVBgNVBAMMDlZlaWxpZCBUZXN0IENBMB4XDTIxMTEyMjEzNTIxNloXDTI0MDIy +NTEzNTIxNlowIjEgMB4GA1UEAwwXVmVpbGlkIFRlc3QgQ2VydGlmaWNhdGUwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDLLnpHgb5va1M3UcFQaFpEPbq5 +m3hAhDXUDuhBpg4KuTSul6M3PoHtbA/4iosLGu0Gl1dtSaXstMTYbdJXw4eJme6w +18WCodzVmLPvENrAXDiiuxU+Dl68oM2h8Adnu1c/icxyT7vAp+2tFQdhwrQhczkA +m4+qBBvEndQARIexebThTgE87qS7+a1diEEDtL/fv3Ek7gtpWVXdQ9GRBN6YnFTy +7mN4/nYZv+Zd1liBPBsCPV3McErBhAb2GtsWsOAwsDqFQUihiMU4BHsDxIbw2hr/ +vNGsf80M6FpCXkN/DWFdQWcPuAdHIZNEsqv62Gm7uW2hVm0jVKpJZ+dXxunHAgMB +AAGjgckwgcYwCQYDVR0TBAIwADAdBgNVHQ4EFgQUcO2wlnEzQxbvMv9pEcnwAj9s +gYgwVAYDVR0jBE0wS4AUXX+NrxpW0/TKPdNt71AR92SZbwKhHaQbMBkxFzAVBgNV +BAMMDlZlaWxpZCBUZXN0IENBghQiei5ofN97gYUaUJgWYiLQC9YcSjATBgNVHSUE +DDAKBggrBgEFBQcDATALBgNVHQ8EBAMCBaAwIgYDVR0RBBswGYIXVmVpbGlkIFRl +c3QgQ2VydGlmaWNhdGUwDQYJKoZIhvcNAQELBQADggEBALj8rGLWla8J2yR9giwC +4dB79WkDpEJVxg0q8Z0OxJt4QH0Nfexm9sRtBtBbWN665mfqr0Gjh7Q3i6gfUa5w +4A31UQp6s7Md0XeSYzWuUJ4EPQRu8WDI448fdUcFJ6D/xRswaLL5W+bygQ+b8uiM +nbZXssEp59DQiLO6jngu784DoxL6tOlOH94ay3dya3GYAjfStALwLAhnynUNr4G/ ++Ff42UqTT9s84a8+q5z+h/A6ASFqXJmD4wNHmBUjJLPuKSf08TTB5Pg5WpLaxwjc +cYcc/2fn7yS8NONO4BYShGDUf6LAW4Wpxe94C8Nky7QF61HlwQ9g2lyYCL9duR0z +pyY= +-----END CERTIFICATE----- diff --git a/veilid-tools/src/tests/files/key.pem b/veilid-tools/src/tests/files/key.pem new file mode 100644 index 00000000..38968f47 --- /dev/null +++ b/veilid-tools/src/tests/files/key.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAyy56R4G+b2tTN1HBUGhaRD26uZt4QIQ11A7oQaYOCrk0rpej +Nz6B7WwP+IqLCxrtBpdXbUml7LTE2G3SV8OHiZnusNfFgqHc1Ziz7xDawFw4orsV +Pg5evKDNofAHZ7tXP4nMck+7wKftrRUHYcK0IXM5AJuPqgQbxJ3UAESHsXm04U4B +PO6ku/mtXYhBA7S/379xJO4LaVlV3UPRkQTemJxU8u5jeP52Gb/mXdZYgTwbAj1d +zHBKwYQG9hrbFrDgMLA6hUFIoYjFOAR7A8SG8Noa/7zRrH/NDOhaQl5Dfw1hXUFn +D7gHRyGTRLKr+thpu7ltoVZtI1SqSWfnV8bpxwIDAQABAoIBAQCae5MjbUWC56JU +7EdEQKNpQVoIp2mt/BgFTPRQfdYtVxX0LX0+krss7r3R5lzDq8xN96HUiWur5uHI +APAuJI+YEr8GHHii0zjZ+onMmg8ItNWm/QGwtjJXzxeqKZsnxqwWtkoJHBCP8d5n +fBapwOU+jaHokV6RESCfxLSdI33cdGcOgDAn4/lvcXZ4Pq0qbitFuZwBPpobHbp4 +Mo94K7oh4KCt3FDMfZshkSF0wlquRIeUsI2uZUofybDa/j1RgEsqBZIrHqM6xXV1 +/r13+mMZC4otE0qhBV9jTYffaxooOnae8/Ve0FgaPWpNm7AD6p7l4a3csIkcggMS +xx7cntR5AoGBAOvPgDDLJ7h+AgY7jAd13/eZ75NtuEWbSq4c4Kwwy1K17L+3isX/ +RRkQ5qGTNsT6j1dddfwzX6Rhsi+JywczEdJdWgGNpFCIa8Ly2+47YLDpv0ZIISIZ +V0Ngg6dyuuQo7gFlLz9Dhe/If32/93gEW6HZOjn+GmQu53ZSDdHvukpjAoGBANyT +0GZzaP2ulV3Pk+9nJhC6eK2BZWF4ODXHsAgNUEyWZ4qDM71oDxyFbaWS2IDg7jz7 +T2wVffRFDcx8oNXWbhWbejSBGHWI8HRk0Ki83K0r7Cj8Uhy53rQjGOsdLf3K9T9h +GGVcwMHlBGIvswqTnJKysvgcoh1Ir+6RqbfCmG5NAoGAaVa8UQ+vor7HcLlRCFQj +xJvDZfxxgMaqSbUkuEbjzQLvy4TWPTSXTWc7X5o/sSasub5KYmsgonHyA0Juq7yo +jWyeNGttp3wJh4CttnJX8y+3/lFiW7UuQi7vIPIjgqC2EXF99ajYQBE0wpvqlHZ9 +6IL9e8KDT5WUWEq3WbzZXzkCgYB/0Md6FnZISdoTui0nFMZh+yvinpB4ookv4L6I +a+6T8rOc99oLbzkSdd7LiwQZ6j0i6R1krC+IVFtimvU39EFmE+oEcqoRsYBkcebX +YFkfn8wBE/Ug4DPEfnH6C7aS0gC68TCJy+2GbYbUvn8pKdAY0aQTUcQ+49fOjmmi +KgjaIQKBgQDoT0af/7a7LnY9dkbkz624HmNVyMPOa4/STrdxyy3NRhq/dysRW+At +x30nvCWpv0Z5BAyaUCrRWPGFxhv3/Z7qb4fx5uUbC3Jc04I5D6fwYqrQofGS8TMK +Lrg83o5Ag++pllu1IeWiGQPRbn7VZ+O6pISgpRpYBexXGyLJ6wtcAw== +-----END RSA PRIVATE KEY----- diff --git a/veilid-tools/src/tests/ios/.gitignore b/veilid-tools/src/tests/ios/.gitignore new file mode 100644 index 00000000..438326e0 --- /dev/null +++ b/veilid-tools/src/tests/ios/.gitignore @@ -0,0 +1,91 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Obj-C/Swift specific +*.hmap + +## App packaging +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +# *.xcodeproj +# +# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata +# hence it is not needed unless you have added a package configuration file to your project +# .swiftpm + +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ +# +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build/ + +# Accio dependency management +Dependencies/ +.accio/ + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. +# Instead, use fastlane to re-generate the screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ + diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilid-tools.c b/veilid-tools/src/tests/ios/veilidtools-tests/veilid-tools.c new file mode 100644 index 00000000..5d59813e --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilid-tools.c @@ -0,0 +1,8 @@ +// +// veilidtools.c +// veilidtools-tests +// +// Created by JSmith on 7/6/21. +// + +#include "veilid-tools.h" diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilid-tools.h b/veilid-tools/src/tests/ios/veilidtools-tests/veilid-tools.h new file mode 100644 index 00000000..8f11707a --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilid-tools.h @@ -0,0 +1,13 @@ +// +// veilid-tools.h +// veilid-tools-tests +// +// Created by JSmith on 7/6/21. +// + +#ifndef veilid_tools_h +#define veilid_tools_h + +void run_veilid_tools_tests(void); + +#endif /* veilid-tools_h */ diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests-Bridging-Header.h b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests-Bridging-Header.h new file mode 100644 index 00000000..3344ec39 --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests-Bridging-Header.h @@ -0,0 +1,5 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +#include "veilid-tools.h" 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 new file mode 100644 index 00000000..b47f1821 --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/project.pbxproj @@ -0,0 +1,413 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + 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 */; }; +/* 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 = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 43C436A9268904AC002D11C5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4317C6B7269490DA009C717F /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; + 43C436A3268904AC002D11C5 = { + isa = PBXGroup; + children = ( + 4317C6BB2694A676009C717F /* veilid-tools.h */, + 4317C6BC2694A676009C717F /* veilid-tools.c */, + 43C436AE268904AC002D11C5 /* veilidtools-tests */, + 43C436AD268904AC002D11C5 /* Products */, + 4317C6B7269490DA009C717F /* Frameworks */, + 4317C6BA2694A675009C717F /* veilidtools-tests-Bridging-Header.h */, + ); + sourceTree = ""; + }; + 43C436AD268904AC002D11C5 /* Products */ = { + isa = PBXGroup; + children = ( + 43C436AC268904AC002D11C5 /* veilidtools-tests.app */, + ); + name = Products; + sourceTree = ""; + }; + 43C436AE268904AC002D11C5 /* 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 */, + ); + path = "veilidtools-tests"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 43C436AB268904AC002D11C5 /* veilidtools-tests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 43C436C0268904AD002D11C5 /* Build configuration list for PBXNativeTarget "veilidtools-tests" */; + buildPhases = ( + 43C436C326893020002D11C5 /* Cargo Build */, + 43C436A8268904AC002D11C5 /* Sources */, + 43C436A9268904AC002D11C5 /* Frameworks */, + 43C436AA268904AC002D11C5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "veilidtools-tests"; + productName = "veilidtools-tests"; + productReference = 43C436AC268904AC002D11C5 /* veilidtools-tests.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 43C436A4268904AC002D11C5 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1250; + LastUpgradeCheck = 1250; + TargetAttributes = { + 43C436AB268904AC002D11C5 = { + CreatedOnToolsVersion = 12.5.1; + LastSwiftMigration = 1250; + }; + }; + }; + buildConfigurationList = 43C436A7268904AC002D11C5 /* Build configuration list for PBXProject "veilidtools-tests" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 43C436A3268904AC002D11C5; + productRefGroup = 43C436AD268904AC002D11C5 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 43C436AB268904AC002D11C5 /* veilidtools-tests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 43C436AA268904AC002D11C5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 43C436BC268904AD002D11C5 /* LaunchScreen.storyboard in Resources */, + 43C436B9268904AD002D11C5 /* Assets.xcassets in Resources */, + 43C436B7268904AC002D11C5 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 43C436C326893020002D11C5 /* Cargo Build */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Cargo Build"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "../../../../ios_build.sh --features ios_tests\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 43C436A8268904AC002D11C5 /* 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 */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 43C436B5268904AC002D11C5 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 43C436B6268904AC002D11C5 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 43C436BA268904AD002D11C5 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 43C436BB268904AD002D11C5 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 43C436BE268904AD002D11C5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = arm64; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.3; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 43C436BF268904AD002D11C5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = arm64; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.3; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 43C436C1268904AD002D11C5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ZJPQSFX5MW; + INFOPLIST_FILE = "veilidtools-tests/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.3; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@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", + "-lveilid_tools", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.veilid.veilidtools-tests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "veilidtools-tests-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 43C436C2268904AD002D11C5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ZJPQSFX5MW; + INFOPLIST_FILE = "veilidtools-tests/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.3; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@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", + "-lveilid_tools", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.veilid.veilidtools-tests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "veilidtools-tests-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 43C436A7268904AC002D11C5 /* Build configuration list for PBXProject "veilidtools-tests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 43C436BE268904AD002D11C5 /* Debug */, + 43C436BF268904AD002D11C5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 43C436C0268904AD002D11C5 /* Build configuration list for PBXNativeTarget "veilidtools-tests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 43C436C1268904AD002D11C5 /* Debug */, + 43C436C2268904AD002D11C5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 43C436A4268904AC002D11C5 /* Project object */; +} diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + 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/veilidcore-tests.xcscheme new file mode 100644 index 00000000..f1525db5 --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests.xcodeproj/xcshareddata/xcschemes/veilidcore-tests.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/AppDelegate.swift b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/AppDelegate.swift new file mode 100644 index 00000000..7b8b8e2b --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/AppDelegate.swift @@ -0,0 +1,37 @@ +// +// AppDelegate.swift +// veilidtools-tests +// +// Created by JSmith on 6/27/21. +// + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window : UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + @available(iOS 13.0, *) + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + @available(iOS 13.0, *) + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Assets.xcassets/AccentColor.colorset/Contents.json b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Assets.xcassets/AppIcon.appiconset/Contents.json b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..9221b9bb --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Assets.xcassets/Contents.json b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Base.lproj/LaunchScreen.storyboard b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..3fd36928 --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Base.lproj/Main.storyboard b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Base.lproj/Main.storyboard new file mode 100644 index 00000000..678f8974 --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Base.lproj/Main.storyboard @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Info.plist b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Info.plist new file mode 100644 index 00000000..5b531f7b --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/Info.plist @@ -0,0 +1,66 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/SceneDelegate.swift b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/SceneDelegate.swift new file mode 100644 index 00000000..5ea6baef --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/SceneDelegate.swift @@ -0,0 +1,53 @@ +// +// SceneDelegate.swift +// veilidtools-tests +// +// Created by JSmith on 6/27/21. +// + +import UIKit + +@available(iOS 13.0, *) +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + 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 new file mode 100644 index 00000000..922d5462 --- /dev/null +++ b/veilid-tools/src/tests/ios/veilidtools-tests/veilidtools-tests/ViewController.swift @@ -0,0 +1,19 @@ +// +// ViewController.swift +// veilidtools-tests +// +// Created by JSmith on 6/27/21. +// + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + run_veilid_tools_tests() + } + + +} + diff --git a/veilid-tools/src/tests/mod.rs b/veilid-tools/src/tests/mod.rs new file mode 100644 index 00000000..0b6b6216 --- /dev/null +++ b/veilid-tools/src/tests/mod.rs @@ -0,0 +1,3 @@ +pub mod common; +#[cfg(not(target_arch = "wasm32"))] +mod native; diff --git a/veilid-tools/src/tests/native/mod.rs b/veilid-tools/src/tests/native/mod.rs new file mode 100644 index 00000000..9ab6f14d --- /dev/null +++ b/veilid-tools/src/tests/native/mod.rs @@ -0,0 +1,152 @@ +//! Test suite for Native +#![cfg(not(target_arch = "wasm32"))] + +mod test_async_peek_stream; + +use crate::tests::common::*; +use crate::*; + +#[cfg(all(target_os = "android", feature = "android_tests"))] +use jni::{objects::JClass, objects::JObject, JNIEnv}; + +#[cfg(all(target_os = "android", feature = "android_tests"))] +#[no_mangle] +#[allow(non_snake_case)] +pub extern "system" fn Java_com_veilid_veilidtools_veilidtools_1android_1tests_MainActivity_run_1tests( + env: JNIEnv, + _class: JClass, + ctx: JObject, +) { + crate::intf::utils::android::veilid_tools_setup_android( + env, + ctx, + "veilid_tools", + crate::veilid_config::VeilidConfigLogLevel::Trace, + ); + run_all_tests(); +} + +#[cfg(all(target_os = "ios", feature = "ios_tests"))] +#[no_mangle] +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())), + ); + run_all_tests(); +} + +/////////////////////////////////////////////////////////////////////////// + +#[allow(dead_code)] +pub fn run_all_tests() { + info!("TEST: exec_test_host_interface"); + exec_test_host_interface(); + info!("TEST: exec_test_async_peek_stream"); + exec_test_async_peek_stream(); + info!("TEST: exec_test_async_tag_lock"); + exec_test_async_tag_lock(); + + info!("Finished unit tests"); +} + +#[cfg(feature = "rt-tokio")] +fn block_on, T>(f: F) -> T { + let rt = tokio::runtime::Runtime::new().unwrap(); + let local = tokio::task::LocalSet::new(); + local.block_on(&rt, f) +} +#[cfg(feature = "rt-async-std")] +fn block_on, T>(f: F) -> T { + async_std::task::block_on(f) +} + +fn exec_test_host_interface() { + block_on(async { + test_host_interface::test_all().await; + }); +} +fn exec_test_async_peek_stream() { + block_on(async { + test_async_peek_stream::test_all().await; + }) +} +fn exec_test_async_tag_lock() { + block_on(async { + test_async_tag_lock::test_all().await; + }) +} +/////////////////////////////////////////////////////////////////////////// +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); + } + TestLogger::init(LevelFilter::Trace, cb.build()).unwrap(); + }); + } + + #[test] + #[serial] + fn run_test_host_interface() { + setup(); + exec_test_host_interface(); + } + + #[test] + #[serial] + fn run_test_async_peek_stream() { + setup(); + exec_test_async_peek_stream(); + } + + #[test] + #[serial] + fn run_test_async_tag_lock() { + setup(); + exec_test_async_tag_lock(); + } + } +} diff --git a/veilid-tools/src/tests/native/test_async_peek_stream.rs b/veilid-tools/src/tests/native/test_async_peek_stream.rs new file mode 100644 index 00000000..0797a4f8 --- /dev/null +++ b/veilid-tools/src/tests/native/test_async_peek_stream.rs @@ -0,0 +1,352 @@ +use crate::*; + +cfg_if! { + if #[cfg(feature="rt-async-std")] { + use async_std::net::{TcpListener, TcpStream}; + use async_std::prelude::FutureExt; + use async_std::task::sleep; + } else if #[cfg(feature="rt-tokio")] { + use tokio::net::{TcpListener, TcpStream}; + use tokio::time::sleep; + use tokio_util::compat::*; + } +} + +use futures_util::{AsyncReadExt, AsyncWriteExt}; +use std::io; + +static MESSAGE: &[u8; 62] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + +async fn make_tcp_loopback() -> Result<(TcpStream, TcpStream), io::Error> { + let listener = TcpListener::bind("127.0.0.1:0").await?; + let local_addr = listener.local_addr()?; + + let accept_future = async { + let (accepted_stream, peer_address) = listener.accept().await?; + trace!("connection from {}", peer_address); + accepted_stream.set_nodelay(true)?; + Result::::Ok(accepted_stream) + }; + let connect_future = async { + sleep(Duration::from_secs(1)).await; + let connected_stream = TcpStream::connect(local_addr).await?; + connected_stream.set_nodelay(true)?; + Result::::Ok(connected_stream) + }; + + cfg_if! { + if #[cfg(feature="rt-async-std")] { + accept_future.try_join(connect_future).await + } else if #[cfg(feature="rt-tokio")] { + tokio::try_join!(accept_future, connect_future) + } + } +} + +async fn make_async_peek_stream_loopback() -> (AsyncPeekStream, AsyncPeekStream) { + let (acc, conn) = make_tcp_loopback().await.unwrap(); + #[cfg(feature = "rt-tokio")] + let acc = acc.compat(); + #[cfg(feature = "rt-tokio")] + let conn = conn.compat(); + + let aps_a = AsyncPeekStream::new(acc); + let aps_c = AsyncPeekStream::new(conn); + + (aps_a, aps_c) +} + +#[cfg(feature = "rt-tokio")] +async fn make_stream_loopback() -> (Compat, Compat) { + let (a, c) = make_tcp_loopback().await.unwrap(); + (a.compat(), c.compat()) +} +#[cfg(feature = "rt-async-std")] +async fn make_stream_loopback() -> (TcpStream, TcpStream) { + make_tcp_loopback().await.unwrap() +} + +pub async fn test_nothing() { + info!("test_nothing"); + let (mut a, mut c) = make_stream_loopback().await; + let outbuf = MESSAGE.to_vec(); + + a.write_all(&outbuf).await.unwrap(); + + let mut inbuf: Vec = Vec::new(); + inbuf.resize(outbuf.len(), 0u8); + c.read_exact(&mut inbuf).await.unwrap(); + + assert_eq!(inbuf, outbuf); +} + +pub async fn test_no_peek() { + info!("test_no_peek"); + let (mut a, mut c) = make_async_peek_stream_loopback().await; + + let outbuf = MESSAGE.to_vec(); + + a.write_all(&outbuf).await.unwrap(); + + let mut inbuf: Vec = Vec::new(); + inbuf.resize(outbuf.len(), 0u8); + c.read_exact(&mut inbuf).await.unwrap(); + + assert_eq!(inbuf, outbuf); +} + +pub async fn test_peek_all_read() { + info!("test_peek_all_read"); + + let (mut a, mut c) = make_async_peek_stream_loopback().await; + // write everything + let outbuf = MESSAGE.to_vec(); + a.write_all(&outbuf).await.unwrap(); + + // peek everything + let mut peekbuf1: Vec = Vec::new(); + peekbuf1.resize(outbuf.len(), 0u8); + let peeksize1 = c.peek(&mut peekbuf1).await.unwrap(); + + assert_eq!(peeksize1, peekbuf1.len()); + // read everything + let mut inbuf: Vec = Vec::new(); + inbuf.resize(outbuf.len(), 0u8); + c.read_exact(&mut inbuf).await.unwrap(); + + assert_eq!(inbuf, outbuf); + assert_eq!(peekbuf1, outbuf); +} + +pub async fn test_peek_some_read() { + info!("test_peek_some_read"); + + let (mut a, mut c) = make_async_peek_stream_loopback().await; + + // write everything + let outbuf = MESSAGE.to_vec(); + a.write_all(&outbuf).await.unwrap(); + + // peek partially + let mut peekbuf1: Vec = Vec::new(); + peekbuf1.resize(outbuf.len() / 2, 0u8); + let peeksize1 = c.peek(&mut peekbuf1).await.unwrap(); + assert_eq!(peeksize1, peekbuf1.len()); + // read everything + let mut inbuf: Vec = Vec::new(); + inbuf.resize(outbuf.len(), 0u8); + c.read_exact(&mut inbuf).await.unwrap(); + + assert_eq!(inbuf, outbuf); + assert_eq!(peekbuf1, outbuf[0..peeksize1].to_vec()); +} + +pub async fn test_peek_some_peek_some_read() { + info!("test_peek_some_peek_some_read"); + + let (mut a, mut c) = make_async_peek_stream_loopback().await; + + // write everything + let outbuf = MESSAGE.to_vec(); + a.write_all(&outbuf).await.unwrap(); + + // peek partially + let mut peekbuf1: Vec = Vec::new(); + peekbuf1.resize(outbuf.len() / 4, 0u8); + let peeksize1 = c.peek(&mut peekbuf1).await.unwrap(); + assert_eq!(peeksize1, peekbuf1.len()); + + // peek partially + let mut peekbuf2: Vec = Vec::new(); + peekbuf2.resize(peeksize1 + 1, 0u8); + let peeksize2 = c.peek(&mut peekbuf2).await.unwrap(); + assert_eq!(peeksize2, peekbuf2.len()); + + // read everything + let mut inbuf: Vec = Vec::new(); + inbuf.resize(outbuf.len(), 0u8); + c.read_exact(&mut inbuf).await.unwrap(); + + assert_eq!(inbuf, outbuf); + assert_eq!(peekbuf1, outbuf[0..peeksize1].to_vec()); + assert_eq!(peekbuf2, outbuf[0..peeksize2].to_vec()); +} + +pub async fn test_peek_some_read_peek_some_read() { + info!("test_peek_some_read_peek_some_read"); + + let (mut a, mut c) = make_async_peek_stream_loopback().await; + + // write everything + let outbuf = MESSAGE.to_vec(); + a.write_all(&outbuf).await.unwrap(); + + // peek partially + let mut peekbuf1: Vec = Vec::new(); + peekbuf1.resize(outbuf.len() / 4, 0u8); + let peeksize1 = c.peek(&mut peekbuf1).await.unwrap(); + assert_eq!(peeksize1, peekbuf1.len()); + + // read partially + let mut inbuf1: Vec = Vec::new(); + inbuf1.resize(peeksize1 - 1, 0u8); + c.read_exact(&mut inbuf1).await.unwrap(); + + // peek partially + let mut peekbuf2: Vec = Vec::new(); + peekbuf2.resize(2, 0u8); + let peeksize2 = c.peek(&mut peekbuf2).await.unwrap(); + assert_eq!(peeksize2, peekbuf2.len()); + + // read partially + let mut inbuf2: Vec = Vec::new(); + inbuf2.resize(2, 0u8); + c.read_exact(&mut inbuf2).await.unwrap(); + + assert_eq!(peekbuf1, outbuf[0..peeksize1].to_vec()); + assert_eq!(inbuf1, outbuf[0..peeksize1 - 1].to_vec()); + assert_eq!(peekbuf2, outbuf[peeksize1 - 1..peeksize1 + 1].to_vec()); + assert_eq!(inbuf2, peekbuf2); +} + +pub async fn test_peek_some_read_peek_all_read() { + info!("test_peek_some_read_peek_all_read"); + + let (mut a, mut c) = make_async_peek_stream_loopback().await; + + // write everything + let outbuf = MESSAGE.to_vec(); + a.write_all(&outbuf).await.unwrap(); + + // peek partially + let mut peekbuf1: Vec = Vec::new(); + peekbuf1.resize(outbuf.len() / 4, 0u8); + let peeksize1 = c.peek(&mut peekbuf1).await.unwrap(); + assert_eq!(peeksize1, peekbuf1.len()); + + // read partially + let mut inbuf1: Vec = Vec::new(); + inbuf1.resize(peeksize1 + 1, 0u8); + c.read_exact(&mut inbuf1).await.unwrap(); + + // peek past end + let mut peekbuf2: Vec = Vec::new(); + peekbuf2.resize(outbuf.len(), 0u8); + let peeksize2 = c.peek(&mut peekbuf2).await.unwrap(); + assert_eq!(peeksize2, outbuf.len() - (peeksize1 + 1)); + + // read remaining + let mut inbuf2: Vec = Vec::new(); + inbuf2.resize(peeksize2, 0u8); + c.read_exact(&mut inbuf2).await.unwrap(); + + assert_eq!(peekbuf1, outbuf[0..peeksize1].to_vec()); + assert_eq!(inbuf1, outbuf[0..peeksize1 + 1].to_vec()); + assert_eq!( + peekbuf2[0..peeksize2].to_vec(), + outbuf[peeksize1 + 1..outbuf.len()].to_vec() + ); + assert_eq!(inbuf2, peekbuf2[0..peeksize2].to_vec()); +} + +pub async fn test_peek_some_read_peek_some_read_all_read() { + info!("test_peek_some_read_peek_some_read_peek_all_read"); + + let (mut a, mut c) = make_async_peek_stream_loopback().await; + + // write everything + let outbuf = MESSAGE.to_vec(); + a.write_all(&outbuf).await.unwrap(); + + // peek partially + let mut peekbuf1: Vec = Vec::new(); + peekbuf1.resize(outbuf.len() / 4, 0u8); + let peeksize1 = c.peek(&mut peekbuf1).await.unwrap(); + assert_eq!(peeksize1, peekbuf1.len()); + + // read partially + let mut inbuf1: Vec = Vec::new(); + inbuf1.resize(peeksize1 - 1, 0u8); + c.read_exact(&mut inbuf1).await.unwrap(); + + // peek partially + let mut peekbuf2: Vec = Vec::new(); + peekbuf2.resize(2, 0u8); + let peeksize2 = c.peek(&mut peekbuf2).await.unwrap(); + assert_eq!(peeksize2, peekbuf2.len()); + // read partially + let mut inbuf2: Vec = Vec::new(); + inbuf2.resize(1, 0u8); + c.read_exact(&mut inbuf2).await.unwrap(); + + // read remaining + let mut inbuf3: Vec = Vec::new(); + inbuf3.resize(outbuf.len() - peeksize1, 0u8); + c.read_exact(&mut inbuf3).await.unwrap(); + + assert_eq!(peekbuf1, outbuf[0..peeksize1].to_vec()); + assert_eq!(inbuf1, outbuf[0..peeksize1 - 1].to_vec()); + assert_eq!( + peekbuf2[0..peeksize2].to_vec(), + outbuf[peeksize1 - 1..peeksize1 + 1].to_vec() + ); + assert_eq!(inbuf2, peekbuf2[0..1].to_vec()); + assert_eq!(inbuf3, outbuf[peeksize1..outbuf.len()].to_vec()); +} + +pub async fn test_peek_exact_read_peek_exact_read_all_read() { + info!("test_peek_exact_read_peek_exact_read_all_read"); + + let (mut a, mut c) = make_async_peek_stream_loopback().await; + + // write everything + let outbuf = MESSAGE.to_vec(); + a.write_all(&outbuf).await.unwrap(); + + // peek partially + let mut peekbuf1: Vec = Vec::new(); + peekbuf1.resize(outbuf.len() / 4, 0u8); + let peeksize1 = c.peek_exact(&mut peekbuf1).await.unwrap(); + assert_eq!(peeksize1, peekbuf1.len()); + + // read partially + let mut inbuf1: Vec = Vec::new(); + inbuf1.resize(peeksize1 - 1, 0u8); + c.read_exact(&mut inbuf1).await.unwrap(); + + // peek partially + let mut peekbuf2: Vec = Vec::new(); + peekbuf2.resize(2, 0u8); + let peeksize2 = c.peek_exact(&mut peekbuf2).await.unwrap(); + assert_eq!(peeksize2, peekbuf2.len()); + // read partially + let mut inbuf2: Vec = Vec::new(); + inbuf2.resize(1, 0u8); + c.read_exact(&mut inbuf2).await.unwrap(); + + // read remaining + let mut inbuf3: Vec = Vec::new(); + inbuf3.resize(outbuf.len() - peeksize1, 0u8); + c.read_exact(&mut inbuf3).await.unwrap(); + + assert_eq!(peekbuf1, outbuf[0..peeksize1].to_vec()); + assert_eq!(inbuf1, outbuf[0..peeksize1 - 1].to_vec()); + assert_eq!( + peekbuf2[0..peeksize2].to_vec(), + outbuf[peeksize1 - 1..peeksize1 + 1].to_vec() + ); + assert_eq!(inbuf2, peekbuf2[0..1].to_vec()); + assert_eq!(inbuf3, outbuf[peeksize1..outbuf.len()].to_vec()); +} + +pub async fn test_all() { + test_nothing().await; + test_no_peek().await; + test_peek_all_read().await; + test_peek_some_read().await; + test_peek_some_peek_some_read().await; + test_peek_some_read_peek_some_read().await; + test_peek_some_read_peek_all_read().await; + test_peek_some_read_peek_some_read_all_read().await; + test_peek_exact_read_peek_exact_read_all_read().await; +} diff --git a/veilid-tools/tests/web.rs b/veilid-tools/tests/web.rs new file mode 100644 index 00000000..7e7c3c5f --- /dev/null +++ b/veilid-tools/tests/web.rs @@ -0,0 +1,87 @@ +//! Test suite for the Web and headless browsers. +#![cfg(target_arch = "wasm32")] + +use veilid_tools::tests::common::*; +use veilid_tools::xx::*; +use wasm_bindgen_test::*; + +wasm_bindgen_test_configure!(run_in_browser); + +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(); + let mut builder = tracing_wasm::WASMLayerConfigBuilder::new(); + builder.set_report_logs_in_timings(false); + builder.set_max_level(Level::TRACE); + builder.set_console_config(tracing_wasm::ConsoleConfig::ReportWithConsoleColor); + tracing_wasm::set_as_global_default_with_config(builder.build()); + }); +} + +#[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_tools() { + setup(); + + test_veilid_tools::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; +}