diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-11-29 00:23:11 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-11-29 00:23:11 +0000 |
commit | 0a25aa60a2a7cc6b681dd2e31321000cedbff77e (patch) | |
tree | 71a9010357ac5f4c35035066e6676a9857a4a547 | |
parent | 72dcf2340ffb3215bb5f71515d2b59ec88d331a4 (diff) | |
parent | cabc77f9172d74ff0bfc56d0797a6a8255b14f2a (diff) |
Merge "Always wrap waitpid in TEMP_FAILURE_RETRY."
-rw-r--r-- | libc/malloc_debug/tests/malloc_debug_unit_tests.cpp | 2 | ||||
-rw-r--r-- | tests/gtest_main.cpp | 2 | ||||
-rw-r--r-- | tests/sys_ptrace_test.cpp | 20 | ||||
-rw-r--r-- | tests/utils.h | 2 |
4 files changed, 13 insertions, 13 deletions
diff --git a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp index d7ba379c9..4e9066812 100644 --- a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp +++ b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp @@ -1385,7 +1385,7 @@ TEST_F(MallocDebugTest, backtrace_dump_on_exit) { exit(0); } ASSERT_NE(-1, pid); - ASSERT_EQ(pid, waitpid(pid, nullptr, 0)); + ASSERT_EQ(pid, TEMP_FAILURE_RETRY(waitpid(pid, nullptr, 0))); // Read all of the contents. std::string actual; diff --git a/tests/gtest_main.cpp b/tests/gtest_main.cpp index 3f59a9c04..33dbfd933 100644 --- a/tests/gtest_main.cpp +++ b/tests/gtest_main.cpp @@ -324,7 +324,7 @@ static bool EnumerateTests(int argc, char** argv, std::vector<TestCase>& testcas } int status; - if (waitpid(pid, &status, 0) != pid) { + if (TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)) != pid) { perror("waitpid"); return false; } diff --git a/tests/sys_ptrace_test.cpp b/tests/sys_ptrace_test.cpp index 78fcf2be3..d460dec85 100644 --- a/tests/sys_ptrace_test.cpp +++ b/tests/sys_ptrace_test.cpp @@ -51,7 +51,7 @@ class ChildGuard { ~ChildGuard() { kill(pid, SIGKILL); int status; - waitpid(pid, &status, 0); + TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)); } private: @@ -184,7 +184,7 @@ static void run_watchpoint_test(std::function<void(T&)> child_func, size_t offse ChildGuard guard(child); int status; - ASSERT_EQ(child, waitpid(child, &status, __WALL)) << strerror(errno); + ASSERT_EQ(child, TEMP_FAILURE_RETRY(waitpid(child, &status, __WALL))) << strerror(errno); ASSERT_TRUE(WIFSTOPPED(status)) << "Status was: " << status; ASSERT_EQ(SIGSTOP, WSTOPSIG(status)) << "Status was: " << status; @@ -196,7 +196,7 @@ static void run_watchpoint_test(std::function<void(T&)> child_func, size_t offse set_watchpoint(child, uintptr_t(&data) + offset, size); ASSERT_EQ(0, ptrace(PTRACE_CONT, child, nullptr, nullptr)) << strerror(errno); - ASSERT_EQ(child, waitpid(child, &status, __WALL)) << strerror(errno); + ASSERT_EQ(child, TEMP_FAILURE_RETRY(waitpid(child, &status, __WALL))) << strerror(errno); ASSERT_TRUE(WIFSTOPPED(status)) << "Status was: " << status; ASSERT_EQ(SIGTRAP, WSTOPSIG(status)) << "Status was: " << status; @@ -364,7 +364,7 @@ TEST(sys_ptrace, hardware_breakpoint) { ChildGuard guard(child); int status; - ASSERT_EQ(child, waitpid(child, &status, __WALL)) << strerror(errno); + ASSERT_EQ(child, TEMP_FAILURE_RETRY(waitpid(child, &status, __WALL))) << strerror(errno); ASSERT_TRUE(WIFSTOPPED(status)) << "Status was: " << status; ASSERT_EQ(SIGSTOP, WSTOPSIG(status)) << "Status was: " << status; @@ -376,7 +376,7 @@ TEST(sys_ptrace, hardware_breakpoint) { set_breakpoint(child); ASSERT_EQ(0, ptrace(PTRACE_CONT, child, nullptr, nullptr)) << strerror(errno); - ASSERT_EQ(child, waitpid(child, &status, __WALL)) << strerror(errno); + ASSERT_EQ(child, TEMP_FAILURE_RETRY(waitpid(child, &status, __WALL))) << strerror(errno); ASSERT_TRUE(WIFSTOPPED(status)) << "Status was: " << status; ASSERT_EQ(SIGTRAP, WSTOPSIG(status)) << "Status was: " << status; @@ -436,7 +436,7 @@ class PtraceResumptionTest : public ::testing::Test { } int result; - pid_t rc = waitpid(tracer, &result, 0); + pid_t rc = TEMP_FAILURE_RETRY(waitpid(tracer, &result, 0)); if (rc != tracer) { printf("waitpid returned %d (%s)\n", rc, strerror(errno)); return false; @@ -463,7 +463,7 @@ class PtraceResumptionTest : public ::testing::Test { } int result; - pid_t rc = waitpid(worker, &result, WNOHANG); + pid_t rc = TEMP_FAILURE_RETRY(waitpid(worker, &result, WNOHANG)); if (rc != 0) { printf("worker exited prematurely\n"); return false; @@ -471,7 +471,7 @@ class PtraceResumptionTest : public ::testing::Test { worker_pipe_write.reset(); - rc = waitpid(worker, &result, 0); + rc = TEMP_FAILURE_RETRY(waitpid(worker, &result, 0)); if (rc != worker) { printf("waitpid for worker returned %d (%s)\n", rc, strerror(errno)); return false; @@ -517,9 +517,9 @@ TEST_F(PtraceResumptionTest, smoke) { std::this_thread::sleep_for(250ms); int result; - ASSERT_EQ(0, waitpid(worker, &result, WNOHANG)); + ASSERT_EQ(0, TEMP_FAILURE_RETRY(waitpid(worker, &result, WNOHANG))); ASSERT_TRUE(WaitForTracer()); - ASSERT_EQ(worker, waitpid(worker, &result, 0)); + ASSERT_EQ(worker, TEMP_FAILURE_RETRY(waitpid(worker, &result, 0))); } TEST_F(PtraceResumptionTest, seize) { diff --git a/tests/utils.h b/tests/utils.h index ba006f12b..9a8eb5df7 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -140,7 +140,7 @@ static inline void WaitUntilThreadSleep(std::atomic<pid_t>& tid) { static inline void AssertChildExited(int pid, int expected_exit_status) { int status; - ASSERT_EQ(pid, waitpid(pid, &status, 0)); + ASSERT_EQ(pid, TEMP_FAILURE_RETRY(waitpid(pid, &status, 0))); if (expected_exit_status >= 0) { ASSERT_TRUE(WIFEXITED(status)); ASSERT_EQ(expected_exit_status, WEXITSTATUS(status)); |