3 Commits

Author SHA1 Message Date
69e172b633 avoid static muts for static pools 2025-01-31 11:27:09 +01:00
b01628d8ef Merge pull request 'fix minisim tests' (#216) from update-minisim into main
Reviewed-on: #216
2025-01-31 11:18:03 +01:00
31844e4fe2 fix tests 2025-01-31 11:17:39 +01:00
5 changed files with 129 additions and 71 deletions

View File

@@ -199,7 +199,7 @@ pub mod tests {
.send_request(request) .send_request(request)
.expect("sending MGM request failed"); .expect("sending MGM request failed");
sim_testbench.handle_sim_requests_time_agnostic(); sim_testbench.handle_sim_requests_time_agnostic();
sim_testbench.step(); sim_testbench.step().unwrap();
let sim_reply = sim_testbench.try_receive_next_reply(); let sim_reply = sim_testbench.try_receive_next_reply();
assert!(sim_reply.is_some()); assert!(sim_reply.is_some());
let sim_reply = sim_reply.unwrap(); let sim_reply = sim_reply.unwrap();
@@ -222,21 +222,21 @@ pub mod tests {
.send_request(request) .send_request(request)
.expect("sending MGM request failed"); .expect("sending MGM request failed");
sim_testbench.handle_sim_requests_time_agnostic(); sim_testbench.handle_sim_requests_time_agnostic();
sim_testbench.step(); sim_testbench.step().unwrap();
let mut sim_reply_res = sim_testbench.try_receive_next_reply(); let mut sim_reply_res = sim_testbench.try_receive_next_reply();
assert!(sim_reply_res.is_some()); assert!(sim_reply_res.is_some());
let mut sim_reply = sim_reply_res.unwrap(); let mut sim_reply = sim_reply_res.unwrap();
assert_eq!(sim_reply.component(), SimComponent::MgmLis3Mdl); assert_eq!(sim_reply.component(), SimComponent::MgmLis3Mdl);
let first_reply = MgmLis3MdlReply::from_sim_message(&sim_reply) let first_reply = MgmLis3MdlReply::from_sim_message(&sim_reply)
.expect("failed to deserialize MGM sensor values"); .expect("failed to deserialize MGM sensor values");
sim_testbench.step_by(Duration::from_millis(50)); sim_testbench.step_until(Duration::from_millis(50)).unwrap();
request = SimRequest::new_with_epoch_time(MgmRequestLis3Mdl::RequestSensorData); request = SimRequest::new_with_epoch_time(MgmRequestLis3Mdl::RequestSensorData);
sim_testbench sim_testbench
.send_request(request) .send_request(request)
.expect("sending MGM request failed"); .expect("sending MGM request failed");
sim_testbench.handle_sim_requests_time_agnostic(); sim_testbench.handle_sim_requests_time_agnostic();
sim_testbench.step(); sim_testbench.step().unwrap();
sim_reply_res = sim_testbench.try_receive_next_reply(); sim_reply_res = sim_testbench.try_receive_next_reply();
assert!(sim_reply_res.is_some()); assert!(sim_reply_res.is_some());
sim_reply = sim_reply_res.unwrap(); sim_reply = sim_reply_res.unwrap();
@@ -271,7 +271,7 @@ pub mod tests {
.send_request(request) .send_request(request)
.expect("sending MGM request failed"); .expect("sending MGM request failed");
sim_testbench.handle_sim_requests_time_agnostic(); sim_testbench.handle_sim_requests_time_agnostic();
sim_testbench.step(); sim_testbench.step().unwrap();
let sim_reply_res = sim_testbench.try_receive_next_reply(); let sim_reply_res = sim_testbench.try_receive_next_reply();
assert!(sim_reply_res.is_none()); assert!(sim_reply_res.is_none());
} }
@@ -286,7 +286,7 @@ pub mod tests {
.send_request(request) .send_request(request)
.expect("sending MGM request failed"); .expect("sending MGM request failed");
sim_testbench.handle_sim_requests_time_agnostic(); sim_testbench.handle_sim_requests_time_agnostic();
sim_testbench.step(); sim_testbench.step().unwrap();
let sim_reply_res = sim_testbench.try_receive_next_reply(); let sim_reply_res = sim_testbench.try_receive_next_reply();
assert!(sim_reply_res.is_some()); assert!(sim_reply_res.is_some());
let sim_reply = sim_reply_res.unwrap(); let sim_reply = sim_reply_res.unwrap();
@@ -307,7 +307,7 @@ pub mod tests {
.send_request(request) .send_request(request)
.expect("sending MGM request failed"); .expect("sending MGM request failed");
sim_testbench.handle_sim_requests_time_agnostic(); sim_testbench.handle_sim_requests_time_agnostic();
sim_testbench.step(); sim_testbench.step().unwrap();
let sim_reply_res = sim_testbench.try_receive_next_reply(); let sim_reply_res = sim_testbench.try_receive_next_reply();
assert!(sim_reply_res.is_some()); assert!(sim_reply_res.is_some());
let sim_reply = sim_reply_res.unwrap(); let sim_reply = sim_reply_res.unwrap();
@@ -338,7 +338,7 @@ pub mod tests {
.send_request(request) .send_request(request)
.expect("sending MGM request failed"); .expect("sending MGM request failed");
sim_testbench.handle_sim_requests_time_agnostic(); sim_testbench.handle_sim_requests_time_agnostic();
sim_testbench.step_by(Duration::from_millis(5)); sim_testbench.step_until(Duration::from_millis(5)).unwrap();
check_mgt_hk( check_mgt_hk(
&mut sim_testbench, &mut sim_testbench,
@@ -347,7 +347,9 @@ pub mod tests {
torquing: true, torquing: true,
}, },
); );
sim_testbench.step_by(Duration::from_millis(100)); sim_testbench
.step_until(Duration::from_millis(100))
.unwrap();
check_mgt_hk( check_mgt_hk(
&mut sim_testbench, &mut sim_testbench,
MgtHkSet { MgtHkSet {

View File

@@ -231,7 +231,7 @@ mod tests {
.send_request(request) .send_request(request)
.expect("sending sim ctrl request failed"); .expect("sending sim ctrl request failed");
sim_testbench.handle_sim_requests_time_agnostic(); sim_testbench.handle_sim_requests_time_agnostic();
sim_testbench.step(); sim_testbench.step().unwrap();
let sim_reply = sim_testbench.try_receive_next_reply(); let sim_reply = sim_testbench.try_receive_next_reply();
assert!(sim_reply.is_some()); assert!(sim_reply.is_some());
let sim_reply = sim_reply.unwrap(); let sim_reply = sim_reply.unwrap();

View File

@@ -91,7 +91,7 @@ pub(crate) mod tests {
.send_request(request) .send_request(request)
.expect("sending MGM switch request failed"); .expect("sending MGM switch request failed");
sim_testbench.handle_sim_requests_time_agnostic(); sim_testbench.handle_sim_requests_time_agnostic();
sim_testbench.step(); sim_testbench.step().unwrap();
} }
#[allow(dead_code)] #[allow(dead_code)]
@@ -112,7 +112,7 @@ pub(crate) mod tests {
.send_request(request) .send_request(request)
.expect("sending MGM request failed"); .expect("sending MGM request failed");
sim_testbench.handle_sim_requests_time_agnostic(); sim_testbench.handle_sim_requests_time_agnostic();
sim_testbench.step(); sim_testbench.step().unwrap();
let sim_reply = sim_testbench.try_receive_next_reply(); let sim_reply = sim_testbench.try_receive_next_reply();
assert!(sim_reply.is_some()); assert!(sim_reply.is_some());
let sim_reply = sim_reply.unwrap(); let sim_reply = sim_reply.unwrap();
@@ -142,12 +142,12 @@ pub(crate) mod tests {
.send_request(request) .send_request(request)
.expect("sending MGM request failed"); .expect("sending MGM request failed");
sim_testbench.handle_sim_requests_time_agnostic(); sim_testbench.handle_sim_requests_time_agnostic();
sim_testbench.step_by(Duration::from_millis(1)); sim_testbench.step_until(Duration::from_millis(1)).unwrap();
let sim_reply = sim_testbench.try_receive_next_reply(); let sim_reply = sim_testbench.try_receive_next_reply();
assert!(sim_reply.is_none()); assert!(sim_reply.is_none());
// Reply takes 20ms // Reply takes 20ms
sim_testbench.step_by(Duration::from_millis(25)); sim_testbench.step_until(Duration::from_millis(25)).unwrap();
let sim_reply = sim_testbench.try_receive_next_reply(); let sim_reply = sim_testbench.try_receive_next_reply();
assert!(sim_reply.is_some()); assert!(sim_reply.is_some());
let sim_reply = sim_reply.unwrap(); let sim_reply = sim_reply.unwrap();

View File

@@ -1,7 +1,10 @@
use delegate::delegate; use delegate::delegate;
use std::{sync::mpsc, time::Duration}; use std::sync::mpsc;
use asynchronix::time::MonotonicTime; use nexosim::{
simulation::ExecutionError,
time::{Deadline, MonotonicTime},
};
use satrs_minisim::{SimReply, SimRequest}; use satrs_minisim::{SimReply, SimRequest};
use crate::{controller::SimController, create_sim_controller, ThreadingModel}; use crate::{controller::SimController, create_sim_controller, ThreadingModel};
@@ -35,8 +38,8 @@ impl SimTestbench {
pub fn handle_sim_requests(&mut self, old_timestamp: MonotonicTime); pub fn handle_sim_requests(&mut self, old_timestamp: MonotonicTime);
} }
to self.sim_controller.simulation { to self.sim_controller.simulation {
pub fn step(&mut self); pub fn step(&mut self) -> Result<(), ExecutionError>;
pub fn step_by(&mut self, duration: Duration); pub fn step_until(&mut self, duration: impl Deadline) -> Result<(), ExecutionError>;
} }
} }

View File

@@ -378,27 +378,71 @@ pub struct SubpoolConfig {
#[cfg(feature = "heapless")] #[cfg(feature = "heapless")]
pub mod heapless_mod { pub mod heapless_mod {
use super::*; use super::*;
use core::cell::UnsafeCell;
use core::sync::atomic::{AtomicBool, Ordering};
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct PoolIsFull; pub struct PoolIsFull;
#[derive(Debug)]
pub struct UnsafeCellBufWrapper<T> {
val: UnsafeCell<T>,
once: AtomicBool
}
// `Sync` is required because `UnsafeCell` is not `Sync` by default.
// This is safe as long as access is manually synchronized.
unsafe impl<T> Sync for UnsafeCellBufWrapper<T> {}
impl<T: Sync> UnsafeCellBufWrapper<T> {
/// Creates a new wrapper around an arbitrary value which should be [Sync].
pub const fn new(v: T) -> Self {
unsafe { Self::new_unchecked(v) }
}
}
impl<T> UnsafeCellBufWrapper<T> {
/// Creates a new wrapper around a buffer.
///
/// # Safety
///
/// Currently, the [Sync] trait is implemented for all T and ignores the usual [Sync] bound
/// on T. This API should only be called for declaring byte buffers statically or if T is
/// known to be [Sync]. You can use [new] to let the compiler do the [Sync] check.
pub const unsafe fn new_unchecked(v: T) -> Self {
Self { val: UnsafeCell::new(v), once: AtomicBool::new(false) }
}
/// Retrieves a mutable reference to the internal value once.
///
/// All subsequent calls return None.
pub fn get_mut(&self) -> Option<&mut T> {
if self.once.load(Ordering::Relaxed) {
return None;
}
// Safety: We ensure that this is only done once with an [AtomicBool].
let mut_ref = unsafe { &mut *self.val.get() };
self.once.store(true, Ordering::Relaxed);
Some(mut_ref)
}
}
/// Helper macro to generate static buffers for the [crate::pool::StaticHeaplessMemoryPool]. /// Helper macro to generate static buffers for the [crate::pool::StaticHeaplessMemoryPool].
#[macro_export] #[macro_export]
macro_rules! static_subpool { macro_rules! static_subpool {
($pool_name: ident, $sizes_list_name: ident, $num_blocks: expr, $block_size: expr) => { ($pool_name: ident, $sizes_list_name: ident, $num_blocks: expr, $block_size: expr) => {
static mut $pool_name: core::mem::MaybeUninit<[u8; $num_blocks * $block_size]> = static $pool_name: UnsafeCellBufWrapper<[u8; $num_blocks * $block_size]> =
core::mem::MaybeUninit::new([0; $num_blocks * $block_size]); UnsafeCellBufWrapper::new([0; $num_blocks * $block_size]);
static mut $sizes_list_name: core::mem::MaybeUninit<[usize; $num_blocks]> = static $sizes_list_name: UnsafeCellBufWrapper<[usize; $num_blocks]> =
core::mem::MaybeUninit::new([$crate::pool::STORE_FREE; $num_blocks]); UnsafeCellBufWrapper::new([$crate::pool::STORE_FREE; $num_blocks]);
}; };
($pool_name: ident, $sizes_list_name: ident, $num_blocks: expr, $block_size: expr, $meta_data: meta) => { ($pool_name: ident, $sizes_list_name: ident, $num_blocks: expr, $block_size: expr, $meta_data: meta) => {
#[$meta_data] #[$meta_data]
static mut $pool_name: core::mem::MaybeUninit<[u8; $num_blocks * $block_size]> = static $pool_name: UnsafeCellBufWrapper<[u8; $num_blocks * $block_size]> =
core::mem::MaybeUninit::new([0; $num_blocks * $block_size]); UnsafeCellBufWrapper::new([0; $num_blocks * $block_size]);
#[$meta_data] #[$meta_data]
static mut $sizes_list_name: core::mem::MaybeUninit<[usize; $num_blocks]> = static $sizes_list_name: UnsafeCellBufWrapper<[usize; $num_blocks]> =
core::mem::MaybeUninit::new([$crate::pool::STORE_FREE; $num_blocks]); UnsafeCellBufWrapper::new([$crate::pool::STORE_FREE; $num_blocks]);
}; };
} }
@@ -435,17 +479,17 @@ pub mod heapless_mod {
/// ///
/// let mut mem_pool: StaticHeaplessMemoryPool<2> = StaticHeaplessMemoryPool::new(true); /// let mut mem_pool: StaticHeaplessMemoryPool<2> = StaticHeaplessMemoryPool::new(true);
/// mem_pool.grow( /// mem_pool.grow(
/// unsafe { SUBPOOL_SMALL.assume_init_mut() }, /// SUBPOOL_SMALL.get_mut().unwrap(),
/// unsafe { SUBPOOL_SMALL_SIZES.assume_init_mut() }, /// SUBPOOL_SMALL_SIZES.get_mut().unwrap(),
/// SUBPOOL_SMALL_NUM_BLOCKS, /// SUBPOOL_SMALL_NUM_BLOCKS,
/// false /// false
/// ); /// ).unwrap();
/// mem_pool.grow( /// mem_pool.grow(
/// unsafe { SUBPOOL_LARGE.assume_init_mut() }, /// SUBPOOL_LARGE.get_mut().unwrap(),
/// unsafe { SUBPOOL_LARGE_SIZES.assume_init_mut() }, /// SUBPOOL_LARGE_SIZES.get_mut().unwrap(),
/// SUBPOOL_LARGE_NUM_BLOCKS, /// SUBPOOL_LARGE_NUM_BLOCKS,
/// false /// false
/// ); /// ).unwrap();
/// ///
/// let mut read_buf: [u8; 16] = [0; 16]; /// let mut read_buf: [u8; 16] = [0; 16];
/// let mut addr; /// let mut addr;
@@ -522,12 +566,14 @@ pub mod heapless_mod {
num_blocks: NumBlocks, num_blocks: NumBlocks,
set_sizes_list_to_all_free: bool, set_sizes_list_to_all_free: bool,
) -> Result<(), PoolIsFull> { ) -> Result<(), PoolIsFull> {
assert!( assert_eq!(
(subpool_memory.len() % num_blocks as usize) == 0, (subpool_memory.len() % num_blocks as usize),
0,
"pool slice length must be multiple of number of blocks" "pool slice length must be multiple of number of blocks"
); );
assert!( assert_eq!(
num_blocks as usize == sizes_list.len(), num_blocks as usize,
sizes_list.len(),
"used block size list slice must be of same length as number of blocks" "used block size list slice must be of same length as number of blocks"
); );
let subpool_config = SubpoolConfig { let subpool_config = SubpoolConfig {
@@ -1584,21 +1630,28 @@ mod tests {
mod heapless_tests { mod heapless_tests {
use super::*; use super::*;
use crate::static_subpool; use crate::static_subpool;
use core::ptr::addr_of_mut; use std::cell::UnsafeCell;
use std::sync::Mutex;
const SUBPOOL_1_BLOCK_SIZE: usize = 4; const SUBPOOL_1_BLOCK_SIZE: usize = 4;
const SUBPOOL_1_NUM_ELEMENTS: u16 = 4; const SUBPOOL_1_NUM_ELEMENTS: u16 = 4;
static mut SUBPOOL_1: [u8; SUBPOOL_1_NUM_ELEMENTS as usize * SUBPOOL_1_BLOCK_SIZE] =
[0; SUBPOOL_1_NUM_ELEMENTS as usize * SUBPOOL_1_BLOCK_SIZE]; static SUBPOOL_1: UnsafeCellBufWrapper<
static mut SUBPOOL_1_SIZES: [usize; SUBPOOL_1_NUM_ELEMENTS as usize] = [u8; SUBPOOL_1_NUM_ELEMENTS as usize * SUBPOOL_1_BLOCK_SIZE],
[STORE_FREE; SUBPOOL_1_NUM_ELEMENTS as usize]; > = UnsafeCellBufWrapper::new([0; SUBPOOL_1_NUM_ELEMENTS as usize * SUBPOOL_1_BLOCK_SIZE]);
static SUBPOOL_1_SIZES: Mutex<UnsafeCell<[usize; SUBPOOL_1_NUM_ELEMENTS as usize]>> =
Mutex::new(UnsafeCell::new(
[STORE_FREE; SUBPOOL_1_NUM_ELEMENTS as usize],
));
const SUBPOOL_2_NUM_ELEMENTS: u16 = 2; const SUBPOOL_2_NUM_ELEMENTS: u16 = 2;
const SUBPOOL_2_BLOCK_SIZE: usize = 8; const SUBPOOL_2_BLOCK_SIZE: usize = 8;
static mut SUBPOOL_2: [u8; SUBPOOL_2_NUM_ELEMENTS as usize * SUBPOOL_2_BLOCK_SIZE] = static SUBPOOL_2: UnsafeCellBufWrapper<
[0; SUBPOOL_2_NUM_ELEMENTS as usize * SUBPOOL_2_BLOCK_SIZE]; [u8; SUBPOOL_2_NUM_ELEMENTS as usize * SUBPOOL_2_BLOCK_SIZE],
static mut SUBPOOL_2_SIZES: [usize; SUBPOOL_2_NUM_ELEMENTS as usize] = > = UnsafeCellBufWrapper::new([0; SUBPOOL_2_NUM_ELEMENTS as usize * SUBPOOL_2_BLOCK_SIZE]);
[STORE_FREE; SUBPOOL_2_NUM_ELEMENTS as usize]; static SUBPOOL_2_SIZES: UnsafeCellBufWrapper<[usize; SUBPOOL_2_NUM_ELEMENTS as usize]> =
UnsafeCellBufWrapper::new([STORE_FREE; SUBPOOL_2_NUM_ELEMENTS as usize]);
const SUBPOOL_3_NUM_ELEMENTS: u16 = 1; const SUBPOOL_3_NUM_ELEMENTS: u16 = 1;
const SUBPOOL_3_BLOCK_SIZE: usize = 16; const SUBPOOL_3_BLOCK_SIZE: usize = 16;
@@ -1641,24 +1694,24 @@ mod tests {
StaticHeaplessMemoryPool::new(false); StaticHeaplessMemoryPool::new(false);
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { &mut *addr_of_mut!(SUBPOOL_1) }, SUBPOOL_1.get_mut().unwrap(),
unsafe { &mut *addr_of_mut!(SUBPOOL_1_SIZES) }, unsafe { &mut *SUBPOOL_1_SIZES.lock().unwrap().get() },
SUBPOOL_1_NUM_ELEMENTS, SUBPOOL_1_NUM_ELEMENTS,
true true
) )
.is_ok()); .is_ok());
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { &mut *addr_of_mut!(SUBPOOL_2) }, SUBPOOL_2.get_mut().unwrap(),
unsafe { &mut *addr_of_mut!(SUBPOOL_2_SIZES) }, SUBPOOL_2_SIZES.get_mut().unwrap(),
SUBPOOL_2_NUM_ELEMENTS, SUBPOOL_2_NUM_ELEMENTS,
true true
) )
.is_ok()); .is_ok());
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { SUBPOOL_3.assume_init_mut() }, SUBPOOL_3.get_mut().unwrap(),
unsafe { SUBPOOL_3_SIZES.assume_init_mut() }, SUBPOOL_3_SIZES.get_mut().unwrap(),
SUBPOOL_3_NUM_ELEMENTS, SUBPOOL_3_NUM_ELEMENTS,
true true
) )
@@ -1780,16 +1833,16 @@ mod tests {
StaticHeaplessMemoryPool::new(true); StaticHeaplessMemoryPool::new(true);
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { &mut *addr_of_mut!(SUBPOOL_2) }, SUBPOOL_2.get_mut().unwrap(),
unsafe { &mut *addr_of_mut!(SUBPOOL_2_SIZES) }, SUBPOOL_2_SIZES.get_mut().unwrap(),
SUBPOOL_2_NUM_ELEMENTS, SUBPOOL_2_NUM_ELEMENTS,
true true
) )
.is_ok()); .is_ok());
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { SUBPOOL_4.assume_init_mut() }, SUBPOOL_4.get_mut().unwrap(),
unsafe { SUBPOOL_4_SIZES.assume_init_mut() }, SUBPOOL_4_SIZES.get_mut().unwrap(),
SUBPOOL_4_NUM_ELEMENTS, SUBPOOL_4_NUM_ELEMENTS,
true true
) )
@@ -1803,16 +1856,16 @@ mod tests {
StaticHeaplessMemoryPool::new(true); StaticHeaplessMemoryPool::new(true);
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { SUBPOOL_5.assume_init_mut() }, SUBPOOL_5.get_mut().unwrap(),
unsafe { SUBPOOL_5_SIZES.assume_init_mut() }, SUBPOOL_5_SIZES.get_mut().unwrap(),
SUBPOOL_5_NUM_ELEMENTS, SUBPOOL_5_NUM_ELEMENTS,
true true
) )
.is_ok()); .is_ok());
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { SUBPOOL_3.assume_init_mut() }, SUBPOOL_3.get_mut().unwrap(),
unsafe { SUBPOOL_3_SIZES.assume_init_mut() }, SUBPOOL_3_SIZES.get_mut().unwrap(),
SUBPOOL_3_NUM_ELEMENTS, SUBPOOL_3_NUM_ELEMENTS,
true true
) )
@@ -1826,24 +1879,24 @@ mod tests {
StaticHeaplessMemoryPool::new(true); StaticHeaplessMemoryPool::new(true);
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { SUBPOOL_5.assume_init_mut() }, SUBPOOL_5.get_mut().unwrap(),
unsafe { SUBPOOL_5_SIZES.assume_init_mut() }, SUBPOOL_5_SIZES.get_mut().unwrap(),
SUBPOOL_5_NUM_ELEMENTS, SUBPOOL_5_NUM_ELEMENTS,
true true
) )
.is_ok()); .is_ok());
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { SUBPOOL_6.assume_init_mut() }, SUBPOOL_6.get_mut().unwrap(),
unsafe { SUBPOOL_6_SIZES.assume_init_mut() }, SUBPOOL_6_SIZES.get_mut().unwrap(),
SUBPOOL_6_NUM_ELEMENTS, SUBPOOL_6_NUM_ELEMENTS,
true true
) )
.is_ok()); .is_ok());
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { SUBPOOL_3.assume_init_mut() }, SUBPOOL_3.get_mut().unwrap(),
unsafe { SUBPOOL_3_SIZES.assume_init_mut() }, SUBPOOL_3_SIZES.get_mut().unwrap(),
SUBPOOL_3_NUM_ELEMENTS, SUBPOOL_3_NUM_ELEMENTS,
true true
) )
@@ -1857,24 +1910,24 @@ mod tests {
StaticHeaplessMemoryPool::new(true); StaticHeaplessMemoryPool::new(true);
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { SUBPOOL_5.assume_init_mut() }, SUBPOOL_5.get_mut().unwrap(),
unsafe { SUBPOOL_5_SIZES.assume_init_mut() }, SUBPOOL_5_SIZES.get_mut().unwrap(),
SUBPOOL_5_NUM_ELEMENTS, SUBPOOL_5_NUM_ELEMENTS,
true true
) )
.is_ok()); .is_ok());
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { SUBPOOL_6.assume_init_mut() }, SUBPOOL_6.get_mut().unwrap(),
unsafe { SUBPOOL_6_SIZES.assume_init_mut() }, SUBPOOL_6_SIZES.get_mut().unwrap(),
SUBPOOL_6_NUM_ELEMENTS, SUBPOOL_6_NUM_ELEMENTS,
true true
) )
.is_ok()); .is_ok());
assert!(heapless_pool assert!(heapless_pool
.grow( .grow(
unsafe { SUBPOOL_3.assume_init_mut() }, SUBPOOL_3.get_mut().unwrap(),
unsafe { SUBPOOL_3_SIZES.assume_init_mut() }, SUBPOOL_3_SIZES.get_mut().unwrap(),
SUBPOOL_3_NUM_ELEMENTS, SUBPOOL_3_NUM_ELEMENTS,
true true
) )