Index: base/process/process_unittest.cc |
diff --git a/base/process/process_unittest.cc b/base/process/process_unittest.cc |
index 90bb95a0fe9b04964cedb716629bb42e3058741f..0a59b0a525d52f8f83f7ca1112ef09afd51c2e34 100644 |
--- a/base/process/process_unittest.cc |
+++ b/base/process/process_unittest.cc |
@@ -148,6 +148,35 @@ TEST_F(ProcessTest, Terminate) { |
#endif |
} |
+MULTIPROCESS_TEST_MAIN(TerminateCurrentProcessImmediately) { |
+ // PlatformThread::Sleep(TestTimeouts::action_max_timeout()); |
+ int kExpectedExitCode = 250; |
+ Process::TerminateCurrentProcessImmediately(kExpectedExitCode); |
+ return 0; |
+} |
+ |
+TEST_F(ProcessTest, TerminateCurrentProcessImmediately) { |
+ Process process(SpawnChild("TerminateCurrentProcessImmediately")); |
+ ASSERT_TRUE(process.IsValid()); |
+ |
+ const int kDummyExitCode = 42; |
+ int exit_code = kDummyExitCode; |
+ EXPECT_EQ(TERMINATION_STATUS_STILL_RUNNING, |
+ GetTerminationStatus(process.Handle(), &exit_code)); |
+ EXPECT_EQ(kExpectedStillRunningExitCode, exit_code); |
+ |
+ exit_code = kDummyExitCode; |
+ process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(), |
+ &exit_code); |
+ |
+ EXPECT_NE(TERMINATION_STATUS_STILL_RUNNING, |
+ GetTerminationStatus(process.Handle(), &exit_code)); |
+#if !defined(OS_POSIX) |
haraken
2017/01/17 09:40:27
It looks like this guard is needed. In Linux, exit
Primiano Tucci (use gerrit)
2017/01/17 12:08:21
I insist, on linux the exit code works really fine
|
+ // The POSIX implementation actually ignores the exit_code. |
+ EXPECT_EQ(kExpectedExitCode, exit_code); |
+#endif |
+} |
+ |
MULTIPROCESS_TEST_MAIN(FastSleepyChildProcess) { |
PlatformThread::Sleep(TestTimeouts::tiny_timeout() * 10); |
return 0; |