From e75adf9e67886b2f04e1e31e4e8982fc8c5b8b83 Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Tue, 18 Jan 2022 19:33:25 +0000 Subject: [PATCH] check no blocks are leaked during testing --- agb/src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/agb/src/lib.rs b/agb/src/lib.rs index f5cb0f62..9c7c2085 100644 --- a/agb/src/lib.rs +++ b/agb/src/lib.rs @@ -243,6 +243,13 @@ where mgba::number_of_cycles_tagged(785); self(gba); mgba::number_of_cycles_tagged(785); + + assert!( + unsafe { agb_alloc::number_of_blocks() } < 2, + "memory is being leaked, there are {} blocks", + unsafe { agb_alloc::number_of_blocks() } + ); + mgba.print(format_args!("[ok]"), mgba::DebugLevel::Info) .unwrap(); } @@ -274,10 +281,10 @@ pub fn test_runner(tests: &[&dyn Testable]) { ) .unwrap(); - let mut gba = unsafe { TEST_GBA.as_mut() }.unwrap(); + let gba = unsafe { TEST_GBA.as_mut() }.unwrap(); for test in tests { - test.run(&mut gba); + test.run(gba); } mgba.print(