mirror of
https://gitlab.com/veilid/veilid.git
synced 2026-10-13 01:42:13 -05:00
more test work
This commit is contained in:
1 parent
edc87cd78e
commit
89dd5da522
65 files changed
+175
-283
No files matched your search
@@ -3,7 +3,7 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
pushd $SCRIPTDIR 2>/dev/null
|
||||
if [[ "$1" == "wasm" ]]; then
|
||||
WASM_BINDGEN_TEST_TIMEOUT=120 wasm-pack test --chrome --headless
|
||||
WASM_BINDGEN_TEST_TIMEOUT=120 wasm-pack test --firefox --headless
|
||||
elif [[ "$1" == "ios" ]]; then
|
||||
SYMROOT=/tmp/testout
|
||||
APPNAME=veilidcore-tests
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
// xxx : support for android older than API 24, if we need it someday
|
||||
//mod android_get_if_addrs;
|
||||
//pub use android_get_if_addrs::*;
|
||||
|
||||
mod get_directories;
|
||||
pub use get_directories::*;
|
||||
|
||||
use crate::veilid_config::VeilidConfigLogLevel;
|
||||
use crate::*;
|
||||
use backtrace::Backtrace;
|
||||
use jni::errors::Result as JniResult;
|
||||
use jni::{objects::GlobalRef, objects::JObject, objects::JString, JNIEnv, JavaVM};
|
||||
use jni::{objects::GlobalRef, objects::JObject, JNIEnv, JavaVM};
|
||||
use lazy_static::*;
|
||||
use std::panic;
|
||||
use tracing::*;
|
||||
use tracing_subscriber::prelude::*;
|
||||
use tracing_subscriber::*;
|
||||
|
||||
pub struct AndroidGlobals {
|
||||
pub vm: JavaVM,
|
||||
@@ -32,63 +22,13 @@ lazy_static! {
|
||||
pub static ref ANDROID_GLOBALS: Arc<Mutex<Option<AndroidGlobals>>> = Arc::new(Mutex::new(None));
|
||||
}
|
||||
|
||||
pub fn veilid_core_setup_android_no_log<'a>(env: JNIEnv<'a>, ctx: JObject<'a>) {
|
||||
pub fn veilid_core_setup_android(env: JNIEnv, ctx: JObject) {
|
||||
*ANDROID_GLOBALS.lock() = Some(AndroidGlobals {
|
||||
vm: env.get_java_vm().unwrap(),
|
||||
ctx: env.new_global_ref(ctx).unwrap(),
|
||||
});
|
||||
}
|
||||
|
||||
pub fn veilid_core_setup_android<'a>(
|
||||
env: JNIEnv<'a>,
|
||||
ctx: JObject<'a>,
|
||||
log_tag: &'a str,
|
||||
log_level: VeilidConfigLogLevel,
|
||||
) {
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "tracing")] {
|
||||
// Set up subscriber and layers
|
||||
let subscriber = Registry::default();
|
||||
let mut layers = Vec::new();
|
||||
let filter = VeilidLayerFilter::new(log_level, None);
|
||||
let layer = tracing_android::layer(log_tag)
|
||||
.expect("failed to set up android logging")
|
||||
.with_filter(filter.clone());
|
||||
layers.push(layer.boxed());
|
||||
|
||||
let subscriber = subscriber.with(layers);
|
||||
subscriber
|
||||
.try_init()
|
||||
.expect("failed to init android tracing");
|
||||
}
|
||||
}
|
||||
// Set up panic hook for backtraces
|
||||
panic::set_hook(Box::new(|panic_info| {
|
||||
let bt = Backtrace::new();
|
||||
if let Some(location) = panic_info.location() {
|
||||
error!(
|
||||
"panic occurred in file '{}' at line {}",
|
||||
location.file(),
|
||||
location.line(),
|
||||
);
|
||||
} else {
|
||||
error!("panic occurred but can't get location information...");
|
||||
}
|
||||
if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
|
||||
error!("panic payload: {:?}", s);
|
||||
} else if let Some(s) = panic_info.payload().downcast_ref::<String>() {
|
||||
error!("panic payload: {:?}", s);
|
||||
} else if let Some(a) = panic_info.payload().downcast_ref::<std::fmt::Arguments>() {
|
||||
error!("panic payload: {:?}", a);
|
||||
} else {
|
||||
error!("no panic payload");
|
||||
}
|
||||
error!("Backtrace:\n{:?}", bt);
|
||||
}));
|
||||
|
||||
veilid_core_setup_android_no_log(env, ctx);
|
||||
}
|
||||
|
||||
pub fn get_android_globals() -> (JavaVM, GlobalRef) {
|
||||
let globals_locked = ANDROID_GLOBALS.lock();
|
||||
let globals = globals_locked.as_ref().unwrap();
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
use backtrace::Backtrace;
|
||||
use log::*;
|
||||
use simplelog::*;
|
||||
use std::fs::OpenOptions;
|
||||
use std::panic;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub fn veilid_core_setup<'a>(
|
||||
log_tag: &'a str,
|
||||
terminal_log: Option<Level>,
|
||||
file_log: Option<(Level, &Path)>,
|
||||
) {
|
||||
if let Err(e) = veilid_core_setup_internal(log_tag, terminal_log, file_log) {
|
||||
panic!("failed to set up veilid-core: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
fn veilid_core_setup_internal<'a>(
|
||||
_log_tag: &'a str,
|
||||
terminal_log: Option<Level>,
|
||||
file_log: Option<(Level, &Path)>,
|
||||
) -> Result<(), String> {
|
||||
let mut logs: Vec<Box<dyn SharedLogger>> = Vec::new();
|
||||
|
||||
let mut cb = ConfigBuilder::new();
|
||||
for ig in veilid_core::DEFAULT_LOG_IGNORE_LIST {
|
||||
cb.add_filter_ignore_str(ig);
|
||||
}
|
||||
|
||||
if let Some(level) = terminal_log {
|
||||
logs.push(TermLogger::new(
|
||||
level.to_level_filter(),
|
||||
cb.build(),
|
||||
TerminalMode::Mixed,
|
||||
ColorChoice::Auto,
|
||||
))
|
||||
}
|
||||
if let Some((level, log_path)) = file_log {
|
||||
let logfile = OpenOptions::new()
|
||||
.truncate(true)
|
||||
.create(true)
|
||||
.write(true)
|
||||
.open(log_path)
|
||||
.map_err(|e| {
|
||||
format!(
|
||||
"log open error: {} path={:?} all_dirs={:?}",
|
||||
e,
|
||||
log_path,
|
||||
std::fs::read_dir(std::env::var("HOME").unwrap())
|
||||
.unwrap()
|
||||
.map(|d| d.unwrap().path())
|
||||
.collect::<Vec<PathBuf>>()
|
||||
)
|
||||
})?;
|
||||
logs.push(WriteLogger::new(
|
||||
level.to_level_filter(),
|
||||
cb.build(),
|
||||
logfile,
|
||||
))
|
||||
}
|
||||
CombinedLogger::init(logs).map_err(|e| format!("logger init error: {}", e))?;
|
||||
|
||||
panic::set_hook(Box::new(|panic_info| {
|
||||
let bt = Backtrace::new();
|
||||
if let Some(location) = panic_info.location() {
|
||||
error!(
|
||||
"panic occurred in file '{}' at line {}",
|
||||
location.file(),
|
||||
location.line(),
|
||||
);
|
||||
} else {
|
||||
error!("panic occurred but can't get location information...");
|
||||
}
|
||||
if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
|
||||
error!("panic payload: {:?}", s);
|
||||
} else if let Some(s) = panic_info.payload().downcast_ref::<String>() {
|
||||
error!("panic payload: {:?}", s);
|
||||
} else if let Some(a) = panic_info.payload().downcast_ref::<std::fmt::Arguments>() {
|
||||
error!("panic payload: {:?}", a);
|
||||
} else {
|
||||
error!("no panic payload");
|
||||
}
|
||||
error!("Backtrace:\n{:?}", bt);
|
||||
}));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -10,6 +10,4 @@ pub use table_store::*;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub mod android;
|
||||
#[cfg(all(target_os = "ios", feature = "veilid_core_ios_tests"))]
|
||||
pub mod ios_test_setup;
|
||||
pub mod network_interfaces;
|
||||
@@ -59,7 +59,7 @@ pub fn veilid_version() -> (u32, u32, u32) {
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub use intf::utils::android::{veilid_core_setup_android, veilid_core_setup_android_no_log};
|
||||
pub use intf::utils::android::veilid_core_setup_android;
|
||||
|
||||
pub static DEFAULT_LOG_IGNORE_LIST: [&str; 21] = [
|
||||
"mio",
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
use crate::*;
|
||||
use backtrace::Backtrace;
|
||||
use jni::{
|
||||
objects::GlobalRef, objects::JClass, objects::JObject, objects::JString, JNIEnv, JavaVM,
|
||||
};
|
||||
use lazy_static::*;
|
||||
use std::panic;
|
||||
use tracing::*;
|
||||
use tracing_subscriber::prelude::*;
|
||||
use tracing_subscriber::*;
|
||||
|
||||
#[no_mangle]
|
||||
#[allow(non_snake_case)]
|
||||
pub extern "system" fn Java_com_veilid_veilid_1core_1android_1tests_MainActivity_run_1tests(
|
||||
env: JNIEnv,
|
||||
_class: JClass,
|
||||
ctx: JObject,
|
||||
) {
|
||||
crate::intf::utils::android::veilid_core_setup_android_tests(env, ctx);
|
||||
run_all_tests();
|
||||
}
|
||||
|
||||
pub fn veilid_core_setup_android_tests(env: JNIEnv, ctx: JObject) {
|
||||
// Set up subscriber and layers
|
||||
use tracing_subscriber::{filter, fmt, prelude::*};
|
||||
let filter = VeilidLayerFilter::new(VeilidConfigLogLevel::Trace, None);
|
||||
let layer = tracing_android::layer("veilid-core").expect("failed to set up android logging");
|
||||
tracing_subscriber::registry()
|
||||
.with(filters)
|
||||
.with(fmt_layer)
|
||||
.init();
|
||||
|
||||
// Set up panic hook for backtraces
|
||||
panic::set_hook(Box::new(|panic_info| {
|
||||
let bt = Backtrace::new();
|
||||
if let Some(location) = panic_info.location() {
|
||||
error!(
|
||||
"panic occurred in file '{}' at line {}",
|
||||
location.file(),
|
||||
location.line(),
|
||||
);
|
||||
} else {
|
||||
error!("panic occurred but can't get location information...");
|
||||
}
|
||||
if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
|
||||
error!("panic payload: {:?}", s);
|
||||
} else if let Some(s) = panic_info.payload().downcast_ref::<String>() {
|
||||
error!("panic payload: {:?}", s);
|
||||
} else if let Some(a) = panic_info.payload().downcast_ref::<std::fmt::Arguments>() {
|
||||
error!("panic payload: {:?}", a);
|
||||
} else {
|
||||
error!("no panic payload");
|
||||
}
|
||||
error!("Backtrace:\n{:?}", bt);
|
||||
}));
|
||||
|
||||
veilid_core_setup_android(env, ctx);
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -60,10 +60,10 @@ dependencies {
|
||||
apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
|
||||
|
||||
cargo {
|
||||
module = "../../../../"
|
||||
module = "../../../../../"
|
||||
libname = "veilid_core"
|
||||
targets = ["arm", "arm64", "x86", "x86_64"]
|
||||
targetDirectory = "../../../../../target"
|
||||
targetDirectory = "../../../../../../target"
|
||||
prebuiltToolchains = true
|
||||
profile = gradle.startParameter.taskNames.any{it.toLowerCase().contains("debug")} ? "debug" : "release"
|
||||
pythonCommand = "python3"
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,45 @@
|
||||
use crate::*;
|
||||
use backtrace::Backtrace;
|
||||
use std::panic;
|
||||
|
||||
#[no_mangle]
|
||||
#[allow(dead_code)]
|
||||
pub extern "C" fn run_veilid_core_tests() {
|
||||
veilid_core_setup_ios_tests();
|
||||
run_all_tests();
|
||||
}
|
||||
|
||||
pub fn veilid_core_setup_ios_tests() {
|
||||
// Set up subscriber and layers
|
||||
use tracing_subscriber::{filter, fmt, prelude::*};
|
||||
let filter = VeilidLayerFilter::new(VeilidConfigLogLevel::Trace, None);
|
||||
let fmt_layer = fmt::layer();
|
||||
let layer = tracing_android::layer("veilid-core").expect("failed to set up android logging");
|
||||
tracing_subscriber::registry()
|
||||
.with(filters)
|
||||
.with(fmt_layer)
|
||||
.init();
|
||||
|
||||
panic::set_hook(Box::new(|panic_info| {
|
||||
let bt = Backtrace::new();
|
||||
if let Some(location) = panic_info.location() {
|
||||
error!(
|
||||
"panic occurred in file '{}' at line {}",
|
||||
location.file(),
|
||||
location.line(),
|
||||
);
|
||||
} else {
|
||||
error!("panic occurred but can't get location information...");
|
||||
}
|
||||
if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
|
||||
error!("panic payload: {:?}", s);
|
||||
} else if let Some(s) = panic_info.payload().downcast_ref::<String>() {
|
||||
error!("panic payload: {:?}", s);
|
||||
} else if let Some(a) = panic_info.payload().downcast_ref::<std::fmt::Arguments>() {
|
||||
error!("panic payload: {:?}", a);
|
||||
} else {
|
||||
error!("no panic payload");
|
||||
}
|
||||
error!("Backtrace:\n{:?}", bt);
|
||||
}));
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#[cfg(target_os = "android")]
|
||||
#[cfg(all(target_os = "android", feature = "veilid_core_android_tests"))]
|
||||
mod android;
|
||||
pub mod common;
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(all(target_os = "ios", feature = "veilid_core_ios_tests"))]
|
||||
mod ios;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
mod native;
|
||||
|
||||
@@ -5,44 +5,6 @@ use crate::network_manager::tests::*;
|
||||
use crate::tests::common::*;
|
||||
use crate::*;
|
||||
|
||||
#[cfg(all(target_os = "android", feature = "veilid_core_android_tests"))]
|
||||
use jni::{objects::JClass, objects::JObject, JNIEnv};
|
||||
|
||||
#[cfg(all(target_os = "android", feature = "veilid_core_android_tests"))]
|
||||
#[no_mangle]
|
||||
#[allow(non_snake_case)]
|
||||
pub extern "system" fn Java_com_veilid_veilid_1core_1android_1tests_MainActivity_run_1tests(
|
||||
env: JNIEnv,
|
||||
_class: JClass,
|
||||
ctx: JObject,
|
||||
) {
|
||||
crate::intf::utils::android::veilid_core_setup_android(
|
||||
env,
|
||||
ctx,
|
||||
"veilid_core",
|
||||
crate::veilid_config::VeilidConfigLogLevel::Trace,
|
||||
);
|
||||
run_all_tests();
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "ios", feature = "veilid_core_ios_tests"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn run_veilid_core_tests() {
|
||||
let log_path: std::path::PathBuf = [
|
||||
std::env::var("HOME").unwrap().as_str(),
|
||||
"Documents",
|
||||
"veilid-core.log",
|
||||
]
|
||||
.iter()
|
||||
.collect();
|
||||
crate::intf::utils::ios_test_setup::veilid_core_setup(
|
||||
"veilid-core",
|
||||
Some(Level::Trace),
|
||||
Some((Level::Trace, log_path.as_path())),
|
||||
);
|
||||
run_all_tests();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[allow(dead_code)]
|
||||
@@ -130,18 +92,26 @@ fn exec_test_envelope_receipt() {
|
||||
cfg_if! {
|
||||
if #[cfg(test)] {
|
||||
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 crate::DEFAULT_LOG_IGNORE_LIST {
|
||||
cb.add_filter_ignore_str(ig);
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "tracing")] {
|
||||
use tracing_subscriber::{filter, fmt, prelude::*};
|
||||
let mut filters = filter::Targets::new().with_default(filter::LevelFilter::TRACE);
|
||||
for ig in DEFAULT_LOG_IGNORE_LIST {
|
||||
filters = filters.with_target(ig, filter::LevelFilter::OFF);
|
||||
}
|
||||
let fmt_layer = fmt::layer();
|
||||
tracing_subscriber::registry()
|
||||
.with(fmt_layer)
|
||||
.with(filters)
|
||||
.init();
|
||||
}
|
||||
}
|
||||
TestLogger::init(LevelFilter::Trace, cb.build()).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"moz:firefoxOptions": {
|
||||
"prefs": {
|
||||
"media.navigator.streams.fake": true,
|
||||
"media.navigator.permission.disabled": true
|
||||
},
|
||||
"args": []
|
||||
},
|
||||
"goog:chromeOptions": {
|
||||
"args": [
|
||||
"--use-fake-device-for-media-stream",
|
||||
"--use-fake-ui-for-media-stream"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
pushd $SCRIPTDIR 2>/dev/null
|
||||
if [[ "$1" == "wasm" ]]; then
|
||||
WASM_BINDGEN_TEST_TIMEOUT=120 wasm-pack test --chrome --headless
|
||||
WASM_BINDGEN_TEST_TIMEOUT=120 wasm-pack test --firefox --headless
|
||||
elif [[ "$1" == "ios" ]]; then
|
||||
SYMROOT=/tmp/testout
|
||||
APPNAME=veilidtools-tests
|
||||
@@ -56,9 +56,9 @@ elif [[ "$1" == "android" ]]; then
|
||||
popd >/dev/null
|
||||
|
||||
else
|
||||
cargo test --features=rt-tokio,tracing
|
||||
cargo test --features=rt-async-std,tracing
|
||||
cargo test --features=rt-tokio
|
||||
cargo test --features=rt-async-std
|
||||
cargo test --features=rt-tokio,tracing -- --nocapture
|
||||
cargo test --features=rt-async-std,tracing -- --nocapture
|
||||
cargo test --features=rt-tokio -- --nocapture
|
||||
cargo test --features=rt-async-std -- --nocapture
|
||||
fi
|
||||
popd 2>/dev/null
|
||||
@@ -1,35 +1,25 @@
|
||||
use super::native::*;
|
||||
use super::*;
|
||||
|
||||
//use jni::errors::Result as JniResult;
|
||||
use jni::{objects::GlobalRef, objects::JObject, JNIEnv, JavaVM};
|
||||
use lazy_static::*;
|
||||
use std::backtrace::Backtrace;
|
||||
use std::panic;
|
||||
|
||||
pub struct AndroidGlobals {
|
||||
pub vm: JavaVM,
|
||||
pub ctx: GlobalRef,
|
||||
use jni::{objects::JClass, objects::JObject, JNIEnv};
|
||||
|
||||
#[no_mangle]
|
||||
#[allow(non_snake_case)]
|
||||
pub extern "system" fn Java_com_veilid_veilid_1tools_1android_1tests_MainActivity_run_1tests(
|
||||
_env: JNIEnv,
|
||||
_class: JClass,
|
||||
_ctx: JObject,
|
||||
) {
|
||||
crate::tests::android::veilid_tools_setup_android_tests();
|
||||
run_all_tests();
|
||||
}
|
||||
|
||||
impl Drop for AndroidGlobals {
|
||||
fn drop(&mut self) {
|
||||
// Ensure we're attached before dropping GlobalRef
|
||||
self.vm.attach_current_thread_as_daemon().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref ANDROID_GLOBALS: Arc<Mutex<Option<AndroidGlobals>>> = Arc::new(Mutex::new(None));
|
||||
}
|
||||
|
||||
pub fn veilid_tools_setup_android_no_log<'a>(env: JNIEnv<'a>, ctx: JObject<'a>) {
|
||||
*ANDROID_GLOBALS.lock() = Some(AndroidGlobals {
|
||||
vm: env.get_java_vm().unwrap(),
|
||||
ctx: env.new_global_ref(ctx).unwrap(),
|
||||
});
|
||||
}
|
||||
|
||||
pub fn veilid_tools_setup<'a>(env: JNIEnv<'a>, ctx: JObject<'a>, log_tag: &'a str) {
|
||||
pub fn veilid_tools_setup_android_tests() {
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "tracing")] {
|
||||
use tracing::*;
|
||||
@@ -44,7 +34,7 @@ pub fn veilid_tools_setup<'a>(env: JNIEnv<'a>, ctx: JObject<'a>, log_tag: &'a st
|
||||
// Set up subscriber and layers
|
||||
let subscriber = Registry::default();
|
||||
let mut layers = Vec::new();
|
||||
let layer = tracing_android::layer(log_tag)
|
||||
let layer = tracing_android::layer("veilid-tools")
|
||||
.expect("failed to set up android logging")
|
||||
.with_filter(filter::LevelFilter::TRACE)
|
||||
.with_filter(filters);
|
||||
@@ -89,25 +79,4 @@ pub fn veilid_tools_setup<'a>(env: JNIEnv<'a>, ctx: JObject<'a>, log_tag: &'a st
|
||||
}
|
||||
error!("Backtrace:\n{:?}", bt);
|
||||
}));
|
||||
|
||||
veilid_tools_setup_android_no_log(env, ctx);
|
||||
}
|
||||
|
||||
// pub fn get_android_globals() -> (JavaVM, GlobalRef) {
|
||||
// let globals_locked = ANDROID_GLOBALS.lock();
|
||||
// let globals = globals_locked.as_ref().unwrap();
|
||||
// let env = globals.vm.attach_current_thread_as_daemon().unwrap();
|
||||
// let vm = env.get_java_vm().unwrap();
|
||||
// let ctx = globals.ctx.clone();
|
||||
// (vm, ctx)
|
||||
// }
|
||||
|
||||
// pub fn with_null_local_frame<'b, T, F>(env: JNIEnv<'b>, s: i32, f: F) -> JniResult<T>
|
||||
// where
|
||||
// F: FnOnce() -> JniResult<T>,
|
||||
// {
|
||||
// env.push_local_frame(s)?;
|
||||
// let out = f();
|
||||
// env.pop_local_frame(JObject::null())?;
|
||||
// out
|
||||
// }
|
||||
@@ -1,9 +1,16 @@
|
||||
use super::native::*;
|
||||
use super::*;
|
||||
|
||||
use std::backtrace::Backtrace;
|
||||
use std::panic;
|
||||
|
||||
pub fn veilid_tools_setup<'a>() -> Result<(), String> {
|
||||
#[no_mangle]
|
||||
pub extern "C" fn run_veilid_tools_tests() {
|
||||
crate::tests::ios::veilid_tools_setup_ios_tests();
|
||||
run_all_tests();
|
||||
}
|
||||
|
||||
pub fn veilid_tools_setup_ios_tests() {
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "tracing")] {
|
||||
use tracing_subscriber::{filter, fmt, prelude::*};
|
||||
@@ -30,7 +37,7 @@ pub fn veilid_tools_setup<'a>() -> Result<(), String> {
|
||||
TerminalMode::Mixed,
|
||||
ColorChoice::Auto,
|
||||
));
|
||||
CombinedLogger::init(logs).map_err(|e| format!("logger init error: {}", e))?;
|
||||
CombinedLogger::init(logs).expect("logger init error");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +63,4 @@ pub fn veilid_tools_setup<'a>() -> Result<(), String> {
|
||||
}
|
||||
error!("Backtrace:\n{:?}", bt);
|
||||
}));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#[cfg(target_os = "android")]
|
||||
#[cfg(all(target_os = "android", feature = "veilid_tools_android_tests"))]
|
||||
mod android;
|
||||
pub mod common;
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(all(target_os = "ios", feature = "veilid_tools_ios_tests"))]
|
||||
mod ios;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
mod native;
|
||||
|
||||
@@ -5,30 +5,8 @@ mod test_async_peek_stream;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[cfg(all(target_os = "android", feature = "veilid_tools_android_tests"))]
|
||||
use jni::{objects::JClass, objects::JObject, JNIEnv};
|
||||
|
||||
#[cfg(all(target_os = "android", feature = "veilid_tools_android_tests"))]
|
||||
#[no_mangle]
|
||||
#[allow(non_snake_case)]
|
||||
pub extern "system" fn Java_com_veilid_veilid_1tools_1android_1tests_MainActivity_run_1tests(
|
||||
env: JNIEnv,
|
||||
_class: JClass,
|
||||
ctx: JObject,
|
||||
) {
|
||||
crate::tests::android::veilid_tools_setup(env, ctx, "veilid-tools");
|
||||
run_all_tests();
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "ios", feature = "veilid_tools_ios_tests"))]
|
||||
#[no_mangle]
|
||||
#[allow(dead_code)]
|
||||
pub extern "C" fn run_veilid_tools_tests() {
|
||||
crate::tests::ios::veilid_tools_setup().expect("setup failed");
|
||||
run_all_tests();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// Allow access to tests from non cfg(test), as required for android and ios tests
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn run_all_tests() {
|
||||
@@ -68,6 +46,7 @@ fn exec_test_async_tag_lock() {
|
||||
test_async_tag_lock::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
cfg_if! {
|
||||
if #[cfg(test)] {
|
||||
@@ -83,15 +62,14 @@ cfg_if! {
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "tracing")] {
|
||||
use tracing_subscriber::{filter, fmt, prelude::*};
|
||||
let mut filters = filter::Targets::new();
|
||||
let mut filters = filter::Targets::new().with_default(filter::LevelFilter::TRACE);
|
||||
for ig in DEFAULT_LOG_IGNORE_LIST {
|
||||
filters = filters.with_target(ig, filter::LevelFilter::OFF);
|
||||
}
|
||||
let fmt_layer = fmt::layer();
|
||||
tracing_subscriber::registry()
|
||||
.with(filters)
|
||||
.with(filter::LevelFilter::TRACE)
|
||||
.with(fmt_layer)
|
||||
.with(filters)
|
||||
.init();
|
||||
} else {
|
||||
use simplelog::*;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#![cfg(target_arch = "wasm32")]
|
||||
|
||||
use veilid_tools::tests::*;
|
||||
use veilid_tools::*;
|
||||
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
|
||||
Reference in new issue
Block a user