Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Unified Diff: base/test/multiprocess_test_android.cc

Issue 104803007: Add a MultiProcessTest::SpawnChildWithOptions(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better comment Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/multiprocess_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/multiprocess_test_android.cc
diff --git a/base/test/multiprocess_test_android.cc b/base/test/multiprocess_test_android.cc
index 51c2ce020d09e50e3352a8609d74462f1c4969fd..c518bb438ac87e652ec38b20aac66288b7b5dcdc 100644
--- a/base/test/multiprocess_test_android.cc
+++ b/base/test/multiprocess_test_android.cc
@@ -12,14 +12,21 @@
namespace base {
-// A very basic implementation for android. On Android tests can run in an APK
+// 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).
+// - All options except |fds_to_remap| are ignored.
// - |debug_on_start| is ignored.
-ProcessHandle MultiProcessTest::SpawnChildImpl(
+ProcessHandle MultiProcessTest::SpawnChildWithOptions(
const std::string& procname,
- const FileHandleMappingVector& fds_to_remap,
+ const LaunchOptions& options,
bool debug_on_start) {
+ // TODO(vtl): The FD-remapping done below is wrong in the presence of cycles
+ // (e.g., fd1 -> fd2, fd2 -> fd1). crbug.com/326576
+ FileHandleMappingVector empty;
+ const FileHandleMappingVector* fds_to_remap =
+ options.fds_to_remap ? options.fds_to_remap : ∅
+
pid_t pid = fork();
if (pid < 0) {
@@ -32,8 +39,8 @@ ProcessHandle MultiProcessTest::SpawnChildImpl(
}
// Child process.
std::hash_set<int> fds_to_keep_open;
- for (FileHandleMappingVector::const_iterator it = fds_to_remap.begin();
- it != fds_to_remap.end(); ++it) {
+ for (FileHandleMappingVector::const_iterator it = fds_to_remap->begin();
+ it != fds_to_remap->end(); ++it) {
fds_to_keep_open.insert(it->first);
}
// Keep stdin, stdout and stderr open since this is not meant to spawn a
@@ -44,8 +51,8 @@ ProcessHandle MultiProcessTest::SpawnChildImpl(
close(fd);
}
}
- for (FileHandleMappingVector::const_iterator it = fds_to_remap.begin();
- it != fds_to_remap.end(); ++it) {
+ for (FileHandleMappingVector::const_iterator it = fds_to_remap->begin();
+ it != fds_to_remap->end(); ++it) {
int old_fd = it->first;
int new_fd = it->second;
if (dup2(old_fd, new_fd) < 0) {
« no previous file with comments | « base/test/multiprocess_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698