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
3 // found in the LICENSE file.
5 #include "base/test/multiprocess_test.h"
7 #include "base/base_switches.h"
8 #include "base/command_line.h"
12 MultiProcessTest::MultiProcessTest() {
15 ProcessHandle
MultiProcessTest::SpawnChild(const std::string
& procname
,
16 bool debug_on_start
) {
17 FileHandleMappingVector empty_file_list
;
18 return SpawnChildImpl(procname
, empty_file_list
, debug_on_start
);
22 ProcessHandle
MultiProcessTest::SpawnChild(
23 const std::string
& procname
,
24 const FileHandleMappingVector
& fds_to_map
,
25 bool debug_on_start
) {
26 return SpawnChildImpl(procname
, fds_to_map
, debug_on_start
);
30 CommandLine
MultiProcessTest::MakeCmdLine(const std::string
& procname
,
31 bool debug_on_start
) {
32 CommandLine
cl(*CommandLine::ForCurrentProcess());
33 cl
.AppendSwitchASCII(switches::kTestChildProcess
, procname
);
35 cl
.AppendSwitch(switches::kDebugOnStart
);
39 #if !defined(OS_ANDROID)
40 ProcessHandle
MultiProcessTest::SpawnChildImpl(
41 const std::string
& procname
,
42 const FileHandleMappingVector
& fds_to_map
,
43 bool debug_on_start
) {
44 ProcessHandle handle
= kNullProcessHandle
;
45 base::LaunchOptions options
;
47 options
.start_hidden
= true;
49 options
.fds_to_remap
= &fds_to_map
;
51 base::LaunchProcess(MakeCmdLine(procname
, debug_on_start
), options
, &handle
);
54 #endif // !defined(OS_ANDROID)