OLD | NEW |
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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #endif | 47 #endif |
48 #if defined(OS_MACOSX) | 48 #if defined(OS_MACOSX) |
49 #include <mach/vm_param.h> | 49 #include <mach/vm_param.h> |
50 #include <malloc/malloc.h> | 50 #include <malloc/malloc.h> |
51 #endif | 51 #endif |
52 | 52 |
53 using base::FilePath; | 53 using base::FilePath; |
54 | 54 |
55 namespace { | 55 namespace { |
56 | 56 |
57 #if defined(OS_WIN) | |
58 const wchar_t kProcessName[] = L"base_unittests.exe"; | |
59 #else | |
60 const wchar_t kProcessName[] = L"base_unittests"; | |
61 #endif // defined(OS_WIN) | |
62 | |
63 #if defined(OS_ANDROID) | 57 #if defined(OS_ANDROID) |
64 const char kShellPath[] = "/system/bin/sh"; | 58 const char kShellPath[] = "/system/bin/sh"; |
65 const char kPosixShell[] = "sh"; | 59 const char kPosixShell[] = "sh"; |
66 #else | 60 #else |
67 const char kShellPath[] = "/bin/sh"; | 61 const char kShellPath[] = "/bin/sh"; |
68 const char kPosixShell[] = "bash"; | 62 const char kPosixShell[] = "bash"; |
69 #endif | 63 #endif |
70 | 64 |
71 const char kSignalFileSlow[] = "SlowChildProcess.die"; | 65 const char kSignalFileSlow[] = "SlowChildProcess.die"; |
72 const char kSignalFileCrash[] = "CrashingChildProcess.die"; | |
73 const char kSignalFileKill[] = "KilledChildProcess.die"; | 66 const char kSignalFileKill[] = "KilledChildProcess.die"; |
74 | 67 |
75 #if defined(OS_WIN) | 68 #if defined(OS_WIN) |
76 const int kExpectedStillRunningExitCode = 0x102; | 69 const int kExpectedStillRunningExitCode = 0x102; |
77 const int kExpectedKilledExitCode = 1; | 70 const int kExpectedKilledExitCode = 1; |
78 #else | 71 #else |
79 const int kExpectedStillRunningExitCode = 0; | 72 const int kExpectedStillRunningExitCode = 0; |
80 #endif | 73 #endif |
81 | 74 |
82 // Sleeps until file filename is created. | 75 // Sleeps until file filename is created. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 207 |
215 #if !defined(OS_MACOSX) | 208 #if !defined(OS_MACOSX) |
216 // This test is disabled on Mac, since it's flaky due to ReportCrash | 209 // This test is disabled on Mac, since it's flaky due to ReportCrash |
217 // taking a variable amount of time to parse and load the debug and | 210 // taking a variable amount of time to parse and load the debug and |
218 // symbol data for this unit test's executable before firing the | 211 // symbol data for this unit test's executable before firing the |
219 // signal handler. | 212 // signal handler. |
220 // | 213 // |
221 // TODO(gspencer): turn this test process into a very small program | 214 // TODO(gspencer): turn this test process into a very small program |
222 // with no symbols (instead of using the multiprocess testing | 215 // with no symbols (instead of using the multiprocess testing |
223 // framework) to reduce the ReportCrash overhead. | 216 // framework) to reduce the ReportCrash overhead. |
| 217 const char kSignalFileCrash[] = "CrashingChildProcess.die"; |
224 | 218 |
225 MULTIPROCESS_TEST_MAIN(CrashingChildProcess) { | 219 MULTIPROCESS_TEST_MAIN(CrashingChildProcess) { |
226 WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileCrash).c_str()); | 220 WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileCrash).c_str()); |
227 #if defined(OS_POSIX) | 221 #if defined(OS_POSIX) |
228 // Have to disable to signal handler for segv so we can get a crash | 222 // Have to disable to signal handler for segv so we can get a crash |
229 // instead of an abnormal termination through the crash dump handler. | 223 // instead of an abnormal termination through the crash dump handler. |
230 ::signal(SIGSEGV, SIG_DFL); | 224 ::signal(SIGSEGV, SIG_DFL); |
231 #endif | 225 #endif |
232 // Make this process have a segmentation fault. | 226 // Make this process have a segmentation fault. |
233 volatile int* oops = NULL; | 227 volatile int* oops = NULL; |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 // Check that process was really killed. | 903 // Check that process was really killed. |
910 EXPECT_TRUE(IsProcessDead(child_process)); | 904 EXPECT_TRUE(IsProcessDead(child_process)); |
911 base::CloseProcessHandle(child_process); | 905 base::CloseProcessHandle(child_process); |
912 } | 906 } |
913 | 907 |
914 MULTIPROCESS_TEST_MAIN(process_util_test_die_immediately) { | 908 MULTIPROCESS_TEST_MAIN(process_util_test_die_immediately) { |
915 return 0; | 909 return 0; |
916 } | 910 } |
917 | 911 |
918 #endif // defined(OS_POSIX) | 912 #endif // defined(OS_POSIX) |
OLD | NEW |