mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-22 16:47:21 +03:00
parent
ced8b3cffb
commit
2114349a4e
30 changed files with 124 additions and 1364 deletions
|
|
@ -1,5 +1,34 @@
|
|||
#include "test/jemalloc_test.h"
|
||||
#include "test/fork.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
static void
|
||||
wait_for_child_exit(int pid) {
|
||||
int status;
|
||||
while (true) {
|
||||
if (waitpid(pid, &status, 0) == -1) {
|
||||
test_fail("Unexpected waitpid() failure.");
|
||||
}
|
||||
if (WIFSIGNALED(status)) {
|
||||
test_fail(
|
||||
"Unexpected child termination due to "
|
||||
"signal %d",
|
||||
WTERMSIG(status));
|
||||
break;
|
||||
}
|
||||
if (WIFEXITED(status)) {
|
||||
if (WEXITSTATUS(status) != 0) {
|
||||
test_fail("Unexpected child exit value %d",
|
||||
WEXITSTATUS(status));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_BEGIN(test_fork) {
|
||||
#ifndef _WIN32
|
||||
|
|
@ -37,7 +66,7 @@ TEST_BEGIN(test_fork) {
|
|||
/* Child. */
|
||||
_exit(0);
|
||||
} else {
|
||||
fork_wait_for_child_exit(pid);
|
||||
wait_for_child_exit(pid);
|
||||
}
|
||||
#else
|
||||
test_skip("fork(2) is irrelevant to Windows");
|
||||
|
|
@ -60,7 +89,7 @@ do_fork_thd(void *arg) {
|
|||
test_fail("Exec failed");
|
||||
} else {
|
||||
/* Parent */
|
||||
fork_wait_for_child_exit(pid);
|
||||
wait_for_child_exit(pid);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -97,7 +126,7 @@ TEST_BEGIN(test_fork_multithreaded) {
|
|||
do_test_fork_multithreaded();
|
||||
_exit(0);
|
||||
} else {
|
||||
fork_wait_for_child_exit(pid);
|
||||
wait_for_child_exit(pid);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue