Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: net/disk_cache/stress_cache.cc

Issue 10824336: Run the disk cache tests in scoped temporary directories instead of a fixed directory so that they … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/disk_cache_test_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 key[size - 1] = '\0'; 94 key[size - 1] = '\0';
95 return std::string(key); 95 return std::string(key);
96 } 96 }
97 97
98 // This thread will loop forever, adding and removing entries from the cache. 98 // This thread will loop forever, adding and removing entries from the cache.
99 // iteration is the current crash cycle, so the entries on the cache are marked 99 // iteration is the current crash cycle, so the entries on the cache are marked
100 // to know which instance of the application wrote them. 100 // to know which instance of the application wrote them.
101 void StressTheCache(int iteration) { 101 void StressTheCache(int iteration) {
102 int cache_size = 0x2000000; // 32MB. 102 int cache_size = 0x2000000; // 32MB.
103 uint32 mask = 0xfff; // 4096 entries. 103 uint32 mask = 0xfff; // 4096 entries.
104 FilePath path = GetCacheFilePath().InsertBeforeExtensionASCII("_stress"); 104
105 FilePath path;
106 PathService::Get(base::DIR_TEMP, &path);
107 path = path.AppendASCII("cache_test_stress");
105 108
106 base::Thread cache_thread("CacheThread"); 109 base::Thread cache_thread("CacheThread");
107 if (!cache_thread.StartWithOptions( 110 if (!cache_thread.StartWithOptions(
108 base::Thread::Options(MessageLoop::TYPE_IO, 0))) 111 base::Thread::Options(MessageLoop::TYPE_IO, 0)))
109 return; 112 return;
110 113
111 disk_cache::BackendImpl* cache = 114 disk_cache::BackendImpl* cache =
112 new disk_cache::BackendImpl(path, mask, cache_thread.message_loop_proxy(), 115 new disk_cache::BackendImpl(path, mask, cache_thread.message_loop_proxy(),
113 NULL); 116 NULL);
114 cache->SetMaxSize(cache_size); 117 cache->SetMaxSize(cache_size);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 long int iteration = strtol(argv[1], &end, 0); 281 long int iteration = strtol(argv[1], &end, 0);
279 282
280 if (!StartCrashThread()) { 283 if (!StartCrashThread()) {
281 printf("failed to start thread\n"); 284 printf("failed to start thread\n");
282 return kError; 285 return kError;
283 } 286 }
284 287
285 StressTheCache(iteration); 288 StressTheCache(iteration);
286 return 0; 289 return 0;
287 } 290 }
OLDNEW
« no previous file with comments | « net/disk_cache/disk_cache_test_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698