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

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(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
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
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