diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-02-14 19:15:43 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-02-14 19:15:43 +0100 |
commit | 1ca147f9e08202dfbc78692e204adac280f8238b (patch) | |
tree | 70cf40c14aae874bae814a9dcddbfdf5aba52079 /src/tests/ktests/region2/test.c | |
parent | 74ea640f40285220dfa93492a143a35426b867d1 (diff) | |
download | kogata-1ca147f9e08202dfbc78692e204adac280f8238b.tar.gz kogata-1ca147f9e08202dfbc78692e204adac280f8238b.zip |
Rearrange testing architecture : just type 'make run_tests'
Diffstat (limited to 'src/tests/ktests/region2/test.c')
-rw-r--r-- | src/tests/ktests/region2/test.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/tests/ktests/region2/test.c b/src/tests/ktests/region2/test.c new file mode 100644 index 0000000..24908b0 --- /dev/null +++ b/src/tests/ktests/region2/test.c @@ -0,0 +1,34 @@ + +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", default_allocator_pf_handler); + 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 :*/ |