Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2001)

Unified Diff: base/process/process_util_unittest.cc

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process/process_unittest.cc ('k') | base/process/process_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/process_util_unittest.cc
diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc
index 11d8874a52ab9576cd9ec5b1f2d08c9808655ac5..1f7f1b2c776edcfe2942c7564a74a209942804ec 100644
--- a/base/process/process_util_unittest.cc
+++ b/base/process/process_util_unittest.cc
@@ -75,6 +75,10 @@ const char kPosixShell[] = "bash";
const char kSignalFileSlow[] = "SlowChildProcess.die";
const char kSignalFileKill[] = "KilledChildProcess.die";
+#if defined(OS_POSIX)
+const char kSignalFileTerm[] = "TerminatedChildProcess.die";
+#endif
+
#if defined(OS_WIN)
const int kExpectedStillRunningExitCode = 0x102;
const int kExpectedKilledExitCode = 1;
@@ -286,7 +290,16 @@ MULTIPROCESS_TEST_MAIN(KilledChildProcess) {
return 1;
}
-TEST_F(ProcessUtilTest, GetTerminationStatusKill) {
+#if defined(OS_POSIX)
+MULTIPROCESS_TEST_MAIN(TerminatedChildProcess) {
+ WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileTerm).c_str());
+ // Send a SIGTERM to this process.
+ ::kill(getpid(), SIGTERM);
+ return 1;
+}
+#endif
+
+TEST_F(ProcessUtilTest, GetTerminationStatusSigKill) {
const std::string signal_file =
ProcessUtilTest::GetSignalFilePath(kSignalFileKill);
remove(signal_file.c_str());
@@ -302,7 +315,12 @@ TEST_F(ProcessUtilTest, GetTerminationStatusKill) {
exit_code = 42;
base::TerminationStatus status =
WaitForChildTermination(process.Handle(), &exit_code);
+#if defined(OS_CHROMEOS)
+ EXPECT_EQ(base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM, status);
+#else
EXPECT_EQ(base::TERMINATION_STATUS_PROCESS_WAS_KILLED, status);
+#endif
+
#if defined(OS_WIN)
EXPECT_EQ(kExpectedKilledExitCode, exit_code);
#elif defined(OS_POSIX)
@@ -314,6 +332,33 @@ TEST_F(ProcessUtilTest, GetTerminationStatusKill) {
remove(signal_file.c_str());
}
+#if defined(OS_POSIX)
+TEST_F(ProcessUtilTest, GetTerminationStatusSigTerm) {
+ const std::string signal_file =
+ ProcessUtilTest::GetSignalFilePath(kSignalFileTerm);
+ remove(signal_file.c_str());
+ base::Process process = SpawnChild("TerminatedChildProcess");
+ ASSERT_TRUE(process.IsValid());
+
+ int exit_code = 42;
+ EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING,
+ base::GetTerminationStatus(process.Handle(), &exit_code));
+ EXPECT_EQ(kExpectedStillRunningExitCode, exit_code);
+
+ SignalChildren(signal_file.c_str());
+ exit_code = 42;
+ base::TerminationStatus status =
+ WaitForChildTermination(process.Handle(), &exit_code);
+ EXPECT_EQ(base::TERMINATION_STATUS_PROCESS_WAS_KILLED, status);
+
+ int signaled = WIFSIGNALED(exit_code);
+ EXPECT_NE(0, signaled);
+ int signal = WTERMSIG(exit_code);
+ EXPECT_EQ(SIGTERM, signal);
+ remove(signal_file.c_str());
+}
+#endif
+
#if defined(OS_WIN)
// TODO(estade): if possible, port this test.
TEST_F(ProcessUtilTest, GetAppOutput) {
« no previous file with comments | « base/process/process_unittest.cc ('k') | base/process/process_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698