diff --git a/allocator/src/lib.rs b/allocator/src/lib.rs index a71a5164d..a8788be6c 100644 --- a/allocator/src/lib.rs +++ b/allocator/src/lib.rs @@ -258,56 +258,3 @@ unsafe impl GlobalAlloc } } } - -#[cfg(test)] -mod tests { - use super::*; - - struct TestIntegration; - impl AsyncDeallocationIntegration for TestIntegration { - fn offload_deallocation(&self) -> bool { - true - } - } - - struct TestDeallocator(&'static str); - impl Deallocate for TestDeallocator { - fn deallocate(&self, ptr: *mut u8, layout: Layout) { - println!("[{}] Deallocating {ptr:?} with layout {layout:?}", self.0); - unsafe { - System.dealloc(ptr, layout); - } - } - } - - #[global_allocator] - static GLOBAL_ALLOCATOR: HelgobossAllocator = - HelgobossAllocator::new(TestDeallocator("SYNC")); - - fn init() -> AsyncDeallocatorCommandReceiver { - GLOBAL_ALLOCATOR.init(100, TestIntegration) - } - - #[test] - fn offload_deallocate() { - let _receiver = init(); - let mut bla = vec![]; - bla.push(2); - assert_no_alloc(|| { - drop(bla); - }); - drop(_receiver); - } - - // // Don't execute this in CI. It crashes the test process which counts as "not passed". - // #[test] - // #[ignore] - // #[should_panic] - // fn abort_on_allocate() { - // let _receiver = init(); - // assert_no_alloc(|| { - // let mut bla: Vec = vec![]; - // bla.push(2); - // }); - // } -}