diff --git a/src/rust/bitbox02-rust-c/Cargo.toml b/src/rust/bitbox02-rust-c/Cargo.toml index 237d48ff9..bdf33a5dd 100644 --- a/src/rust/bitbox02-rust-c/Cargo.toml +++ b/src/rust/bitbox02-rust-c/Cargo.toml @@ -59,7 +59,8 @@ target-c-unit-tests = [ # enable these features "app-bitcoin", "app-ethereum", - "firmware" + "firmware", + "c-unit-testing", ] platform-bitbox02 = [] @@ -67,9 +68,12 @@ platform-bitbox02 = [] bootloader = [] firmware = ["bitbox02-rust", "bitbox02", "bitbox02-noise", "sha2"] -# Only to be enabled in unit tests. +# Only to be enabled in Rust unit tests. testing = ["bitbox02-rust/testing", "bitbox02/testing"] +# Active when the Rust code is compiled to be linked into the C unit tests and simulator. +c-unit-testing = ["bitbox02-rust/c-unit-testing", "bitbox02/c-unit-testing"] + app-ethereum = [ # enable this dep "sha3", diff --git a/src/rust/bitbox02-rust/Cargo.toml b/src/rust/bitbox02-rust/Cargo.toml index c478d58ec..3345d2398 100644 --- a/src/rust/bitbox02-rust/Cargo.toml +++ b/src/rust/bitbox02-rust/Cargo.toml @@ -115,4 +115,6 @@ testing = [ # enable these features "bitbox02/testing" -] \ No newline at end of file +] + +c-unit-testing = [] diff --git a/src/rust/bitbox02/Cargo.toml b/src/rust/bitbox02/Cargo.toml index 1aa2d4295..40ddeb3d0 100644 --- a/src/rust/bitbox02/Cargo.toml +++ b/src/rust/bitbox02/Cargo.toml @@ -29,6 +29,8 @@ lazy_static = { version = "1.4.0", optional = true } [features] # Only to be enabled in unit tests. testing = ["lazy_static"] +# Active when the Rust code is compiled to be linked into the C unit tests and simulator. +c-unit-testing = [] app-ethereum = [] app-bitcoin = [] diff --git a/src/rust/bitbox02/src/lib.rs b/src/rust/bitbox02/src/lib.rs index bbd7dfd07..e5e05280d 100644 --- a/src/rust/bitbox02/src/lib.rs +++ b/src/rust/bitbox02/src/lib.rs @@ -176,7 +176,7 @@ pub fn reboot() -> ! { panic!("reboot called") } -#[cfg(feature = "testing")] +#[cfg(any(feature = "testing", feature = "c-unit-testing"))] pub fn print_stdout(msg: &str) { unsafe { bitbox02_sys::printf(crate::util::str_to_cstr_vec(msg).unwrap().as_ptr());