summaryrefslogtreecommitdiff
path: root/debuggerd/debuggerd_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'debuggerd/debuggerd_test.cpp')
-rw-r--r--debuggerd/debuggerd_test.cpp34
1 files changed, 12 insertions, 22 deletions
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp
index 8d0c98bb0..0d17a3b5c 100644
--- a/debuggerd/debuggerd_test.cpp
+++ b/debuggerd/debuggerd_test.cpp
@@ -245,6 +245,8 @@ void CrasherTest::AssertDeath(int signo) {
int status;
pid_t pid = TIMEOUT(5, waitpid(crasher_pid, &status, 0));
if (pid != crasher_pid) {
+ printf("failed to wait for crasher (pid %d)\n", crasher_pid);
+ sleep(100);
FAIL() << "failed to wait for crasher: " << strerror(errno);
}
@@ -341,13 +343,12 @@ TEST_F(CrasherTest, signal) {
int intercept_result;
unique_fd output_fd;
StartProcess([]() {
- abort();
+ while (true) {
+ sleep(1);
+ }
});
StartIntercept(&output_fd);
-
- // Wait for a bit, or we might end up killing the process before the signal
- // handler even gets a chance to be registered.
- std::this_thread::sleep_for(100ms);
+ FinishCrasher();
ASSERT_EQ(0, kill(crasher_pid, SIGSEGV));
AssertDeath(SIGSEGV);
@@ -439,19 +440,6 @@ TEST_F(CrasherTest, wait_for_gdb) {
AssertDeath(SIGABRT);
}
-// wait_for_gdb shouldn't trigger on manually sent signals.
-TEST_F(CrasherTest, wait_for_gdb_signal) {
- if (!android::base::SetProperty(kWaitForGdbKey, "1")) {
- FAIL() << "failed to enable wait_for_gdb";
- }
-
- StartProcess([]() {
- abort();
- });
- ASSERT_EQ(0, kill(crasher_pid, SIGSEGV)) << strerror(errno);
- AssertDeath(SIGSEGV);
-}
-
TEST_F(CrasherTest, backtrace) {
std::string result;
int intercept_result;
@@ -596,15 +584,13 @@ TEST_F(CrasherTest, competing_tracer) {
int intercept_result;
unique_fd output_fd;
StartProcess([]() {
- while (true) {
- }
+ raise(SIGABRT);
});
StartIntercept(&output_fd);
- FinishCrasher();
ASSERT_EQ(0, ptrace(PTRACE_SEIZE, crasher_pid, 0, 0));
- ASSERT_EQ(0, kill(crasher_pid, SIGABRT));
+ FinishCrasher();
int status;
ASSERT_EQ(crasher_pid, waitpid(crasher_pid, &status, 0));
@@ -622,6 +608,10 @@ TEST_F(CrasherTest, competing_tracer) {
regex += R"( \(.+debuggerd_test)";
ASSERT_MATCH(result, regex.c_str());
+ ASSERT_EQ(crasher_pid, waitpid(crasher_pid, &status, 0));
+ ASSERT_TRUE(WIFSTOPPED(status));
+ ASSERT_EQ(SIGABRT, WSTOPSIG(status));
+
ASSERT_EQ(0, ptrace(PTRACE_DETACH, crasher_pid, 0, SIGABRT));
AssertDeath(SIGABRT);
}