mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2026-01-01 01:41:18 +01:00
Merge pull request #16427 from fjmolinas/pr_test_malloc_refactor
tests/malloc: refactor test
This commit is contained in:
commit
c49162cc66
@ -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)
|
||||
|
||||
@ -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]")
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user