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 #include "base/test/multiprocess_test.h" | 5 #include "base/test/multiprocess_test.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" |
9 | 11 |
10 namespace base { | 12 namespace base { |
11 | 13 |
12 #if !defined(OS_ANDROID) | 14 #if !defined(OS_ANDROID) |
13 Process SpawnMultiProcessTestChild( | 15 Process SpawnMultiProcessTestChild( |
14 const std::string& procname, | 16 const std::string& procname, |
15 const CommandLine& base_command_line, | 17 const CommandLine& base_command_line, |
16 const LaunchOptions& options) { | 18 const LaunchOptions& options) { |
17 CommandLine command_line(base_command_line); | 19 CommandLine command_line(base_command_line); |
18 // TODO(viettrungluu): See comment above |MakeCmdLine()| in the header file. | 20 // TODO(viettrungluu): See comment above |MakeCmdLine()| in the header file. |
19 // This is a temporary hack, since |MakeCmdLine()| has to provide a full | 21 // This is a temporary hack, since |MakeCmdLine()| has to provide a full |
20 // command line. | 22 // command line. |
21 if (!command_line.HasSwitch(switches::kTestChildProcess)) | 23 if (!command_line.HasSwitch(switches::kTestChildProcess)) |
22 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); | 24 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); |
23 | 25 |
24 return LaunchProcess(command_line, options); | 26 return LaunchProcess(command_line, options); |
25 } | 27 } |
26 #endif // !defined(OS_ANDROID) | 28 #endif // !defined(OS_ANDROID) |
27 | 29 |
28 CommandLine GetMultiProcessTestChildBaseCommandLine() { | 30 CommandLine GetMultiProcessTestChildBaseCommandLine() { |
29 return *CommandLine::ForCurrentProcess(); | 31 CommandLine cmd_line = *CommandLine::ForCurrentProcess(); |
| 32 cmd_line.SetProgram(MakeAbsoluteFilePath(cmd_line.GetProgram())); |
| 33 return cmd_line; |
30 } | 34 } |
31 | 35 |
32 // MultiProcessTest ------------------------------------------------------------ | 36 // MultiProcessTest ------------------------------------------------------------ |
33 | 37 |
34 MultiProcessTest::MultiProcessTest() { | 38 MultiProcessTest::MultiProcessTest() { |
35 } | 39 } |
36 | 40 |
37 Process MultiProcessTest::SpawnChild(const std::string& procname) { | 41 Process MultiProcessTest::SpawnChild(const std::string& procname) { |
38 LaunchOptions options; | 42 LaunchOptions options; |
39 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
40 options.start_hidden = true; | 44 options.start_hidden = true; |
41 #endif | 45 #endif |
42 return SpawnChildWithOptions(procname, options); | 46 return SpawnChildWithOptions(procname, options); |
43 } | 47 } |
44 | 48 |
45 Process MultiProcessTest::SpawnChildWithOptions( | 49 Process MultiProcessTest::SpawnChildWithOptions( |
46 const std::string& procname, | 50 const std::string& procname, |
47 const LaunchOptions& options) { | 51 const LaunchOptions& options) { |
48 return SpawnMultiProcessTestChild(procname, MakeCmdLine(procname), options); | 52 return SpawnMultiProcessTestChild(procname, MakeCmdLine(procname), options); |
49 } | 53 } |
50 | 54 |
51 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname) { | 55 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname) { |
52 CommandLine command_line = GetMultiProcessTestChildBaseCommandLine(); | 56 CommandLine command_line = GetMultiProcessTestChildBaseCommandLine(); |
53 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); | 57 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); |
54 return command_line; | 58 return command_line; |
55 } | 59 } |
56 | 60 |
57 } // namespace base | 61 } // namespace base |
OLD | NEW |