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

Side by Side Diff: base/process/process_unittest.cc

Issue 2629623003: Win should call ::TerminateProcess to exit a renderer process (Closed)
Patch Set: temp Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « base/process/process_posix.cc ('k') | base/process/process_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(TerminateCurrentProcessImmediatelyWithCode0) {
152 Process::TerminateCurrentProcessImmediately(0);
Nico 2017/02/07 15:19:34 maybe this test should register an atexit handler
Primiano Tucci (use gerrit) 2017/02/07 15:48:11 oh very good point. I guess you could both: - regi
153 NOTREACHED();
154 return 42;
155 }
156
157 TEST_F(ProcessTest, TerminateCurrentProcessImmediatelyWithZeroExitCode) {
158 Process process(SpawnChild("TerminateCurrentProcessImmediatelyWithCode0"));
159 ASSERT_TRUE(process.IsValid());
160 int exit_code = 42;
161 ASSERT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(),
162 &exit_code));
163 EXPECT_EQ(0, exit_code);
164 }
165
166 MULTIPROCESS_TEST_MAIN(TerminateCurrentProcessImmediatelyWithCode250) {
167 Process::TerminateCurrentProcessImmediately(250);
168 NOTREACHED();
169 return 42;
170 }
171
172 TEST_F(ProcessTest, TerminateCurrentProcessImmediatelyWithNonZeroExitCode) {
173 Process process(SpawnChild("TerminateCurrentProcessImmediatelyWithCode250"));
174 ASSERT_TRUE(process.IsValid());
175 int exit_code = 42;
176 ASSERT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(),
177 &exit_code));
178 EXPECT_EQ(250, exit_code);
179 }
180
151 MULTIPROCESS_TEST_MAIN(FastSleepyChildProcess) { 181 MULTIPROCESS_TEST_MAIN(FastSleepyChildProcess) {
152 PlatformThread::Sleep(TestTimeouts::tiny_timeout() * 10); 182 PlatformThread::Sleep(TestTimeouts::tiny_timeout() * 10);
153 return 0; 183 return 0;
154 } 184 }
155 185
156 TEST_F(ProcessTest, WaitForExit) { 186 TEST_F(ProcessTest, WaitForExit) {
157 Process process(SpawnChild("FastSleepyChildProcess")); 187 Process process(SpawnChild("FastSleepyChildProcess"));
158 ASSERT_TRUE(process.IsValid()); 188 ASSERT_TRUE(process.IsValid());
159 189
160 const int kDummyExitCode = 42; 190 const int kDummyExitCode = 42;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 "2:freezer:/chrome_renderers/to_be_frozen\n" 277 "2:freezer:/chrome_renderers/to_be_frozen\n"
248 "1:cpu:/chrome_renderers/background\n"; 278 "1:cpu:/chrome_renderers/background\n";
249 279
250 EXPECT_FALSE(IsProcessBackgroundedCGroup(kNotBackgrounded)); 280 EXPECT_FALSE(IsProcessBackgroundedCGroup(kNotBackgrounded));
251 EXPECT_TRUE(IsProcessBackgroundedCGroup(kBackgrounded)); 281 EXPECT_TRUE(IsProcessBackgroundedCGroup(kBackgrounded));
252 } 282 }
253 283
254 #endif // defined(OS_CHROMEOS) 284 #endif // defined(OS_CHROMEOS)
255 285
256 } // namespace base 286 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_posix.cc ('k') | base/process/process_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698