diff --git a/tests/malloc/main.c b/tests/malloc/main.c index 67db274ad1..5048492800 100644 --- a/tests/malloc/main.c +++ b/tests/malloc/main.c @@ -78,10 +78,13 @@ static void free_memory(struct node *head) { struct node *old_head; + uint32_t freed = 0; + while (head) { if (head->ptr) { if (total > CHUNK_SIZE) { total -= CHUNK_SIZE; + freed++; } printf("Free %"PRIu32" Bytes at 0x%p, total %"PRIu32"\n", (uint32_t)CHUNK_SIZE, head->ptr, total); @@ -100,6 +103,8 @@ static void free_memory(struct node *head) total -= sizeof(struct node); } + + printf("Free count: %"PRIu32"\n", freed); } int main(void) diff --git a/tests/malloc/tests/01-run.py b/tests/malloc/tests/01-run.py index fea0d3c031..a29812b9da 100755 --- a/tests/malloc/tests/01-run.py +++ b/tests/malloc/tests/01-run.py @@ -12,6 +12,7 @@ from testrunner import run # For BOARD's with large amount of RAM allocating all chunks takes longer # than 10s ALLOCATION_TIMEOUT = 20 +FREE_TIMEOUT = ALLOCATION_TIMEOUT def testfunc(child): @@ -30,9 +31,11 @@ def testfunc(child): if initial_allocations == 0: initial_allocations = allocations assert initial_allocations == allocations - for _ in range(allocations): - child.expect(r"Free {} Bytes at 0x[a-z0-9]+, total [a-z0-9]+\r\n" - .format(chunk_size)) + child.expect(r"Free {} Bytes at 0x[a-z0-9]+, total [a-z0-9]+\r\n" + .format(chunk_size)) + child.expect(r'Free count: (\d+)\r\n', timeout=FREE_TIMEOUT) + freed = int(child.match.group(1)) + assert freed == allocations child.expect_exact("[SUCCESS]")