OSDN Git Service

Simpleperf: fix flaky workload unit tests.
authorYabin Cui <yabinc@google.com>
Thu, 24 Sep 2015 19:37:27 +0000 (12:37 -0700)
committerYabin Cui <yabinc@google.com>
Thu, 24 Sep 2015 20:35:53 +0000 (13:35 -0700)
Move SIGABRT to SIGKILL to make sure the child process is terminated by a signal.
SIGABRT can't guarantee this because the child process can install signal handler for SIGABRT.

Add a final _exit(1) after ChildProcessFn in case execvp() fails.

Change-Id: I353720b10c6ea42826efcafce5ff2699fd246e22

simpleperf/workload.cpp
simpleperf/workload_test.cpp

index 42a5fdd..56870a7 100644 (file)
@@ -78,6 +78,7 @@ bool Workload::CreateNewProcess() {
     close(start_signal_pipe[1]);
     close(exec_child_pipe[0]);
     ChildProcessFn(args_, start_signal_pipe[0], exec_child_pipe[1]);
+    _exit(0);
   }
   // In parent process.
   close(start_signal_pipe[0]);
index f250328..f4c1601 100644 (file)
@@ -50,7 +50,7 @@ static void run_signaled_workload() {
     auto workload = Workload::CreateWorkload({"sleep", "10"});
     ASSERT_TRUE(workload != nullptr);
     ASSERT_TRUE(workload->Start());
-    ASSERT_EQ(0, kill(workload->GetPid(), SIGABRT));
+    ASSERT_EQ(0, kill(workload->GetPid(), SIGKILL));
     while (!signaled) {
     }
   }