summaryrefslogtreecommitdiffstats
path: root/test/unit/fork.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/fork.c')
-rw-r--r--test/unit/fork.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/test/unit/fork.c b/test/unit/fork.c
index c530797..afe2214 100644
--- a/test/unit/fork.c
+++ b/test/unit/fork.c
@@ -4,12 +4,24 @@
#include <sys/wait.h>
#endif
-TEST_BEGIN(test_fork)
-{
+TEST_BEGIN(test_fork) {
#ifndef _WIN32
void *p;
pid_t pid;
+ /* Set up a manually managed arena for test. */
+ unsigned arena_ind;
+ size_t sz = sizeof(unsigned);
+ assert_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz, NULL, 0),
+ 0, "Unexpected mallctl() failure");
+
+ /* Migrate to the new arena. */
+ unsigned old_arena_ind;
+ sz = sizeof(old_arena_ind);
+ assert_d_eq(mallctl("thread.arena", (void *)&old_arena_ind, &sz,
+ (void *)&arena_ind, sizeof(arena_ind)), 0,
+ "Unexpected mallctl() failure");
+
p = malloc(1);
assert_ptr_not_null(p, "Unexpected malloc() failure");
@@ -32,8 +44,9 @@ TEST_BEGIN(test_fork)
/* Parent. */
while (true) {
- if (waitpid(pid, &status, 0) == -1)
+ 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));
@@ -56,9 +69,7 @@ TEST_BEGIN(test_fork)
TEST_END
int
-main(void)
-{
-
- return (test(
- test_fork));
+main(void) {
+ return test(
+ test_fork);
}