OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 #endif | 123 #endif |
124 const int kNumEntries = 30; | 124 const int kNumEntries = 30; |
125 std::string keys[kNumKeys]; | 125 std::string keys[kNumKeys]; |
126 disk_cache::Entry* entries[kNumEntries] = {0}; | 126 disk_cache::Entry* entries[kNumEntries] = {0}; |
127 | 127 |
128 for (int i = 0; i < kNumKeys; i++) { | 128 for (int i = 0; i < kNumKeys; i++) { |
129 keys[i] = GenerateKey(true); | 129 keys[i] = GenerateKey(true); |
130 } | 130 } |
131 | 131 |
132 const int kSize = 4000; | 132 const int kSize = 4000; |
133 scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(kSize); | 133 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kSize)); |
134 memset(buffer->data(), 'k', kSize); | 134 memset(buffer->data(), 'k', kSize); |
135 | 135 |
136 for (int i = 0;; i++) { | 136 for (int i = 0;; i++) { |
137 int slot = rand() % kNumEntries; | 137 int slot = rand() % kNumEntries; |
138 int key = rand() % kNumKeys; | 138 int key = rand() % kNumKeys; |
139 bool truncate = rand() % 2 ? false : true; | 139 bool truncate = rand() % 2 ? false : true; |
140 int size = kSize - (rand() % 4) * kSize / 4; | 140 int size = kSize - (rand() % 4) * kSize / 4; |
141 | 141 |
142 if (entries[slot]) | 142 if (entries[slot]) |
143 entries[slot]->Close(); | 143 entries[slot]->Close(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 long int iteration = strtol(argv[1], &end, 0); | 235 long int iteration = strtol(argv[1], &end, 0); |
236 | 236 |
237 if (!StartCrashThread()) { | 237 if (!StartCrashThread()) { |
238 printf("failed to start thread\n"); | 238 printf("failed to start thread\n"); |
239 return kError; | 239 return kError; |
240 } | 240 } |
241 | 241 |
242 StressTheCache(iteration); | 242 StressTheCache(iteration); |
243 return 0; | 243 return 0; |
244 } | 244 } |
OLD | NEW |