test work
This commit is contained in:
@@ -14,8 +14,8 @@ default = []
|
||||
rt-async-std = [ "async-std", "async-std-resolver", "async_executors/async_std", "rtnetlink?/smol_socket", "veilid-tools/rt-async-std" ]
|
||||
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", "veilid-tools/rt-tokio" ]
|
||||
|
||||
veilid_core_android_tests = []
|
||||
veilid_core_ios_tests = [ "simplelog" ]
|
||||
veilid_core_android_tests = [ "dep:tracing-android" ]
|
||||
veilid_core_ios_tests = [ "dep:tracing-oslog" ]
|
||||
tracking = []
|
||||
|
||||
[dependencies]
|
||||
@@ -130,7 +130,7 @@ jni = "^0"
|
||||
jni-sys = "^0"
|
||||
ndk = { version = "^0.7" }
|
||||
ndk-glue = { version = "^0.7", features = ["logger"] }
|
||||
tracing-android = { version = "^0" }
|
||||
tracing-android = { version = "^0", optional = true }
|
||||
|
||||
# Dependenices for all Unix (Linux, Android, MacOS, iOS)
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
@@ -148,7 +148,7 @@ windows-permissions = "^0"
|
||||
|
||||
# Dependencies for iOS
|
||||
[target.'cfg(target_os = "ios")'.dependencies]
|
||||
simplelog = { version = "^0", optional = true }
|
||||
tracing-oslog = { 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
|
||||
|
||||
@@ -16,7 +16,9 @@ pub extern "system" fn Java_com_veilid_veilid_1core_1android_1tests_MainActivity
|
||||
ctx: JObject,
|
||||
) {
|
||||
crate::intf::utils::android::veilid_core_setup_android_tests(env, ctx);
|
||||
run_all_tests();
|
||||
block_on(async {
|
||||
run_all_tests().await;
|
||||
})
|
||||
}
|
||||
|
||||
pub fn veilid_core_setup_android_tests(env: JNIEnv, ctx: JObject) {
|
||||
|
||||
+1
-3
@@ -22,7 +22,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
run_tests(this.context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +30,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
this.testThread = new TestThread(this);
|
||||
this.testThread.start();
|
||||
run_tests(this.context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,15 +7,20 @@ use tracing_subscriber::{fmt, prelude::*};
|
||||
#[no_mangle]
|
||||
#[allow(dead_code)]
|
||||
pub extern "C" fn run_veilid_core_tests() {
|
||||
veilid_core_setup_ios_tests();
|
||||
run_all_tests();
|
||||
std::thread::spawn(|| {
|
||||
block_on(async {
|
||||
veilid_core_setup_ios_tests();
|
||||
run_all_tests().await;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
pub fn veilid_core_setup_ios_tests() {
|
||||
// Set up subscriber and layers
|
||||
let filter = VeilidLayerFilter::new(VeilidConfigLogLevel::Trace, None);
|
||||
let fmt_layer = fmt::layer().with_filter(filter);
|
||||
tracing_subscriber::registry().with(fmt_layer).init();
|
||||
tracing_subscriber::registry()
|
||||
.with(OsLogger::new("com.veilid.veilidtools-tests", "default").with_filter(filter))
|
||||
.init();
|
||||
|
||||
panic::set_hook(Box::new(|panic_info| {
|
||||
let bt = Backtrace::new();
|
||||
|
||||
@@ -8,84 +8,40 @@ use crate::*;
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn run_all_tests() {
|
||||
info!("TEST: exec_test_host_interface");
|
||||
exec_test_host_interface();
|
||||
info!("TEST: exec_test_dht_key");
|
||||
exec_test_dht_key();
|
||||
info!("TEST: exec_test_veilid_core");
|
||||
exec_test_veilid_core();
|
||||
info!("TEST: exec_test_veilid_config");
|
||||
exec_test_veilid_config();
|
||||
info!("TEST: exec_test_connection_table");
|
||||
exec_test_connection_table();
|
||||
info!("TEST: exec_test_table_store");
|
||||
exec_test_table_store();
|
||||
info!("TEST: exec_test_protected_store");
|
||||
exec_test_protected_store();
|
||||
info!("TEST: exec_test_crypto");
|
||||
exec_test_crypto();
|
||||
info!("TEST: exec_test_envelope_receipt");
|
||||
exec_test_envelope_receipt();
|
||||
pub async fn run_all_tests() {
|
||||
info!("TEST: test_host_interface");
|
||||
test_host_interface::test_all().await;
|
||||
info!("TEST: test_dht_key");
|
||||
test_dht_key::test_all().await;
|
||||
info!("TEST: test_veilid_core");
|
||||
test_veilid_core::test_all().await;
|
||||
info!("TEST: test_veilid_config");
|
||||
test_veilid_config::test_all().await;
|
||||
info!("TEST: test_connection_table");
|
||||
test_connection_table::test_all().await;
|
||||
info!("TEST: test_table_store");
|
||||
test_table_store::test_all().await;
|
||||
info!("TEST: test_protected_store");
|
||||
test_protected_store::test_all().await;
|
||||
info!("TEST: test_crypto");
|
||||
test_crypto::test_all().await;
|
||||
info!("TEST: test_envelope_receipt");
|
||||
test_envelope_receipt::test_all().await;
|
||||
|
||||
info!("Finished unit tests");
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[cfg(feature = "rt-tokio")]
|
||||
fn block_on<F: Future<Output = T>, T>(f: F) -> T {
|
||||
pub fn block_on<F: Future<Output = T>, 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<F: Future<Output = T>, T>(f: F) -> T {
|
||||
async_std::task::block_on(f)
|
||||
rt.block_on(f)
|
||||
}
|
||||
|
||||
fn exec_test_host_interface() {
|
||||
block_on(async {
|
||||
test_host_interface::test_all().await;
|
||||
});
|
||||
}
|
||||
fn exec_test_dht_key() {
|
||||
block_on(async {
|
||||
test_dht_key::test_all().await;
|
||||
});
|
||||
}
|
||||
fn exec_test_veilid_core() {
|
||||
block_on(async {
|
||||
test_veilid_core::test_all().await;
|
||||
});
|
||||
}
|
||||
fn exec_test_veilid_config() {
|
||||
block_on(async {
|
||||
test_veilid_config::test_all().await;
|
||||
})
|
||||
}
|
||||
fn exec_test_connection_table() {
|
||||
block_on(async {
|
||||
test_connection_table::test_all().await;
|
||||
})
|
||||
}
|
||||
fn exec_test_table_store() {
|
||||
block_on(async {
|
||||
test_table_store::test_all().await;
|
||||
})
|
||||
}
|
||||
fn exec_test_protected_store() {
|
||||
block_on(async {
|
||||
test_protected_store::test_all().await;
|
||||
})
|
||||
}
|
||||
fn exec_test_crypto() {
|
||||
block_on(async {
|
||||
test_crypto::test_all().await;
|
||||
})
|
||||
}
|
||||
fn exec_test_envelope_receipt() {
|
||||
block_on(async {
|
||||
test_envelope_receipt::test_all().await;
|
||||
})
|
||||
#[cfg(feature = "rt-async-std")]
|
||||
#[allow(dead_code)]
|
||||
pub fn block_on<F: Future<Output = T>, T>(f: F) -> T {
|
||||
async_std::task::block_on(f)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -119,63 +75,81 @@ cfg_if! {
|
||||
#[serial]
|
||||
fn run_test_host_interface() {
|
||||
setup();
|
||||
exec_test_host_interface();
|
||||
block_on(async {
|
||||
test_host_interface::test_all().await;
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_dht_key() {
|
||||
setup();
|
||||
exec_test_dht_key();
|
||||
block_on(async {
|
||||
test_dht_key::test_all().await;
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_veilid_core() {
|
||||
setup();
|
||||
exec_test_veilid_core();
|
||||
block_on(async {
|
||||
test_veilid_core::test_all().await;
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_veilid_config() {
|
||||
setup();
|
||||
exec_test_veilid_config();
|
||||
block_on(async {
|
||||
test_veilid_config::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_connection_table() {
|
||||
setup();
|
||||
exec_test_connection_table();
|
||||
block_on(async {
|
||||
test_connection_table::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_table_store() {
|
||||
setup();
|
||||
exec_test_table_store();
|
||||
block_on(async {
|
||||
test_table_store::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_protected_store() {
|
||||
setup();
|
||||
exec_test_protected_store();
|
||||
block_on(async {
|
||||
test_protected_store::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_crypto() {
|
||||
setup();
|
||||
exec_test_crypto();
|
||||
block_on(async {
|
||||
test_crypto::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn run_test_envelope_receipt() {
|
||||
setup();
|
||||
exec_test_envelope_receipt();
|
||||
block_on(async {
|
||||
test_envelope_receipt::test_all().await;
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user