diff options
-rw-r--r-- | base/base.gyp | 1 | ||||
-rw-r--r-- | base/test/multiprocess_test.cc | 2 | ||||
-rw-r--r-- | base/test/multiprocess_test_android.cc | 38 |
3 files changed, 41 insertions, 0 deletions
diff --git a/base/base.gyp b/base/base.gyp index 60fa8ab..31b6765 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -440,6 +440,7 @@ 'test/mock_time_provider.h', 'test/multiprocess_test.cc', 'test/multiprocess_test.h', + 'test/multiprocess_test_android.cc', 'test/perf_test_suite.cc', 'test/perf_test_suite.h', 'test/scoped_locale.cc', diff --git a/base/test/multiprocess_test.cc b/base/test/multiprocess_test.cc index b0773ae..27f9970 100644 --- a/base/test/multiprocess_test.cc +++ b/base/test/multiprocess_test.cc @@ -36,6 +36,7 @@ CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname, return cl; } +#if !defined(OS_ANDROID) ProcessHandle MultiProcessTest::SpawnChildImpl( const std::string& procname, const FileHandleMappingVector& fds_to_map, @@ -50,5 +51,6 @@ ProcessHandle MultiProcessTest::SpawnChildImpl( base::LaunchProcess(MakeCmdLine(procname, debug_on_start), options, &handle); return handle; } +#endif // !defined(OS_ANDROID) } // namespace base diff --git a/base/test/multiprocess_test_android.cc b/base/test/multiprocess_test_android.cc new file mode 100644 index 0000000..cc45d06 --- /dev/null +++ b/base/test/multiprocess_test_android.cc @@ -0,0 +1,38 @@ +// Copyright (c) 2012 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 <unistd.h> + +#include "base/logging.h" +#include "base/process.h" +#include "testing/multiprocess_func_list.h" + +namespace base { + +// A very basic implementation for android. On Android tests can run in an APK +// and we don't have an executable to exec*. This implementation does the bare +// minimum to execute the method specified by procname (in the child process). +// - File descriptors are not closed and hence |fds_to_map| is ignored. +// - |debug_on_start| is ignored. +ProcessHandle MultiProcessTest::SpawnChildImpl( + const std::string& procname, + const FileHandleMappingVector& fds_to_map, + bool debug_on_start) { + pid_t pid = fork(); + + if (pid < 0) { + DPLOG(ERROR) << "fork"; + return kNullProcessHandle; + } else if (pid == 0) { + // Child process. + _exit(multi_process_function_list::InvokeChildProcessTest(procname)); + } + + // Parent process. + return pid; +} + +} // namespace base |