aboutsummaryrefslogtreecommitdiff
path: root/src/tests/ktests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/ktests')
-rw-r--r--src/tests/ktests/region1/test.c8
l---------src/tests/ktests/region2/Makefile1
-rw-r--r--src/tests/ktests/region2/test.c43
3 files changed, 4 insertions, 48 deletions
diff --git a/src/tests/ktests/region1/test.c b/src/tests/ktests/region1/test.c
index 1a42638..58b4933 100644
--- a/src/tests/ktests/region1/test.c
+++ b/src/tests/ktests/region1/test.c
@@ -2,16 +2,16 @@
void test_region_1() {
BEGIN_TEST("region-test-1");
- void* p = region_alloc(0x1000, "Test region", 0);
+ void* p = region_alloc(0x1000, "Test region");
dbg_printf("Allocated one-page region: 0x%p\n", p);
dbg_print_region_info();
- void* q = region_alloc(0x1000, "Test region", 0);
+ void* q = region_alloc(0x1000, "Test region");
dbg_printf("Allocated one-page region: 0x%p\n", q);
dbg_print_region_info();
- void* r = region_alloc(0x2000, "Test region", 0);
+ void* r = region_alloc(0x2000, "Test region");
dbg_printf("Allocated two-page region: 0x%p\n", r);
dbg_print_region_info();
- void* s = region_alloc(0x10000, "Test region", 0);
+ void* s = region_alloc(0x10000, "Test region");
dbg_printf("Allocated 16-page region: 0x%p\n", s);
dbg_print_region_info();
region_free(p);
diff --git a/src/tests/ktests/region2/Makefile b/src/tests/ktests/region2/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/ktests/region2/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/ktests/region2/test.c b/src/tests/ktests/region2/test.c
deleted file mode 100644
index 232bd12..0000000
--- a/src/tests/ktests/region2/test.c
+++ /dev/null
@@ -1,43 +0,0 @@
-
-void pf_allocate_on_demand(pagedir_t *pd, struct region_info *r, void* addr) {
- ASSERT(pd_get_frame(addr) == 0); // if error is of another type (RO, protected), we don't do anyting
-
- uint32_t f = frame_alloc(1);
- if (f == 0) PANIC("Out Of Memory");
- bool map_ok = pd_map_page(addr, f, 1);
- if (!map_ok) PANIC("Could not map frame (OOM)");
-}
-
-void test_region_2() {
- BEGIN_TEST("region-test-2");
-
- // allocate a big region and try to write into it
- const size_t n = 200;
- void* p0 = region_alloc(n * PAGE_SIZE, "Test big region", pf_allocate_on_demand);
- for (size_t i = 0; i < n; i++) {
- uint32_t *x = (uint32_t*)(p0 + i * PAGE_SIZE);
- x[0] = 12;
- x[1] = (i * 20422) % 122;
- }
- // unmap memory
- for (size_t i = 0; i < n; i++) {
- void* p = p0 + i * PAGE_SIZE;
- uint32_t *x = (uint32_t*)p;
- ASSERT(x[1] == (i * 20422) % 122);
-
- uint32_t f = pd_get_frame(p);
- ASSERT(f != 0);
- pd_unmap_page(p);
- ASSERT(pd_get_frame(p) == 0);
-
- frame_free(f, 1);
- }
- region_free(p0);
-
- TEST_OK;
-}
-
-#undef TEST_PLACEHOLDER_AFTER_REGION
-#define TEST_PLACEHOLDER_AFTER_REGION { test_region_2(); }
-
-/* vim: set ts=4 sw=4 tw=0 noet :*/