From 9d0d33f663c9c5403d87504ae5569774b86e3c35 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 24 Jun 2024 02:28:09 +0200 Subject: Assert that arena_free() unmaps pages --- test/arena.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/arena.c b/test/arena.c index 58b3076..5efd162 100644 --- a/test/arena.c +++ b/test/arena.c @@ -35,6 +35,22 @@ make_and_free(void) xs[i] = i; arena_free(&a); + + /* Assert that after arena_free(), the page was actually freed */ + + unsigned char *vec = NULL; + size_t pagesz = (size_t)sysconf(_SC_PAGESIZE); + oryx_assert(pagesz != (size_t)-1); + + /* Vector size documented in mincore(2) */ + vec = malloc((_ARENA_DFLT_CAP + pagesz - 1) / pagesz); + oryx_assert(vec != NULL); + + errno = 0; + mincore(xs, sizeof(int) * 69, vec); + oryx_assert(errno == ENOMEM); +cleanup: + free(vec); } void -- cgit v1.2.3