| OLD | NEW |
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 using base::Time; | 49 using base::Time; |
| 50 | 50 |
| 51 const int kError = -1; | 51 const int kError = -1; |
| 52 const int kExpectedCrash = 100; | 52 const int kExpectedCrash = 100; |
| 53 | 53 |
| 54 // Starts a new process. | 54 // Starts a new process. |
| 55 int RunSlave(int iteration) { | 55 int RunSlave(int iteration) { |
| 56 base::FilePath exe; | 56 base::FilePath exe; |
| 57 PathService::Get(base::FILE_EXE, &exe); | 57 PathService::Get(base::FILE_EXE, &exe); |
| 58 | 58 |
| 59 CommandLine cmdline(exe); | 59 base::CommandLine cmdline(exe); |
| 60 cmdline.AppendArg(base::IntToString(iteration)); | 60 cmdline.AppendArg(base::IntToString(iteration)); |
| 61 | 61 |
| 62 base::ProcessHandle handle; | 62 base::ProcessHandle handle; |
| 63 if (!base::LaunchProcess(cmdline, base::LaunchOptions(), &handle)) { | 63 if (!base::LaunchProcess(cmdline, base::LaunchOptions(), &handle)) { |
| 64 printf("Unable to run test\n"); | 64 printf("Unable to run test\n"); |
| 65 return kError; | 65 return kError; |
| 66 } | 66 } |
| 67 | 67 |
| 68 int exit_code; | 68 int exit_code; |
| 69 if (!base::WaitForExitCode(handle, &exit_code)) { | 69 if (!base::WaitForExitCode(handle, &exit_code)) { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 264 |
| 265 if (argc < 2) | 265 if (argc < 2) |
| 266 return MasterCode(); | 266 return MasterCode(); |
| 267 | 267 |
| 268 logging::SetLogAssertHandler(CrashHandler); | 268 logging::SetLogAssertHandler(CrashHandler); |
| 269 logging::SetLogMessageHandler(MessageHandler); | 269 logging::SetLogMessageHandler(MessageHandler); |
| 270 | 270 |
| 271 #if defined(OS_WIN) | 271 #if defined(OS_WIN) |
| 272 logging::LogEventProvider::Initialize(kStressCacheTraceProviderName); | 272 logging::LogEventProvider::Initialize(kStressCacheTraceProviderName); |
| 273 #else | 273 #else |
| 274 CommandLine::Init(argc, argv); | 274 base::CommandLine::Init(argc, argv); |
| 275 logging::LoggingSettings settings; | 275 logging::LoggingSettings settings; |
| 276 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 276 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 277 logging::InitLogging(settings); | 277 logging::InitLogging(settings); |
| 278 #endif | 278 #endif |
| 279 | 279 |
| 280 // Some time for the memory manager to flush stuff. | 280 // Some time for the memory manager to flush stuff. |
| 281 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(3)); | 281 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(3)); |
| 282 base::MessageLoopForIO message_loop; | 282 base::MessageLoopForIO message_loop; |
| 283 | 283 |
| 284 char* end; | 284 char* end; |
| 285 long int iteration = strtol(argv[1], &end, 0); | 285 long int iteration = strtol(argv[1], &end, 0); |
| 286 | 286 |
| 287 if (!StartCrashThread()) { | 287 if (!StartCrashThread()) { |
| 288 printf("failed to start thread\n"); | 288 printf("failed to start thread\n"); |
| 289 return kError; | 289 return kError; |
| 290 } | 290 } |
| 291 | 291 |
| 292 StressTheCache(iteration); | 292 StressTheCache(iteration); |
| 293 return 0; | 293 return 0; |
| 294 } | 294 } |
| OLD | NEW |