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; |