diff options
Diffstat (limited to 'test/unit/fork.c')
| -rw-r--r-- | test/unit/fork.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/test/unit/fork.c b/test/unit/fork.c index c0d5642..46c815e 100644 --- a/test/unit/fork.c +++ b/test/unit/fork.c @@ -14,6 +14,13 @@ TEST_BEGIN(test_fork) assert_ptr_not_null(p, "Unexpected malloc() failure"); pid = fork(); + + free(p); + + p = malloc(64); + assert_ptr_not_null(p, "Unexpected malloc() failure"); + free(p); + if (pid == -1) { /* Error. */ test_fail("Unexpected fork() failure"); @@ -24,11 +31,23 @@ TEST_BEGIN(test_fork) int status; /* Parent. */ - free(p); - do { + while (true) { if (waitpid(pid, &status, 0) == -1) test_fail("Unexpected waitpid() failure"); - } while (!WIFEXITED(status) && !WIFSIGNALED(status)); + 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; + } + } } #else test_skip("fork(2) is irrelevant to Windows"); |
