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_android.cc

Issue 189373002: Add multiprocess test helper functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 <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 // - All options except |fds_to_remap| are ignored. 19 // - All options except |fds_to_remap| are ignored.
19 // - |debug_on_start| is ignored. 20 // - |debug_on_start| is ignored.
20 ProcessHandle MultiProcessTest::SpawnChildWithOptions( 21 ProcessHandle SpawnMultiProcessTestChild(
21 const std::string& procname, 22 const std::string& procname,
23 const CommandLine& /*base_command_line*/,
Paweł Hajdan Jr. 2014/03/07 02:08:01 nit: Why comment out parameter names?
viettrungluu 2014/03/07 04:42:44 Removed, though I believe the style guide permits
22 const LaunchOptions& options, 24 const LaunchOptions& options,
23 bool debug_on_start) { 25 bool /*debug_on_start*/) {
24 // TODO(vtl): The FD-remapping done below is wrong in the presence of cycles 26 // TODO(viettrungluu): The FD-remapping done below is wrong in the presence of
25 // (e.g., fd1 -> fd2, fd2 -> fd1). crbug.com/326576 27 // cycles (e.g., fd1 -> fd2, fd2 -> fd1). crbug.com/326576
26 FileHandleMappingVector empty; 28 FileHandleMappingVector empty;
27 const FileHandleMappingVector* fds_to_remap = 29 const FileHandleMappingVector* fds_to_remap =
28 options.fds_to_remap ? options.fds_to_remap : &empty; 30 options.fds_to_remap ? options.fds_to_remap : &empty;
29 31
30 pid_t pid = fork(); 32 pid_t pid = fork();
31 33
32 if (pid < 0) { 34 if (pid < 0) {
33 PLOG(ERROR) << "fork"; 35 PLOG(ERROR) << "fork";
34 return kNullProcessHandle; 36 return kNullProcessHandle;
35 } 37 }
(...skipping 22 matching lines...) Expand all
58 if (dup2(old_fd, new_fd) < 0) { 60 if (dup2(old_fd, new_fd) < 0) {
59 PLOG(FATAL) << "dup2"; 61 PLOG(FATAL) << "dup2";
60 } 62 }
61 close(old_fd); 63 close(old_fd);
62 } 64 }
63 _exit(multi_process_function_list::InvokeChildProcessTest(procname)); 65 _exit(multi_process_function_list::InvokeChildProcessTest(procname));
64 return 0; 66 return 0;
65 } 67 }
66 68
67 } // namespace base 69 } // namespace base
OLDNEW
« base/test/multiprocess_test.cc ('K') | « base/test/multiprocess_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698