Skip to content

Commit

Permalink
Merge pull request #67 from rust-osdev/fix-miri
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
phil-opp committed Sep 6, 2022
2 parents 1c2c9bb + 0f24df1 commit a59ceed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/hole.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,17 +753,18 @@ pub mod test {
fn hole_list_new_min_size() {
// define an array of `u64` instead of `u8` for alignment
static mut HEAP: [u64; 2] = [0; 2];
let heap_start = unsafe { HEAP.as_ptr() as usize };
let heap =
unsafe { HoleList::new(HEAP.as_mut_ptr().cast(), 2 * core::mem::size_of::<usize>()) };
assert_eq!(heap.bottom.cast(), unsafe { HEAP.as_mut_ptr() });
assert_eq!(heap.top.cast(), unsafe { HEAP.as_mut_ptr().add(2) });
assert_eq!(heap.bottom as usize, heap_start);
assert_eq!(heap.top as usize, heap_start + 2 * size_of::<usize>());
assert_eq!(heap.first.size, 0); // dummy
assert_eq!(
heap.first.next,
Some(NonNull::new(heap.bottom.cast())).unwrap()
);
assert_eq!(
unsafe { &*(heap.first.next.unwrap().as_ptr()) }.size,
unsafe { heap.first.next.as_ref().unwrap().as_ref() }.size,
2 * core::mem::size_of::<usize>()
);
assert_eq!(unsafe { &*(heap.first.next.unwrap().as_ptr()) }.next, None);
Expand Down
2 changes: 1 addition & 1 deletion src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ fn oddly_sized_heap_extension() {
#[test]
fn extend_odd_size() {
// define an array of `u64` instead of `u8` for alignment
static mut HEAP: [u64; 5] = [0; 5];
static mut HEAP: [u64; 6] = [0; 6];
unsafe {
let mut heap = Heap::new(HEAP.as_mut_ptr().cast(), 17);
assert_eq!(1, heap.holes.pending_extend);
Expand Down

0 comments on commit a59ceed

Please sign in to comment.