From 75d826bf69eee4d844909beb5abc226186153c4f Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 9 Jan 2020 15:45:38 +0100 Subject: [PATCH] Add a test that memory is reused with a long lived allocation This test fails for the bump allocator because it can only free the complete heap at once, which is prevented by the single long-lived allocation. --- tests/heap_allocation.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/heap_allocation.rs b/tests/heap_allocation.rs index 94a6171f..94c9b950 100644 --- a/tests/heap_allocation.rs +++ b/tests/heap_allocation.rs @@ -58,6 +58,18 @@ fn many_boxes() { serial_println!("[ok]"); } +#[test_case] +fn many_boxes_long_lived() { + serial_print!("many_boxes_long_lived... "); + let long_lived = Box::new(1); // new + for i in 0..HEAP_SIZE { + let x = Box::new(i); + assert_eq!(*x, i); + } + assert_eq!(*long_lived, 1); // new + serial_println!("[ok]"); +} + #[panic_handler] fn panic(info: &PanicInfo) -> ! { blog_os::test_panic_handler(info)