summaryrefslogtreecommitdiffstats
path: root/sandbox
diff options
context:
space:
mode:
authorrvargas <rvargas@chromium.org>2015-01-12 14:23:23 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-12 22:25:04 +0000
commit07b589c1f6c4d0aac24e270a13fa83031bf2038c (patch)
tree18a5284042b77bb6845194277e8dea006576b636 /sandbox
parentd44cce5915db087d726ed2e141896401edeb09b7 (diff)
downloadchromium_src-07b589c1f6c4d0aac24e270a13fa83031bf2038c.zip
chromium_src-07b589c1f6c4d0aac24e270a13fa83031bf2038c.tar.gz
chromium_src-07b589c1f6c4d0aac24e270a13fa83031bf2038c.tar.bz2
MultiProcessTest: Update SpawnChild* to return a Process.
We should not be dealing with raw handles. BUG=417532 Review URL: https://codereview.chromium.org/843113003 Cr-Commit-Position: refs/heads/master@{#311127}
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/mac/bootstrap_sandbox_unittest.mm27
-rw-r--r--sandbox/mac/xpc_message_server_unittest.cc12
2 files changed, 18 insertions, 21 deletions
diff --git a/sandbox/mac/bootstrap_sandbox_unittest.mm b/sandbox/mac/bootstrap_sandbox_unittest.mm
index d9d02c7..bd788bd 100644
--- a/sandbox/mac/bootstrap_sandbox_unittest.mm
+++ b/sandbox/mac/bootstrap_sandbox_unittest.mm
@@ -100,14 +100,14 @@ class BootstrapSandboxTest : public base::MultiProcessTest {
sandbox_->PrepareToForkWithPolicy(policy_id);
base::LaunchOptions options;
options.replacement_bootstrap_name = sandbox_->server_bootstrap_name();
- base::ProcessHandle pid = SpawnChildWithOptions(child_name, options);
- ASSERT_GT(pid, 0);
- sandbox_->FinishedFork(pid);
+ base::Process process = SpawnChildWithOptions(child_name, options);
+ ASSERT_TRUE(process.IsValid());
+ sandbox_->FinishedFork(process.Handle());
int code = 0;
- EXPECT_TRUE(base::WaitForExitCode(pid, &code));
+ EXPECT_TRUE(process.WaitForExit(&code));
EXPECT_EQ(0, code);
if (out_pid)
- *out_pid = pid;
+ *out_pid = process.pid();
}
protected:
@@ -121,15 +121,15 @@ TEST_F(BootstrapSandboxTest, DistributedNotifications_Unsandboxed) {
base::scoped_nsobject<DistributedNotificationObserver> observer(
[[DistributedNotificationObserver alloc] init]);
- base::ProcessHandle pid = SpawnChild(kNotificationTestMain);
- ASSERT_GT(pid, 0);
+ base::Process process = SpawnChild(kNotificationTestMain);
+ ASSERT_TRUE(process.IsValid());
int code = 0;
- EXPECT_TRUE(base::WaitForExitCode(pid, &code));
+ EXPECT_TRUE(process.WaitForExit(&code));
EXPECT_EQ(0, code);
[observer waitForNotification];
EXPECT_EQ(1, [observer receivedCount]);
- EXPECT_EQ(pid, [[observer object] intValue]);
+ EXPECT_EQ(process.pid(), [[observer object] intValue]);
}
// Run the test with the sandbox enabled without notifications on the policy
@@ -439,10 +439,9 @@ TEST_F(BootstrapSandboxTest, ChildOutliveSandbox) {
sandbox_->PrepareToForkWithPolicy(kTestPolicyId);
base::LaunchOptions options;
options.replacement_bootstrap_name = sandbox_->server_bootstrap_name();
- base::ProcessHandle pid =
- SpawnChildWithOptions("ChildOutliveSandbox", options);
- ASSERT_GT(pid, 0);
- sandbox_->FinishedFork(pid);
+ base::Process process = SpawnChildWithOptions("ChildOutliveSandbox", options);
+ ASSERT_TRUE(process.IsValid());
+ sandbox_->FinishedFork(process.Handle());
// Synchronize with the child.
mach_msg_empty_rcv_t rcv_msg;
@@ -468,7 +467,7 @@ TEST_F(BootstrapSandboxTest, ChildOutliveSandbox) {
EXPECT_EQ(KERN_SUCCESS, kr) << mach_error_string(kr);
int code = 0;
- EXPECT_TRUE(base::WaitForExitCode(pid, &code));
+ EXPECT_TRUE(process.WaitForExit(&code));
EXPECT_EQ(0, code);
}
diff --git a/sandbox/mac/xpc_message_server_unittest.cc b/sandbox/mac/xpc_message_server_unittest.cc
index 2632a6e..b9f90562 100644
--- a/sandbox/mac/xpc_message_server_unittest.cc
+++ b/sandbox/mac/xpc_message_server_unittest.cc
@@ -149,21 +149,19 @@ XPC_TEST_F(GetSenderPID) // {
#pragma GCC diagnostic pop
ASSERT_EQ(KERN_SUCCESS, kr);
- base::ProcessHandle child_handle = base::SpawnMultiProcessTestChild(
+ base::Process child = base::SpawnMultiProcessTestChild(
"GetSenderPID",
base::GetMultiProcessTestChildBaseCommandLine(),
base::LaunchOptions());
- ASSERT_NE(base::kNullProcessHandle, child_handle);
+ ASSERT_TRUE(child.IsValid());
int exit_code = -1;
- ASSERT_TRUE(base::WaitForExitCode(child_handle, &exit_code));
+ ASSERT_TRUE(child.WaitForExit(&exit_code));
EXPECT_EQ(0, exit_code);
- EXPECT_EQ(base::GetProcId(child_handle), sender_pid);
- EXPECT_EQ(base::GetProcId(child_handle), child_pid);
+ EXPECT_EQ(child.pid(), sender_pid);
+ EXPECT_EQ(child.pid(), child_pid);
EXPECT_EQ(sender_pid, child_pid);
-
- base::CloseProcessHandle(child_handle);
}
MULTIPROCESS_TEST_MAIN(GetSenderPID) {