diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-09 15:25:53 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-09 15:25:53 +0000 |
commit | 19d536f25ffa4e876c7af79b201c7330841b31ea (patch) | |
tree | 2f64619a8812920692bd3c7e69103727021e9d53 /base/test/multiprocess_test.cc | |
parent | 6c4e6631acb0893ba00f035792e80942e2b00bd3 (diff) | |
download | chromium_src-19d536f25ffa4e876c7af79b201c7330841b31ea.zip chromium_src-19d536f25ffa4e876c7af79b201c7330841b31ea.tar.gz chromium_src-19d536f25ffa4e876c7af79b201c7330841b31ea.tar.bz2 |
Cleanup in base. This moves the implementation (and a bunch of header file
dependencies) from the multiprocess test and the test_suite headers to .cc
files. Moves multiprocess_test to the test directory, and all of this stuff to
the existing base_test_support project. I also used the base namespace.
Previously other projects included this functionality just by #include because
it was all inline, so I had to add dependencies on base_test_support in a few
places.
Moves and renames the command line switch this was using to base_switches. Move
the base switch for process type to chrome switches.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/3026055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55400 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test/multiprocess_test.cc')
-rw-r--r-- | base/test/multiprocess_test.cc | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/base/test/multiprocess_test.cc b/base/test/multiprocess_test.cc new file mode 100644 index 0000000..a1a3bbe --- /dev/null +++ b/base/test/multiprocess_test.cc @@ -0,0 +1,74 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/test/multiprocess_test.h" + +#include "base/base_switches.h" +#include "base/command_line.h" + +#if defined(OS_POSIX) +#include <sys/types.h> +#include <unistd.h> +#endif + +namespace base { + +MultiProcessTest::MultiProcessTest() { +} + +ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname, + bool debug_on_start) { +#if defined(OS_WIN) + return SpawnChildImpl(procname, debug_on_start); +#elif defined(OS_POSIX) + file_handle_mapping_vector empty_file_list; + return SpawnChildImpl(procname, empty_file_list, debug_on_start); +#endif +} + +#if defined(OS_POSIX) +ProcessHandle MultiProcessTest::SpawnChild( + const std::string& procname, + const file_handle_mapping_vector& fds_to_map, + bool debug_on_start) { + return SpawnChildImpl(procname, fds_to_map, debug_on_start); +} +#endif + +CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname, + bool debug_on_start) { + CommandLine cl(*CommandLine::ForCurrentProcess()); + cl.AppendSwitchASCII(switches::kTestChildProcess, procname); + if (debug_on_start) + cl.AppendSwitch(switches::kDebugOnStart); + return cl; +} + +#if defined(OS_WIN) + +ProcessHandle MultiProcessTest::SpawnChildImpl(const std::string& procname, + bool debug_on_start) { + ProcessHandle handle = static_cast<ProcessHandle>(NULL); + LaunchApp(MakeCmdLine(procname, debug_on_start), + false, true, &handle); + return handle; +} + +#elif defined(OS_POSIX) + +// TODO(port): with the CommandLine refactoring, this code is very similar +// to the Windows code. Investigate whether this can be made shorter. +ProcessHandle MultiProcessTest::SpawnChildImpl( + const std::string& procname, + const file_handle_mapping_vector& fds_to_map, + bool debug_on_start) { + ProcessHandle handle = kNullProcessHandle; + LaunchApp(MakeCmdLine(procname, debug_on_start).argv(), + fds_to_map, false, &handle); + return handle; +} + +#endif + +} // namespace base |