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 TEST_F(ProcessTest, TerminateCurrentProcessImmediately) { | |
152 Process process(SpawnChild("SleepyChildProcess")); | |
153 ASSERT_TRUE(process.IsValid()); | |
154 | |
155 const int kDummyExitCode = 42; | |
156 int exit_code = kDummyExitCode; | |
157 EXPECT_EQ(TERMINATION_STATUS_STILL_RUNNING, | |
158 GetTerminationStatus(process.Handle(), &exit_code)); | |
159 EXPECT_EQ(kExpectedStillRunningExitCode, exit_code); | |
160 | |
161 exit_code = kDummyExitCode; | |
162 int kExpectedExitCode = 250; | |
163 process.TerminateCurrentProcessImmediately(kExpectedExitCode); | |
Primiano Tucci (use gerrit)
2017/01/16 14:37:34
well this is the problem. You don't want to termin
| |
164 process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(), | |
165 &exit_code); | |
166 | |
167 EXPECT_NE(TERMINATION_STATUS_STILL_RUNNING, | |
168 GetTerminationStatus(process.Handle(), &exit_code)); | |
169 #if !defined(OS_POSIX) | |
170 // The POSIX implementation actually ignores the exit_code. | |
Primiano Tucci (use gerrit)
2017/01/16 14:37:34
Where did this happen? I tried both on OSX and Lin
| |
171 EXPECT_EQ(kExpectedExitCode, exit_code); | |
172 #endif | |
173 } | |
174 | |
151 MULTIPROCESS_TEST_MAIN(FastSleepyChildProcess) { | 175 MULTIPROCESS_TEST_MAIN(FastSleepyChildProcess) { |
152 PlatformThread::Sleep(TestTimeouts::tiny_timeout() * 10); | 176 PlatformThread::Sleep(TestTimeouts::tiny_timeout() * 10); |
153 return 0; | 177 return 0; |
154 } | 178 } |
155 | 179 |
156 TEST_F(ProcessTest, WaitForExit) { | 180 TEST_F(ProcessTest, WaitForExit) { |
157 Process process(SpawnChild("FastSleepyChildProcess")); | 181 Process process(SpawnChild("FastSleepyChildProcess")); |
158 ASSERT_TRUE(process.IsValid()); | 182 ASSERT_TRUE(process.IsValid()); |
159 | 183 |
160 const int kDummyExitCode = 42; | 184 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" | 271 "2:freezer:/chrome_renderers/to_be_frozen\n" |
248 "1:cpu:/chrome_renderers/background\n"; | 272 "1:cpu:/chrome_renderers/background\n"; |
249 | 273 |
250 EXPECT_FALSE(IsProcessBackgroundedCGroup(kNotBackgrounded)); | 274 EXPECT_FALSE(IsProcessBackgroundedCGroup(kNotBackgrounded)); |
251 EXPECT_TRUE(IsProcessBackgroundedCGroup(kBackgrounded)); | 275 EXPECT_TRUE(IsProcessBackgroundedCGroup(kBackgrounded)); |
252 } | 276 } |
253 | 277 |
254 #endif // defined(OS_CHROMEOS) | 278 #endif // defined(OS_CHROMEOS) |
255 | 279 |
256 } // namespace base | 280 } // namespace base |
OLD | NEW |