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

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

Issue 2549363004: Multiprocess test client: Android child process launcher rework. (Closed)
Patch Set: content_unittests + sync 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #define _CRT_SECURE_NO_WARNINGS 5 #define _CRT_SECURE_NO_WARNINGS
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 base::ProcessId id1 = base::GetProcId(GetCurrentProcess()); 250 base::ProcessId id1 = base::GetProcId(GetCurrentProcess());
251 EXPECT_NE(0ul, id1); 251 EXPECT_NE(0ul, id1);
252 base::Process process = SpawnChild("SimpleChildProcess"); 252 base::Process process = SpawnChild("SimpleChildProcess");
253 ASSERT_TRUE(process.IsValid()); 253 ASSERT_TRUE(process.IsValid());
254 base::ProcessId id2 = process.Pid(); 254 base::ProcessId id2 = process.Pid();
255 EXPECT_NE(0ul, id2); 255 EXPECT_NE(0ul, id2);
256 EXPECT_NE(id1, id2); 256 EXPECT_NE(id1, id2);
257 } 257 }
258 #endif // defined(OS_WIN) 258 #endif // defined(OS_WIN)
259 259
260 #if !defined(OS_MACOSX) 260 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
261 // This test is disabled on Mac, since it's flaky due to ReportCrash 261 // This test is disabled on Mac, since it's flaky due to ReportCrash
262 // taking a variable amount of time to parse and load the debug and 262 // taking a variable amount of time to parse and load the debug and
263 // symbol data for this unit test's executable before firing the 263 // symbol data for this unit test's executable before firing the
264 // signal handler. 264 // signal handler.
265 // 265 //
266 // TODO(gspencer): turn this test process into a very small program 266 // TODO(gspencer): turn this test process into a very small program
267 // with no symbols (instead of using the multiprocess testing 267 // with no symbols (instead of using the multiprocess testing
268 // framework) to reduce the ReportCrash overhead. 268 // framework) to reduce the ReportCrash overhead.
269 //
270 // It is disabled on Android as MultiprocessTests are started as services that
271 // the framework restarts on crashes.
269 const char kSignalFileCrash[] = "CrashingChildProcess.die"; 272 const char kSignalFileCrash[] = "CrashingChildProcess.die";
270 273
271 MULTIPROCESS_TEST_MAIN(CrashingChildProcess) { 274 MULTIPROCESS_TEST_MAIN(CrashingChildProcess) {
272 WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileCrash).c_str()); 275 WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileCrash).c_str());
273 #if defined(OS_ANDROID) 276 #if defined(OS_POSIX)
274 // Android L+ expose signal and sigaction symbols that override the system
275 // ones. There is a bug in these functions where a request to set the handler
276 // to SIG_DFL is ignored. In that case, an infinite loop is entered as the
277 // signal is repeatedly sent to the crash dump signal handler.
278 // To work around this, directly call the system's sigaction.
279 struct kernel_sigaction sa;
280 memset(&sa, 0, sizeof(sa));
281 sys_sigemptyset(&sa.sa_mask);
282 sa.sa_handler_ = SIG_DFL;
283 sa.sa_flags = SA_RESTART;
284 sys_rt_sigaction(SIGSEGV, &sa, NULL, sizeof(kernel_sigset_t));
285 #elif defined(OS_POSIX)
286 // Have to disable to signal handler for segv so we can get a crash 277 // Have to disable to signal handler for segv so we can get a crash
287 // instead of an abnormal termination through the crash dump handler. 278 // instead of an abnormal termination through the crash dump handler.
288 ::signal(SIGSEGV, SIG_DFL); 279 ::signal(SIGSEGV, SIG_DFL);
289 #endif 280 #endif
290 // Make this process have a segmentation fault. 281 // Make this process have a segmentation fault.
291 volatile int* oops = NULL; 282 volatile int* oops = NULL;
292 *oops = 0xDEAD; 283 *oops = 0xDEAD;
293 return 1; 284 return 1;
294 } 285 }
295 286
(...skipping 28 matching lines...) Expand all
324 int signaled = WIFSIGNALED(exit_code); 315 int signaled = WIFSIGNALED(exit_code);
325 EXPECT_NE(0, signaled); 316 EXPECT_NE(0, signaled);
326 int signal = WTERMSIG(exit_code); 317 int signal = WTERMSIG(exit_code);
327 EXPECT_EQ(SIGSEGV, signal); 318 EXPECT_EQ(SIGSEGV, signal);
328 #endif 319 #endif
329 320
330 // Reset signal handlers back to "normal". 321 // Reset signal handlers back to "normal".
331 base::debug::EnableInProcessStackDumping(); 322 base::debug::EnableInProcessStackDumping();
332 remove(signal_file.c_str()); 323 remove(signal_file.c_str());
333 } 324 }
334 #endif // !defined(OS_MACOSX) 325 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID)
335 326
336 MULTIPROCESS_TEST_MAIN(KilledChildProcess) { 327 MULTIPROCESS_TEST_MAIN(KilledChildProcess) {
337 WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileKill).c_str()); 328 WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileKill).c_str());
338 #if defined(OS_WIN) 329 #if defined(OS_WIN)
339 // Kill ourselves. 330 // Kill ourselves.
340 HANDLE handle = ::OpenProcess(PROCESS_ALL_ACCESS, 0, ::GetCurrentProcessId()); 331 HANDLE handle = ::OpenProcess(PROCESS_ALL_ACCESS, 0, ::GetCurrentProcessId());
341 ::TerminateProcess(handle, kExpectedKilledExitCode); 332 ::TerminateProcess(handle, kExpectedKilledExitCode);
342 #elif defined(OS_POSIX) 333 #elif defined(OS_POSIX)
343 // Send a SIGKILL to this process, just like the OOM killer would. 334 // Send a SIGKILL to this process, just like the OOM killer would.
344 ::kill(getpid(), SIGKILL); 335 ::kill(getpid(), SIGKILL);
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 options.current_directory = base::FilePath("/dev/null"); 1011 options.current_directory = base::FilePath("/dev/null");
1021 1012
1022 base::Process process(SpawnChildWithOptions("SimpleChildProcess", options)); 1013 base::Process process(SpawnChildWithOptions("SimpleChildProcess", options));
1023 ASSERT_TRUE(process.IsValid()); 1014 ASSERT_TRUE(process.IsValid());
1024 1015
1025 int exit_code = kSuccess; 1016 int exit_code = kSuccess;
1026 EXPECT_TRUE(process.WaitForExit(&exit_code)); 1017 EXPECT_TRUE(process.WaitForExit(&exit_code));
1027 EXPECT_NE(kSuccess, exit_code); 1018 EXPECT_NE(kSuccess, exit_code);
1028 } 1019 }
1029 #endif // defined(OS_LINUX) 1020 #endif // defined(OS_LINUX)
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