From 0a4c77520d93e7fe6d3fcb4e23e556a6ff9f2915 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 8 Jan 2022 00:46:59 +0800 Subject: [PATCH 1/2] fix test compilation issue --- xous-rs/src/definitions.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xous-rs/src/definitions.rs b/xous-rs/src/definitions.rs index 18937f691..c27f7bd7c 100644 --- a/xous-rs/src/definitions.rs +++ b/xous-rs/src/definitions.rs @@ -39,16 +39,17 @@ pub const EC_REGION_LEN: u32 = 0x0008_0000; pub const PDDB_LOC: u32 = 0x0100_0000; // PDDB start pub const PDDB_LEN: u32 = EC_REGION_LOC - PDDB_LOC; // must be 64k-aligned (bulk erase block size) for proper function. -#[cfg(all(any(windows, unix), not(feature = "processes-as-threads")))] +#[cfg(not(any(target_os = "none", target_os = "xous")))] use core::sync::atomic::AtomicU64; + // Secretly, you can change this by setting the XOUS_SEED environment variable. // I don't lke environment variables because where do you document features like this? // But, this was the most expedient way to get all the threads in Hosted mode to pick up a seed. // The code that reads the varable this is all the way over in xous-rs\src\arch\hosted\mod.rs#29, and // it's glommed onto some other static process initialization code because I don't fully understand // what's going on over there. -#[cfg(all(any(windows, unix), not(feature = "processes-as-threads")))] +#[cfg(not(any(target_os = "none", target_os = "xous")))] pub static TESTING_RNG_SEED: AtomicU64 = AtomicU64::new(0); pub mod exceptions; From 19f95e6bab017989c33ded47b8bbc8f3499553de Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 8 Jan 2022 01:00:20 +0800 Subject: [PATCH 2/2] fix kernel test build --- kernel/src/arch/hosted/mod.rs | 2 -- kernel/src/test.rs | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/src/arch/hosted/mod.rs b/kernel/src/arch/hosted/mod.rs index ea113e09c..4c150f03e 100644 --- a/kernel/src/arch/hosted/mod.rs +++ b/kernel/src/arch/hosted/mod.rs @@ -62,9 +62,7 @@ pub fn set_send_addr(send_addr: Sender) { }); } -#[cfg(not(test))] use core::sync::atomic::{AtomicU64, Ordering}; -#[cfg(not(test))] static LOCAL_RNG_STATE: AtomicU64 = AtomicU64::new(2); #[cfg(not(test))] diff --git a/kernel/src/test.rs b/kernel/src/test.rs index 4af85e55d..b00bac858 100644 --- a/kernel/src/test.rs +++ b/kernel/src/test.rs @@ -32,7 +32,8 @@ fn start_kernel(server_spec: &str) -> JoinHandle<()> { use rand::prelude::*; use rand_chacha::ChaCha8Rng; let mut pid1_key = [0u8; 16]; - let mut rng = ChaCha8Rng::seed_from_u64(RNG_LOCAL_STATE.load(Ordering::SeqCst) + xous::TESTING_RNG_SEED.load(core::sync::atomic::Ordering::SeqCst)); + let mut rng = ChaCha8Rng::seed_from_u64(RNG_LOCAL_STATE.load(Ordering::SeqCst) + xous_kernel::TESTING_RNG_SEED.load(core::sync::atomic::Ordering::SeqCst)); + //let mut rng = thread_rng(); for b in pid1_key.iter_mut() { *b = rng.gen(); }