Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #include "base/test/multiprocess_test.h" | |
| 6 | |
| 7 #include <unistd.h> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "base/process.h" | |
| 11 #include "testing/multiprocess_func_list.h" | |
| 12 | |
| 13 namespace base { | |
| 14 | |
| 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 | |
| 17 // minimum to execute the method specified by procname (in the child process). | |
| 18 // - File descriptors are not closed and hence |fds_to_map| is ignored. | |
| 19 // - |debug_on_start| is ignored. | |
| 20 ProcessHandle MultiProcessTest::SpawnChildImpl( | |
| 21 const std::string& procname, | |
| 22 const FileHandleMappingVector& fds_to_map, | |
| 23 bool debug_on_start) { | |
| 24 pid_t pid = fork(); | |
| 25 | |
| 26 if (pid < 0) { | |
| 27 DPLOG(ERROR) << "fork"; | |
| 28 return kNullProcessHandle; | |
| 29 } else if (pid == 0) { | |
| 30 // Child process | |
|
Paweł Hajdan Jr.
2012/05/29 08:32:12
nit: Dot at the end: http://google-styleguide.goog
nilesh
2012/05/29 16:55:03
Done.
| |
| 31 int ret = multi_process_function_list::InvokeChildProcessTest(procname); | |
|
Paweł Hajdan Jr.
2012/05/29 08:32:12
nit: No need for temporary int ret, why not just _
nilesh
2012/05/29 16:55:03
Done.
| |
| 32 _exit(ret); | |
| 33 } | |
| 34 | |
| 35 // Parent process | |
|
Paweł Hajdan Jr.
2012/05/29 08:32:12
nit: Dot at the end.
nilesh
2012/05/29 16:55:03
Done.
| |
| 36 return pid; | |
| 37 } | |
| 38 | |
| 39 } // namespace base | |
| OLD | NEW |