| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 18 matching lines...) Expand all Loading... |
| 29 using base::Time; | 29 using base::Time; |
| 30 | 30 |
| 31 const int kError = -1; | 31 const int kError = -1; |
| 32 const int kExpectedCrash = 100; | 32 const int kExpectedCrash = 100; |
| 33 | 33 |
| 34 // Starts a new process. | 34 // Starts a new process. |
| 35 int RunSlave(int iteration) { | 35 int RunSlave(int iteration) { |
| 36 std::wstring exe; | 36 std::wstring exe; |
| 37 PathService::Get(base::FILE_EXE, &exe); | 37 PathService::Get(base::FILE_EXE, &exe); |
| 38 | 38 |
| 39 #if defined(OS_WIN) | 39 CommandLine cmdline(exe); |
| 40 CommandLine cmdline(StringPrintf(L"%ls %d", exe.c_str(), iteration)); | 40 cmdline.AppendLooseValue(ASCIIToWide(IntToString(iteration))); |
| 41 #elif defined(OS_POSIX) | |
| 42 std::vector<std::string> cmd_argv; | |
| 43 cmd_argv.push_back(WideToUTF8(exe)); | |
| 44 cmd_argv.push_back(IntToString(iteration)); | |
| 45 CommandLine cmdline(cmd_argv); | |
| 46 #endif | |
| 47 | 41 |
| 48 base::ProcessHandle handle; | 42 base::ProcessHandle handle; |
| 49 if (!base::LaunchApp(cmdline, false, false, &handle)) { | 43 if (!base::LaunchApp(cmdline, false, false, &handle)) { |
| 50 printf("Unable to run test\n"); | 44 printf("Unable to run test\n"); |
| 51 return kError; | 45 return kError; |
| 52 } | 46 } |
| 53 | 47 |
| 54 int exit_code; | 48 int exit_code; |
| 55 if (!base::WaitForExitCode(handle, &exit_code)) { | 49 if (!base::WaitForExitCode(handle, &exit_code)) { |
| 56 printf("Unable to get return code\n"); | 50 printf("Unable to get return code\n"); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 195 |
| 202 if (!StartCrashThread()) { | 196 if (!StartCrashThread()) { |
| 203 printf("failed to start thread\n"); | 197 printf("failed to start thread\n"); |
| 204 return kError; | 198 return kError; |
| 205 } | 199 } |
| 206 | 200 |
| 207 StressTheCache(iteration); | 201 StressTheCache(iteration); |
| 208 return 0; | 202 return 0; |
| 209 } | 203 } |
| 210 | 204 |
| OLD | NEW |