OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This is a simple application that stress-tests the crash recovery of the disk | 5 // This is a simple application that stress-tests the crash recovery of the disk |
6 // cache. The main application starts a copy of itself on a loop, checking the | 6 // cache. The main application starts a copy of itself on a loop, checking the |
7 // exit code of the child process. When the child dies in an unexpected way, | 7 // exit code of the child process. When the child dies in an unexpected way, |
8 // the main application quits. | 8 // the main application quits. |
9 | 9 |
10 // The child application has two threads: one to exercise the cache in an | 10 // The child application has two threads: one to exercise the cache in an |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // Keep trying to run. | 137 // Keep trying to run. |
138 RunSoon(MessageLoop::current()); | 138 RunSoon(MessageLoop::current()); |
139 | 139 |
140 if (g_crashing) | 140 if (g_crashing) |
141 return; | 141 return; |
142 | 142 |
143 if (rand() % 100 > 1) { | 143 if (rand() % 100 > 1) { |
144 printf("sweet death...\n"); | 144 printf("sweet death...\n"); |
145 #if defined(OS_WIN) | 145 #if defined(OS_WIN) |
146 // Windows does more work on _exit() that we would like, so we use Kill. | 146 // Windows does more work on _exit() that we would like, so we use Kill. |
147 base::KillProcess(base::GetCurrentProcId(), kExpectedCrash, false); | 147 base::KillProcessById(base::GetCurrentProcId(), kExpectedCrash, false); |
148 #elif defined(OS_POSIX) | 148 #elif defined(OS_POSIX) |
149 // On POSIX, _exit() will terminate the process with minimal cleanup, | 149 // On POSIX, _exit() will terminate the process with minimal cleanup, |
150 // and it is cleaner than killing. | 150 // and it is cleaner than killing. |
151 _exit(kExpectedCrash); | 151 _exit(kExpectedCrash); |
152 #endif | 152 #endif |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 static void RunSoon(MessageLoop* target_loop) { | 156 static void RunSoon(MessageLoop* target_loop) { |
157 int task_delay = 10000; // 10 seconds | 157 int task_delay = 10000; // 10 seconds |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 if (!StartCrashThread()) { | 196 if (!StartCrashThread()) { |
197 printf("failed to start thread\n"); | 197 printf("failed to start thread\n"); |
198 return kError; | 198 return kError; |
199 } | 199 } |
200 | 200 |
201 StressTheCache(iteration); | 201 StressTheCache(iteration); |
202 return 0; | 202 return 0; |
203 } | 203 } |
204 | 204 |
OLD | NEW |