From: Philippe Waroquiers Date: Sun, 23 Nov 2025 15:49:01 +0000 (+0100) Subject: Ensure none/tests/linux/mremap[456].c remove the shared memory X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10e067acf160e91829f9a62774906b2267242502;p=thirdparty%2Fvalgrind.git Ensure none/tests/linux/mremap[456].c remove the shared memory As otherwise, each execution of a test leaves some shared memory lingering. Verified by doing: ipcs -m | wc mremap4 ipcs -m | wc and that the nr does not increase after the fix. --- diff --git a/none/tests/linux/mremap4.c b/none/tests/linux/mremap4.c index 3fe2307de..2328cb812 100644 --- a/none/tests/linux/mremap4.c +++ b/none/tests/linux/mremap4.c @@ -19,5 +19,8 @@ int main() addr = mremap(addr, 100 * 4096, 40 * 4096, 0); assert(addr != (void *)-1); + int rmid = shmctl(shmid, IPC_RMID, NULL); + assert(rmid == 0); + return 0; } diff --git a/none/tests/linux/mremap5.c b/none/tests/linux/mremap5.c index dcea248d7..e78250aeb 100644 --- a/none/tests/linux/mremap5.c +++ b/none/tests/linux/mremap5.c @@ -19,5 +19,8 @@ int main() addr = mremap(addr, 100 * 4096, 400 * 4096, MREMAP_MAYMOVE); assert(addr != (void *)-1); + int rmid = shmctl(shmid, IPC_RMID, NULL); + assert(rmid == 0); + return 0; } diff --git a/none/tests/linux/mremap6.c b/none/tests/linux/mremap6.c index bcebaf59a..44a733b5d 100644 --- a/none/tests/linux/mremap6.c +++ b/none/tests/linux/mremap6.c @@ -7,10 +7,12 @@ #include #include +static int shmid; + static void *mkmap(unsigned sz) { - int shmid = shmget(IPC_PRIVATE, sz, - IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR); + shmid = shmget(IPC_PRIVATE, sz, + IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR); assert(shmid != -1); void *addr = shmat(shmid, NULL, 0); @@ -22,10 +24,13 @@ static void *mkmap(unsigned sz) int main() { void *np, *p; - + p = mkmap(1024*1024); np = mremap(p, 1024*1024, 2048*1024, MREMAP_MAYMOVE); /* grow, maymove */ assert(np != (void *)-1); + int rmid = shmctl(shmid, IPC_RMID, NULL); + assert(rmid == 0); + return 0; }