Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/process/process.h" | 5 #include "base/process/process.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/process/kill.h" | 9 #include "base/process/kill.h" |
| 10 #include "base/test/multiprocess_test.h" | 10 #include "base/test/multiprocess_test.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 &exit_code); | 141 &exit_code); |
| 142 | 142 |
| 143 EXPECT_NE(TERMINATION_STATUS_STILL_RUNNING, | 143 EXPECT_NE(TERMINATION_STATUS_STILL_RUNNING, |
| 144 GetTerminationStatus(process.Handle(), &exit_code)); | 144 GetTerminationStatus(process.Handle(), &exit_code)); |
| 145 #if !defined(OS_POSIX) | 145 #if !defined(OS_POSIX) |
| 146 // The POSIX implementation actually ignores the exit_code. | 146 // The POSIX implementation actually ignores the exit_code. |
| 147 EXPECT_EQ(kExpectedExitCode, exit_code); | 147 EXPECT_EQ(kExpectedExitCode, exit_code); |
| 148 #endif | 148 #endif |
| 149 } | 149 } |
| 150 | 150 |
| 151 MULTIPROCESS_TEST_MAIN(TerminateCurrentProcessImmediately) { | |
| 152 // PlatformThread::Sleep(TestTimeouts::action_max_timeout()); | |
| 153 int kExpectedExitCode = 250; | |
| 154 Process::TerminateCurrentProcessImmediately(kExpectedExitCode); | |
| 155 return 0; | |
| 156 } | |
| 157 | |
| 158 TEST_F(ProcessTest, TerminateCurrentProcessImmediately) { | |
| 159 Process process(SpawnChild("TerminateCurrentProcessImmediately")); | |
| 160 ASSERT_TRUE(process.IsValid()); | |
| 161 | |
| 162 const int kDummyExitCode = 42; | |
| 163 int exit_code = kDummyExitCode; | |
| 164 EXPECT_EQ(TERMINATION_STATUS_STILL_RUNNING, | |
| 165 GetTerminationStatus(process.Handle(), &exit_code)); | |
| 166 EXPECT_EQ(kExpectedStillRunningExitCode, exit_code); | |
| 167 | |
| 168 exit_code = kDummyExitCode; | |
| 169 process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(), | |
| 170 &exit_code); | |
| 171 | |
| 172 EXPECT_NE(TERMINATION_STATUS_STILL_RUNNING, | |
| 173 GetTerminationStatus(process.Handle(), &exit_code)); | |
| 174 #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
| |
| 175 // The POSIX implementation actually ignores the exit_code. | |
| 176 EXPECT_EQ(kExpectedExitCode, exit_code); | |
| 177 #endif | |
| 178 } | |
| 179 | |
| 151 MULTIPROCESS_TEST_MAIN(FastSleepyChildProcess) { | 180 MULTIPROCESS_TEST_MAIN(FastSleepyChildProcess) { |
| 152 PlatformThread::Sleep(TestTimeouts::tiny_timeout() * 10); | 181 PlatformThread::Sleep(TestTimeouts::tiny_timeout() * 10); |
| 153 return 0; | 182 return 0; |
| 154 } | 183 } |
| 155 | 184 |
| 156 TEST_F(ProcessTest, WaitForExit) { | 185 TEST_F(ProcessTest, WaitForExit) { |
| 157 Process process(SpawnChild("FastSleepyChildProcess")); | 186 Process process(SpawnChild("FastSleepyChildProcess")); |
| 158 ASSERT_TRUE(process.IsValid()); | 187 ASSERT_TRUE(process.IsValid()); |
| 159 | 188 |
| 160 const int kDummyExitCode = 42; | 189 const int kDummyExitCode = 42; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 "2:freezer:/chrome_renderers/to_be_frozen\n" | 276 "2:freezer:/chrome_renderers/to_be_frozen\n" |
| 248 "1:cpu:/chrome_renderers/background\n"; | 277 "1:cpu:/chrome_renderers/background\n"; |
| 249 | 278 |
| 250 EXPECT_FALSE(IsProcessBackgroundedCGroup(kNotBackgrounded)); | 279 EXPECT_FALSE(IsProcessBackgroundedCGroup(kNotBackgrounded)); |
| 251 EXPECT_TRUE(IsProcessBackgroundedCGroup(kBackgrounded)); | 280 EXPECT_TRUE(IsProcessBackgroundedCGroup(kBackgrounded)); |
| 252 } | 281 } |
| 253 | 282 |
| 254 #endif // defined(OS_CHROMEOS) | 283 #endif // defined(OS_CHROMEOS) |
| 255 | 284 |
| 256 } // namespace base | 285 } // namespace base |
| OLD | NEW |