diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-06-24 02:28:09 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-06-24 02:28:09 +0200 |
commit | 9d0d33f663c9c5403d87504ae5569774b86e3c35 (patch) | |
tree | d0454be2df604891a68cf4be66943e15e4307a45 | |
parent | 88394eae61a017d2b56c91e4658d0bcd9a65eb2e (diff) |
Assert that arena_free() unmaps pages
-rw-r--r-- | test/arena.c | 16 |
1 files changed, 16 insertions, 0 deletions
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 |