From 9ae500f06ee33710fa1c8bcdd647e4b00eba6467 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Tue, 26 Oct 2021 23:26:42 +0200 Subject: [PATCH] Add more test --- tests/test.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/test.c b/tests/test.c index 4c0af66..477c381 100644 --- a/tests/test.c +++ b/tests/test.c @@ -1,4 +1,5 @@ #include "alloc.h" +#include "allocArea.h" #include "ata.h" #include "assert.h" #include "cpu_context.h" @@ -84,14 +85,22 @@ static void *testAllocNSet(size_t size) return allocated; } -static void testAlloc(void) +void testAllocArea(){ + vaddr_t area = areaAlloc(1, 0); + vaddr_t area2 = areaAlloc(1, AREA_PHY_MAP); + assert(area != area2); + areaFree(area); + areaFree(area2); +} + +void testAlloc(void) { assert(malloc(1410065407) == NULL); for (uint i = 0; i < PAGE_SIZE / (sizeof(struct slabEntry)); i++) { - malloc(sizeof(struct slabEntry)); + assert(malloc(sizeof(struct slabEntry)) != NULL); } for (uint i = 0; i < PAGE_SIZE / (sizeof(struct slabDesc)); i++) { - malloc(sizeof(struct slabDesc)); + assert(malloc(sizeof(struct slabDesc)) != NULL); } assert(malloc(1)); assert(malloc(2)); @@ -103,6 +112,8 @@ static void testAlloc(void) free(malloc2); void *malloc3 = malloc(sizeof(void *)); assertmsg((char *)malloc2 == (char *)malloc3, " %d %d\n", malloc2, malloc3); + free(malloc1); + free(malloc3); void *alloc1 = testAllocNSet(1024); void *alloc2 = testAllocNSet(1024); void *alloc3 = testAllocNSet(1024); @@ -388,6 +399,7 @@ void run_test(void) serialPutc('l'); serialPutc('o'); testAlloc(); + testAllocArea(); printf("Testing backtrace\n"); test_backtrace(); testCoroutine();