Commit 3cda7853 authored by Mathieu Maret's avatar Mathieu Maret

test: add more malloc/free test

parent 340ae6a4
......@@ -38,12 +38,20 @@ void testPhymem(void)
unrefPhyPage((ulong)page);
}
static void *testAllocNSet(size_t size)
{
void *allocated = malloc(size);
assert(allocated);
memset(allocated, size, size);
return allocated;
}
static void testAlloc(void)
{
for( uint i = 0; i < PAGE_SIZE/(sizeof(struct slabEntry)); i++){
for (uint i = 0; i < PAGE_SIZE / (sizeof(struct slabEntry)); i++) {
malloc(sizeof(struct slabEntry));
}
for( uint i = 0; i < PAGE_SIZE/(sizeof(struct slabDesc)); i++){
for (uint i = 0; i < PAGE_SIZE / (sizeof(struct slabDesc)); i++) {
malloc(sizeof(struct slabDesc));
}
assert(malloc(1));
......@@ -56,14 +64,32 @@ static void testAlloc(void)
free(malloc2);
void *malloc3 = malloc(sizeof(void *));
assertmsg((char *)malloc2 == (char *)malloc3, " %d %d\n", malloc2, malloc3);
assert(malloc(1024));
assert(malloc(1024));
assert(malloc(1024));
assert(malloc(1024));
assert(malloc(1024));
assert(malloc(1024));
assert(malloc(2048));
//assert(malloc(4096));
void *alloc1 = testAllocNSet(1024);
void *alloc2 = testAllocNSet(1024);
void *alloc3 = testAllocNSet(1024);
void *alloc4 = testAllocNSet(1024);
void *alloc5 = testAllocNSet(1024);
void *alloc6 = testAllocNSet(1024);
void *alloc7 = testAllocNSet(4096);
free(alloc1);
free(alloc2);
free(alloc3);
free(alloc4);
free(alloc5);
free(alloc6);
free(alloc7);
void *alloc11 = testAllocNSet(1024);
void *alloc12 = testAllocNSet(1024);
void *alloc13 = testAllocNSet(1024);
void *alloc14 = testAllocNSet(1024);
void *alloc15 = testAllocNSet(1024);
void *alloc16 = testAllocNSet(1024);
free(alloc11);
free(alloc12);
free(alloc13);
free(alloc14);
free(alloc15);
free(alloc16);
}
static void testPaging(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment