From 9e769fcb57b4b023cf51fa27c851ce7da21405de Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Thu, 10 Apr 2025 15:33:36 +0200 Subject: [PATCH] Add pthread_exit test. This caught a bug in the kernel where it would return Ok(24) when passing zero extra-munmap length. --- tests/Makefile | 1 + tests/pthread/exit.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/pthread/exit.c diff --git a/tests/Makefile b/tests/Makefile index 948215e198..acc7d5de3b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -204,6 +204,7 @@ NAMES=\ unistd/sysconf \ pthread/main \ pthread/cleanup \ + pthread/exit \ pthread/extjoin \ pthread/once \ pthread/customstack \ diff --git a/tests/pthread/exit.c b/tests/pthread/exit.c new file mode 100644 index 0000000000..35fc31cf21 --- /dev/null +++ b/tests/pthread/exit.c @@ -0,0 +1,31 @@ +#include +#include +#include + +#include + +#include "common.h" + +void *routine(void *arg) { + assert(arg == NULL); + + sleep(1); + + puts("Thread "); + + return NULL; +} + +int main(void) { + int status; + pthread_t thread; + + if ((status = pthread_create(&thread, NULL, routine, NULL)) != 0) { + return fail(status, "failed to create thread"); + } + if ((status = pthread_detach(thread)) != 0) { + return fail(status, "failed to detach thread"); + } + + pthread_exit(NULL); +}