From bfc6bb97c0c85351c82b3a321b4d054e354b7daa Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 30 Jul 2018 11:41:30 +1000 Subject: [PATCH] heap: Fix heap metadata test to account for background memory allocations --- components/heap/test/test_malloc_caps.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/heap/test/test_malloc_caps.c b/components/heap/test/test_malloc_caps.c index 950f18455..4cda558ec 100644 --- a/components/heap/test/test_malloc_caps.c +++ b/components/heap/test/test_malloc_caps.c @@ -103,8 +103,11 @@ TEST_CASE("heap_caps metadata test", "[heap]") free(b); heap_caps_get_info(&after, MALLOC_CAP_8BIT); - TEST_ASSERT_EQUAL(after.total_free_bytes, original.total_free_bytes); - TEST_ASSERT_EQUAL(after.largest_free_block, original.largest_free_block); + /* Allow some leeway here, because LWIP sometimes allocates up to 144 bytes in the background + as part of timer management. + */ + TEST_ASSERT_INT32_WITHIN(200, after.total_free_bytes, original.total_free_bytes); + TEST_ASSERT_INT32_WITHIN(200, after.largest_free_block, original.largest_free_block); TEST_ASSERT(after.minimum_free_bytes < original.total_free_bytes); }