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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/disk_cache_test_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/stress_cache.cc
===================================================================
--- net/disk_cache/stress_cache.cc (revision 151735)
+++ net/disk_cache/stress_cache.cc (working copy)
@@ -26,6 +26,7 @@
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/process_util.h"
+#include "base/scoped_temp_dir.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/threading/platform_thread.h"
@@ -48,14 +49,17 @@
const int kError = -1;
const int kExpectedCrash = 100;
+const char kIterationSwitch[] = "iteration";
+const char kCachePathSwitch[] = "cache_path";
// Starts a new process.
-int RunSlave(int iteration) {
+int RunSlave(int iteration, const FilePath& path) {
FilePath exe;
PathService::Get(base::FILE_EXE, &exe);
CommandLine cmdline(exe);
- cmdline.AppendArg(base::IntToString(iteration));
+ cmdline.AppendSwitchASCII(kIterationSwitch, base::IntToString(iteration));
+ cmdline.AppendSwitchPath(kCachePathSwitch, path);
base::ProcessHandle handle;
if (!base::LaunchProcess(cmdline, base::LaunchOptions(), &handle)) {
@@ -73,8 +77,10 @@
// Main loop for the master process.
int MasterCode() {
+ ScopedTempDir path;
rvargas (doing something else) 2012/08/16 22:26:43 Sorry, what I meant is that stress tests as a whol
+ CHECK(path.CreateUniqueTempDir());
for (int i = 0; i < 100000; i++) {
- int ret = RunSlave(i);
+ int ret = RunSlave(i, path.path());
if (kExpectedCrash != ret)
return ret;
}
@@ -99,9 +105,11 @@
// iteration is the current crash cycle, so the entries on the cache are marked
// to know which instance of the application wrote them.
void StressTheCache(int iteration) {
+ FilePath path = CommandLine::ForCurrentProcess()->GetSwitchValuePath(
+ kCachePathSwitch);
+
int cache_size = 0x2000000; // 32MB.
uint32 mask = 0xfff; // 4096 entries.
- FilePath path = GetCacheFilePath().InsertBeforeExtensionASCII("_stress");
base::Thread cache_thread("CacheThread");
if (!cache_thread.StartWithOptions(
@@ -261,10 +269,10 @@
logging::SetLogAssertHandler(CrashHandler);
logging::SetLogMessageHandler(MessageHandler);
+ CommandLine::Init(argc, argv);
#if defined(OS_WIN)
logging::LogEventProvider::Initialize(kStressCacheTraceProviderName);
#else
- CommandLine::Init(argc, argv);
logging::InitLogging(NULL, logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
logging::LOCK_LOG_FILE, logging::DELETE_OLD_LOG_FILE,
logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
@@ -274,9 +282,12 @@
base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(3));
MessageLoop message_loop(MessageLoop::TYPE_IO);
- char* end;
- long int iteration = strtol(argv[1], &end, 0);
+ int iteration;
+ base::StringToInt(
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(kIterationSwitch),
+ &iteration);
+
if (!StartCrashThread()) {
printf("failed to start thread\n");
return kError;
« 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