| 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 // 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 base::KillProcessById(base::GetCurrentProcId(), kExpectedCrash, false); | 201 base::KillProcessById(base::GetCurrentProcId(), kExpectedCrash, false); |
| 202 #elif defined(OS_POSIX) | 202 #elif defined(OS_POSIX) |
| 203 // On POSIX, _exit() will terminate the process with minimal cleanup, | 203 // On POSIX, _exit() will terminate the process with minimal cleanup, |
| 204 // and it is cleaner than killing. | 204 // and it is cleaner than killing. |
| 205 _exit(kExpectedCrash); | 205 _exit(kExpectedCrash); |
| 206 #endif | 206 #endif |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 | 209 |
| 210 void RunSoon(MessageLoop* target_loop) { | 210 void RunSoon(MessageLoop* target_loop) { |
| 211 const int kTaskDelay = 10000; // 10 seconds | 211 const base::TimeDelta kTaskDelay = base::TimeDelta::FromSeconds(10); |
| 212 target_loop->PostDelayedTask( | 212 target_loop->PostDelayedTask( |
| 213 FROM_HERE, base::Bind(&CrashCallback), kTaskDelay); | 213 FROM_HERE, base::Bind(&CrashCallback), kTaskDelay); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // We leak everything here :) | 216 // We leak everything here :) |
| 217 bool StartCrashThread() { | 217 bool StartCrashThread() { |
| 218 base::Thread* thread = new base::Thread("party_crasher"); | 218 base::Thread* thread = new base::Thread("party_crasher"); |
| 219 if (!thread->Start()) | 219 if (!thread->Start()) |
| 220 return false; | 220 return false; |
| 221 | 221 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 long int iteration = strtol(argv[1], &end, 0); | 278 long int iteration = strtol(argv[1], &end, 0); |
| 279 | 279 |
| 280 if (!StartCrashThread()) { | 280 if (!StartCrashThread()) { |
| 281 printf("failed to start thread\n"); | 281 printf("failed to start thread\n"); |
| 282 return kError; | 282 return kError; |
| 283 } | 283 } |
| 284 | 284 |
| 285 StressTheCache(iteration); | 285 StressTheCache(iteration); |
| 286 return 0; | 286 return 0; |
| 287 } | 287 } |
| OLD | NEW |