| OLD | NEW |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 CHECK_EQ(kSize, cb.GetResult(rv)); | 133 CHECK_EQ(kSize, cb.GetResult(rv)); |
| 134 | 134 |
| 135 if (rand() % 100 > 80) { | 135 if (rand() % 100 > 80) { |
| 136 key = rand() % kNumKeys; | 136 key = rand() % kNumKeys; |
| 137 rv = cache->DoomEntry(keys[key], &cb); | 137 rv = cache->DoomEntry(keys[key], &cb); |
| 138 cb.GetResult(rv); | 138 cb.GetResult(rv); |
| 139 } | 139 } |
| 140 | 140 |
| 141 if (!(i % 100)) | 141 if (!(i % 100)) |
| 142 printf("Entries: %d \r", i); | 142 printf("Entries: %d \r", i); |
| 143 MessageLoop::current()->RunAllPending(); | |
| 144 } | 143 } |
| 145 } | 144 } |
| 146 | 145 |
| 147 // We want to prevent the timer thread from killing the process while we are | 146 // We want to prevent the timer thread from killing the process while we are |
| 148 // waiting for the debugger to attach. | 147 // waiting for the debugger to attach. |
| 149 bool g_crashing = false; | 148 bool g_crashing = false; |
| 150 | 149 |
| 151 class CrashTask : public Task { | 150 class CrashTask : public Task { |
| 152 public: | 151 public: |
| 153 CrashTask() {} | 152 CrashTask() {} |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 long int iteration = strtol(argv[1], &end, 0); | 213 long int iteration = strtol(argv[1], &end, 0); |
| 215 | 214 |
| 216 if (!StartCrashThread()) { | 215 if (!StartCrashThread()) { |
| 217 printf("failed to start thread\n"); | 216 printf("failed to start thread\n"); |
| 218 return kError; | 217 return kError; |
| 219 } | 218 } |
| 220 | 219 |
| 221 StressTheCache(iteration); | 220 StressTheCache(iteration); |
| 222 return 0; | 221 return 0; |
| 223 } | 222 } |
| OLD | NEW |