diff options
Diffstat (limited to 'crates/buddy_allocator/tests')
-rw-r--r-- | crates/buddy_allocator/tests/hosted_test.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/crates/buddy_allocator/tests/hosted_test.rs b/crates/buddy_allocator/tests/hosted_test.rs index d13895c..a841802 100644 --- a/crates/buddy_allocator/tests/hosted_test.rs +++ b/crates/buddy_allocator/tests/hosted_test.rs @@ -1,6 +1,7 @@ use core::{fmt, num::NonZero, slice}; use nix::sys::mman::{mmap_anonymous, munmap, MapFlags, ProtFlags}; use proptest::prelude::*; +use std::ptr::NonNull; use vernos_buddy_allocator::BuddyAllocator; use vernos_physmem_free_list::FreeListAllocator; @@ -19,7 +20,7 @@ proptest! { #[test] fn test_simple_scenario() { let scenario = Scenario { - range_sizes: vec![4], + range_sizes: vec![16], actions: vec![ Action::Debug, Action::Alloc { @@ -32,7 +33,7 @@ fn test_simple_scenario() { scenario.run(false) } -const PAGE_SIZE: usize = (size_of::<*const ()>() * 4).next_power_of_two(); +const PAGE_SIZE: usize = (size_of::<*const ()>() * 3).next_power_of_two(); const PAGE_SIZE_BITS: usize = PAGE_SIZE.trailing_zeros() as usize; const SIZE_CLASS_COUNT: usize = 4; @@ -112,7 +113,7 @@ impl Action { }, Err(err) => { if !allow_errors { - Err(err).unwrap() + Err(err).expect("failed to perform alloc action") } } }, @@ -124,7 +125,12 @@ impl Action { let index = index % allocs.len(); let alloc = allocs.remove(index); alloc.check_sentinel(); - todo!("{alloc:?}") + unsafe { + buddy.dealloc( + NonNull::from(alloc.slice.as_mut()).cast(), + alloc.slice.len().trailing_zeros() as usize - PAGE_SIZE_BITS, + ); + } } Action::Debug => { dbg!(buddy); @@ -212,7 +218,7 @@ impl Scenario { } Err(err) => { if !allow_errors { - Err(err).unwrap() + Err(err).expect("failed to make buddy allocator") } } } |