From 882c83f9de4055b6ee1a532dd5826f98d70f0292 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 9 Jan 2020 12:58:29 +0100 Subject: [PATCH] Update many_boxes test to scale with heap size (#716) Instead of using a hardcoded number of boxes, use the HEAP_SIZE constant. This ensures that we get a test failure because of an out-of-memory error when the allocator does not reuse freed memory. --- tests/heap_allocation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/heap_allocation.rs b/tests/heap_allocation.rs index a8a4b8f4..94a6171f 100644 --- a/tests/heap_allocation.rs +++ b/tests/heap_allocation.rs @@ -7,7 +7,7 @@ extern crate alloc; use alloc::{boxed::Box, vec::Vec}; -use blog_os::{serial_print, serial_println}; +use blog_os::{allocator::HEAP_SIZE, serial_print, serial_println}; use bootloader::{entry_point, BootInfo}; use core::panic::PanicInfo; @@ -51,7 +51,7 @@ fn large_vec() { #[test_case] fn many_boxes() { serial_print!("many_boxes... "); - for i in 0..10_000 { + for i in 0..HEAP_SIZE { let x = Box::new(i); assert_eq!(*x, i); }