OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 command-line program generates the set of files needed for the crash- | 5 // This command-line program generates the set of files needed for the crash- |
6 // cache unit tests (DiskCacheTest,CacheBackend_Recover*). This program only | 6 // cache unit tests (DiskCacheTest,CacheBackend_Recover*). This program only |
7 // works properly on debug mode, because the crash functionality is not compiled | 7 // works properly on debug mode, because the crash functionality is not compiled |
8 // on release builds of the cache. | 8 // on release builds of the cache. |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/at_exit.h" | 12 #include "base/at_exit.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/process/kill.h" | 18 #include "base/process/kill.h" |
19 #include "base/process/launch.h" | 19 #include "base/process/launch.h" |
20 #include "base/process/process_handle.h" | |
21 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
23 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
24 #include "base/threading/thread.h" | 23 #include "base/threading/thread.h" |
25 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
26 #include "net/base/net_export.h" | 25 #include "net/base/net_export.h" |
27 #include "net/base/test_completion_callback.h" | 26 #include "net/base/test_completion_callback.h" |
28 #include "net/disk_cache/blockfile/backend_impl.h" | 27 #include "net/disk_cache/blockfile/backend_impl.h" |
29 #include "net/disk_cache/blockfile/rankings.h" | 28 #include "net/disk_cache/blockfile/rankings.h" |
30 #include "net/disk_cache/disk_cache.h" | 29 #include "net/disk_cache/disk_cache.h" |
(...skipping 12 matching lines...) Expand all Loading... |
43 using disk_cache::RankCrashes; | 42 using disk_cache::RankCrashes; |
44 | 43 |
45 // Starts a new process, to generate the files. | 44 // Starts a new process, to generate the files. |
46 int RunSlave(RankCrashes action) { | 45 int RunSlave(RankCrashes action) { |
47 base::FilePath exe; | 46 base::FilePath exe; |
48 PathService::Get(base::FILE_EXE, &exe); | 47 PathService::Get(base::FILE_EXE, &exe); |
49 | 48 |
50 base::CommandLine cmdline(exe); | 49 base::CommandLine cmdline(exe); |
51 cmdline.AppendArg(base::IntToString(action)); | 50 cmdline.AppendArg(base::IntToString(action)); |
52 | 51 |
53 base::ProcessHandle handle; | 52 base::Process process = base::LaunchProcess(cmdline, base::LaunchOptions()); |
54 if (!base::LaunchProcess(cmdline, base::LaunchOptions(), &handle)) { | 53 if (!process.IsValid()) { |
55 printf("Unable to run test %d\n", action); | 54 printf("Unable to run test %d\n", action); |
56 return GENERIC; | 55 return GENERIC; |
57 } | 56 } |
58 | 57 |
59 int exit_code; | 58 int exit_code; |
60 | 59 |
61 if (!base::WaitForExitCode(handle, &exit_code)) { | 60 if (!process.WaitForExit(&exit_code)) { |
62 printf("Unable to get return code, test %d\n", action); | 61 printf("Unable to get return code, test %d\n", action); |
63 return GENERIC; | 62 return GENERIC; |
64 } | 63 } |
65 if (ALL_GOOD != exit_code) | 64 if (ALL_GOOD != exit_code) |
66 printf("Test %d failed, code %d\n", action, exit_code); | 65 printf("Test %d failed, code %d\n", action, exit_code); |
67 | 66 |
68 return exit_code; | 67 return exit_code; |
69 } | 68 } |
70 | 69 |
71 // Main loop for the master process. | 70 // Main loop for the master process. |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 372 |
374 base::FilePath path; | 373 base::FilePath path; |
375 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 374 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
376 path = path.AppendASCII("net"); | 375 path = path.AppendASCII("net"); |
377 path = path.AppendASCII("data"); | 376 path = path.AppendASCII("data"); |
378 path = path.AppendASCII("cache_tests"); | 377 path = path.AppendASCII("cache_tests"); |
379 path = path.AppendASCII("new_crashes"); | 378 path = path.AppendASCII("new_crashes"); |
380 | 379 |
381 return SlaveCode(path, action); | 380 return SlaveCode(path, action); |
382 } | 381 } |
OLD | NEW |