Factor out the waiting for children in bionic tests.
Change-Id: I4a1e51b6920b33dc892d447f5bd6d10f1cb2704a
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index 78dbd39..d11ea3f 100755
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -37,7 +37,6 @@
#include "private/ScopeGuard.h"
#include "BionicDeathTest.h"
#include "ScopedSignalHandler.h"
-
#include "utils.h"
TEST(pthread, pthread_key_create) {
@@ -142,10 +141,7 @@
_exit(99);
}
- int status;
- ASSERT_EQ(pid, waitpid(pid, &status, 0));
- ASSERT_TRUE(WIFEXITED(status));
- ASSERT_EQ(99, WEXITSTATUS(status));
+ AssertChildExited(pid, 99);
ASSERT_EQ(expected, pthread_getspecific(key));
ASSERT_EQ(0, pthread_key_delete(key));
@@ -1038,7 +1034,7 @@
ASSERT_EQ(0, pthread_atfork(AtForkPrepare1, AtForkParent1, AtForkChild1));
ASSERT_EQ(0, pthread_atfork(AtForkPrepare2, AtForkParent2, AtForkChild2));
- int pid = fork();
+ pid_t pid = fork();
ASSERT_NE(-1, pid) << strerror(errno);
// Child and parent calls are made in the order they were registered.
@@ -1050,8 +1046,7 @@
// Prepare calls are made in the reverse order.
ASSERT_EQ(21, g_atfork_prepare_calls);
- int status;
- ASSERT_EQ(pid, waitpid(pid, &status, 0));
+ AssertChildExited(pid, 0);
}
TEST(pthread, pthread_attr_getscope) {