forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide android specific implementation for MultiProcessTest::SpawnCh…
…ildImpl When tests are run in an APK, we do not have an executable to exec. We resort to forking and executing the test method directly. BUG=125059 TEST= Review URL: https://chromiumcodereview.appspot.com/10408081 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139342 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
nileshagrawal@chromium.org
committed
May 29, 2012
1 parent
7298a33
commit 04de380
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |