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(); |
143 } | 144 } |
144 } | 145 } |
145 | 146 |
146 // We want to prevent the timer thread from killing the process while we are | 147 // We want to prevent the timer thread from killing the process while we are |
147 // waiting for the debugger to attach. | 148 // waiting for the debugger to attach. |
148 bool g_crashing = false; | 149 bool g_crashing = false; |
149 | 150 |
150 class CrashTask : public Task { | 151 class CrashTask : public Task { |
151 public: | 152 public: |
152 CrashTask() {} | 153 CrashTask() {} |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 long int iteration = strtol(argv[1], &end, 0); | 214 long int iteration = strtol(argv[1], &end, 0); |
214 | 215 |
215 if (!StartCrashThread()) { | 216 if (!StartCrashThread()) { |
216 printf("failed to start thread\n"); | 217 printf("failed to start thread\n"); |
217 return kError; | 218 return kError; |
218 } | 219 } |
219 | 220 |
220 StressTheCache(iteration); | 221 StressTheCache(iteration); |
221 return 0; | 222 return 0; |
222 } | 223 } |
OLD | NEW |