X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=nautilus%2Fpalacios-nautilus-mm-test.c;fp=nautilus%2Fpalacios-nautilus-mm-test.c;h=0000000000000000000000000000000000000000;hp=ad39a7acc8e4f27d677a610cccd7aa1f2f57c23c;hb=2a9cf19fe40ce33f1c2728a41b18011dda365c06;hpb=7e1ce44438e3ba765e1a8ec2d67c03af12c841e7 diff --git a/nautilus/palacios-nautilus-mm-test.c b/nautilus/palacios-nautilus-mm-test.c deleted file mode 100644 index ad39a7a..0000000 --- a/nautilus/palacios-nautilus-mm-test.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Unit test for palacios-nautilus memory allocator - * Can be invoked in init_palacios_nautilus_mm - */ - -#include // for panic - -#include "palacios-nautilus-mm.h" -#include "palacios-nautilus-mm-test.h" -#include "palacios.h" - -void test_palacios_mm(unsigned num_pages_limit) -{ - uintptr_t some_ptr; - unsigned int i = 0; - unsigned alignment = 4096; // gonna keep this constant for now since palacios only uses 4k pages - num_pages_limit -= 10; - - /* Allocate a gigantic piece of memory at once */ - some_ptr = alloc_palacios_pgs(num_pages_limit, alignment, 0, 0, 0); - if(!some_ptr) { - printk("ERROR IN PALACIOS-MM TEST: returned bogus address when not supposed to\n"); - panic(); - } - free_palacios_pgs(some_ptr, num_pages_limit); - - /* check if free_palacios_pg worked */ - some_ptr = alloc_palacios_pgs(100, alignment, 0, 0, 0); - if(!some_ptr) { - printk("FREE_PALACIOS_PGS DIDN'T WORK\n"); - panic(); - } - - /* Allocate many small pieces of memory consecutively */ - for(i = 0; i < num_pages_limit/100; i++) { - free_palacios_pgs(some_ptr, 100); - some_ptr = alloc_palacios_pgs(100, alignment, 0, 0, 0); - if (!some_ptr) { - printk("ERROR IN PALACIOS-MM TEST: returned bogus address when not supposed to\n"); - panic(); - } - } - - free_palacios_pgs(some_ptr, 100); - - uintptr_t ptrs[num_pages_limit]; - - for(i = 0; i < num_pages_limit/100; i++) { - ptrs[i] = alloc_palacios_pgs(100, alignment, 0, 0, 0); - } - - // first free random pages and then try to allocate them again - free_palacios_pgs(ptrs[0], 100); - free_palacios_pgs(ptrs[3], 100); - free_palacios_pgs(ptrs[4], 100); - - ptrs[0] = alloc_palacios_pgs(100, alignment, 0, 0, 0); - ptrs[3] = alloc_palacios_pgs(100, alignment, 0, 0, 0); - ptrs[4] = alloc_palacios_pgs(100, alignment, 0, 0, 0); - - for(i = 0; i < num_pages_limit/100; i++) { - free_palacios_pgs(ptrs[i], 100); - } - - - // TODO: WRITE MORE TESTS - printk("ALL TESTS PASSED - FREED ALL MEMORY\n"); -}