Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: base/test/multiprocess_test.cc

Issue 2733323002: Changing multiprocess test SpawnChild to return a struct. (Closed)
Patch Set: Synced Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/test/multiprocess_test.h ('k') | base/test/multiprocess_test_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 #if !defined(OS_ANDROID) 15 #if !defined(OS_ANDROID)
16 Process SpawnMultiProcessTestChild( 16 SpawnChildResult SpawnMultiProcessTestChild(
17 const std::string& procname, 17 const std::string& procname,
18 const CommandLine& base_command_line, 18 const CommandLine& base_command_line,
19 const LaunchOptions& options) { 19 const LaunchOptions& options) {
20 CommandLine command_line(base_command_line); 20 CommandLine command_line(base_command_line);
21 // TODO(viettrungluu): See comment above |MakeCmdLine()| in the header file. 21 // TODO(viettrungluu): See comment above |MakeCmdLine()| in the header file.
22 // This is a temporary hack, since |MakeCmdLine()| has to provide a full 22 // This is a temporary hack, since |MakeCmdLine()| has to provide a full
23 // command line. 23 // command line.
24 if (!command_line.HasSwitch(switches::kTestChildProcess)) 24 if (!command_line.HasSwitch(switches::kTestChildProcess))
25 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); 25 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname);
26 26
27 return LaunchProcess(command_line, options); 27 SpawnChildResult result;
28 result.process = LaunchProcess(command_line, options);
29 return result;
28 } 30 }
29 31
30 bool WaitForMultiprocessTestChildExit(const Process& process, 32 bool WaitForMultiprocessTestChildExit(const Process& process,
31 TimeDelta timeout, 33 TimeDelta timeout,
32 int* exit_code) { 34 int* exit_code) {
33 return process.WaitForExitWithTimeout(timeout, exit_code); 35 return process.WaitForExitWithTimeout(timeout, exit_code);
34 } 36 }
35 37
36 bool TerminateMultiProcessTestChild(const Process& process, 38 bool TerminateMultiProcessTestChild(const Process& process,
37 int exit_code, 39 int exit_code,
38 bool wait) { 40 bool wait) {
39 return process.Terminate(exit_code, wait); 41 return process.Terminate(exit_code, wait);
40 } 42 }
41 43
42 #endif // !defined(OS_ANDROID) 44 #endif // !defined(OS_ANDROID)
43 45
44 CommandLine GetMultiProcessTestChildBaseCommandLine() { 46 CommandLine GetMultiProcessTestChildBaseCommandLine() {
45 CommandLine cmd_line = *CommandLine::ForCurrentProcess(); 47 CommandLine cmd_line = *CommandLine::ForCurrentProcess();
46 cmd_line.SetProgram(MakeAbsoluteFilePath(cmd_line.GetProgram())); 48 cmd_line.SetProgram(MakeAbsoluteFilePath(cmd_line.GetProgram()));
47 return cmd_line; 49 return cmd_line;
48 } 50 }
49 51
50 // MultiProcessTest ------------------------------------------------------------ 52 // MultiProcessTest ------------------------------------------------------------
51 53
52 MultiProcessTest::MultiProcessTest() { 54 MultiProcessTest::MultiProcessTest() {
53 } 55 }
54 56
55 Process MultiProcessTest::SpawnChild(const std::string& procname) { 57 SpawnChildResult MultiProcessTest::SpawnChild(const std::string& procname) {
56 LaunchOptions options; 58 LaunchOptions options;
57 #if defined(OS_WIN) 59 #if defined(OS_WIN)
58 options.start_hidden = true; 60 options.start_hidden = true;
59 #endif 61 #endif
60 return SpawnChildWithOptions(procname, options); 62 return SpawnChildWithOptions(procname, options);
61 } 63 }
62 64
63 Process MultiProcessTest::SpawnChildWithOptions( 65 SpawnChildResult MultiProcessTest::SpawnChildWithOptions(
64 const std::string& procname, 66 const std::string& procname,
65 const LaunchOptions& options) { 67 const LaunchOptions& options) {
66 return SpawnMultiProcessTestChild(procname, MakeCmdLine(procname), options); 68 return SpawnMultiProcessTestChild(procname, MakeCmdLine(procname), options);
67 } 69 }
68 70
69 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname) { 71 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname) {
70 CommandLine command_line = GetMultiProcessTestChildBaseCommandLine(); 72 CommandLine command_line = GetMultiProcessTestChildBaseCommandLine();
71 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); 73 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname);
72 return command_line; 74 return command_line;
73 } 75 }
74 76
75 } // namespace base 77 } // namespace base
OLDNEW
« no previous file with comments | « base/test/multiprocess_test.h ('k') | base/test/multiprocess_test_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698