aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-04-25 23:14:40 -0700
committerJason Evans <jasone@canonware.com>2016-04-25 23:16:20 -0700
commit174c0c3a9c63b3a0bfa32381148b537e9b9af96d (patch)
treee8e8b7d7793e2bebee876edb1744f6db4d854f1a /test
parent0d970a054e5477cd6cf3639366bcc0a1a4f61b11 (diff)
downloadjemalloc-174c0c3a9c63b3a0bfa32381148b537e9b9af96d.tar.gz
Fix fork()-related lock rank ordering reversals.
Diffstat (limited to 'test')
-rw-r--r--test/unit/fork.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/unit/fork.c b/test/unit/fork.c
new file mode 100644
index 0000000..890bc86
--- /dev/null
+++ b/test/unit/fork.c
@@ -0,0 +1,39 @@
+#include "test/jemalloc_test.h"
+
+#include <sys/wait.h>
+
+TEST_BEGIN(test_fork)
+{
+ void *p;
+ pid_t pid;
+
+ p = malloc(1);
+ assert_ptr_not_null(p, "Unexpected malloc() failure");
+
+ pid = fork();
+ if (pid == -1) {
+ /* Error. */
+ test_fail("Unexpected fork() failure");
+ } else if (pid == 0) {
+ /* Child. */
+ exit(0);
+ } else {
+ int status;
+
+ /* Parent. */
+ free(p);
+ do {
+ if (waitpid(pid, &status, 0) == -1)
+ test_fail("Unexpected waitpid() failure");
+ } while (!WIFEXITED(status) && !WIFSIGNALED(status));
+ }
+}
+TEST_END
+
+int
+main(void)
+{
+
+ return (test(
+ test_fork));
+}