Skip to content
Snippets Groups Projects
Commit 9b26d7af authored by Utz-Uwe Haus's avatar Utz-Uwe Haus
Browse files

add test for overlapping memlocks

parent 170b530d
Branches
Tags
2 merge requests!3Jsc ci update,!2update JSC-CI branch to devel
......@@ -43,6 +43,8 @@
#include "maestro.h"
#include "maestro/i_memlock.h"
#include <unistd.h>
CHEAT_TEST(lock_unlock,
{
......@@ -77,3 +79,35 @@ CHEAT_TEST(lock_unlock_multi,
free(x);
})
CHEAT_TEST(lock_overlapping,
{
long pagesize = sysconf(_SC_PAGESIZE);
void *x = malloc(3*pagesize);
cheat_assert(x!=NULL);
cheat_assert(pagesize>4);
cheat_assert(MSTRO_OK==mstro_memlock_init(4*pagesize));
/* one on the first page */
void *start1 = x;
size_t len1 = pagesize/2;
/* one on the same page */
void *start2 = (void*)((uintptr_t)x+len1);
size_t len2 = pagesize/4;
/* one extending into the third page */
void *start3 = (void*)((uintptr_t)x+len1+len2);
size_t len3 = 2*pagesize;
cheat_assert(MSTRO_OK==mstro_memlock(start1, len1));
cheat_assert(MSTRO_OK==mstro_memlock(start2, len2));
cheat_assert(MSTRO_OK==mstro_memlock(start3, len3));
cheat_assert(MSTRO_OK==mstro_memunlock(start2, len2));
cheat_assert(MSTRO_OK==mstro_memunlock(start1, len1));
cheat_assert(MSTRO_OK==mstro_memunlock(start3, len3));
free(x);
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment