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 <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "testing/multiprocess_func_list.h" | 11 #include "testing/multiprocess_func_list.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 | 14 |
15 // A very basic implementation for Android. On Android tests can run in an APK | 15 // A very basic implementation for Android. On Android tests can run in an APK |
16 // and we don't have an executable to exec*. This implementation does the bare | 16 // and we don't have an executable to exec*. This implementation does the bare |
17 // minimum to execute the method specified by procname (in the child process). | 17 // minimum to execute the method specified by procname (in the child process). |
18 // - |base_command_line| is ignored. | 18 // - |base_command_line| is ignored. |
19 // - All options except |fds_to_remap| are ignored. | 19 // - All options except |fds_to_remap| are ignored. |
20 // - |debug_on_start| is ignored. | |
21 ProcessHandle SpawnMultiProcessTestChild(const std::string& procname, | 20 ProcessHandle SpawnMultiProcessTestChild(const std::string& procname, |
22 const CommandLine& base_command_line, | 21 const CommandLine& base_command_line, |
23 const LaunchOptions& options, | 22 const LaunchOptions& options) { |
24 bool debug_on_start) { | |
25 // TODO(viettrungluu): The FD-remapping done below is wrong in the presence of | 23 // TODO(viettrungluu): The FD-remapping done below is wrong in the presence of |
26 // cycles (e.g., fd1 -> fd2, fd2 -> fd1). crbug.com/326576 | 24 // cycles (e.g., fd1 -> fd2, fd2 -> fd1). crbug.com/326576 |
27 FileHandleMappingVector empty; | 25 FileHandleMappingVector empty; |
28 const FileHandleMappingVector* fds_to_remap = | 26 const FileHandleMappingVector* fds_to_remap = |
29 options.fds_to_remap ? options.fds_to_remap : ∅ | 27 options.fds_to_remap ? options.fds_to_remap : ∅ |
30 | 28 |
31 pid_t pid = fork(); | 29 pid_t pid = fork(); |
32 | 30 |
33 if (pid < 0) { | 31 if (pid < 0) { |
34 PLOG(ERROR) << "fork"; | 32 PLOG(ERROR) << "fork"; |
(...skipping 24 matching lines...) Expand all Loading... |
59 if (dup2(old_fd, new_fd) < 0) { | 57 if (dup2(old_fd, new_fd) < 0) { |
60 PLOG(FATAL) << "dup2"; | 58 PLOG(FATAL) << "dup2"; |
61 } | 59 } |
62 close(old_fd); | 60 close(old_fd); |
63 } | 61 } |
64 _exit(multi_process_function_list::InvokeChildProcessTest(procname)); | 62 _exit(multi_process_function_list::InvokeChildProcessTest(procname)); |
65 return 0; | 63 return 0; |
66 } | 64 } |
67 | 65 |
68 } // namespace base | 66 } // namespace base |
OLD | NEW |