Skip to content

Commit

Permalink
Remove allocator tests, doesn't work well with CI builds
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Nov 6, 2023
1 parent dde7ab7 commit d9ddb04
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions allocator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,56 +258,3 @@ unsafe impl<I: AsyncDeallocationIntegration, D: Deallocate> 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<TestIntegration, TestDeallocator> =
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<i32> = vec![];
// bla.push(2);
// });
// }
}

0 comments on commit d9ddb04

Please sign in to comment.