Index: sandbox/mac/bootstrap_sandbox_unittest.mm |
diff --git a/sandbox/mac/bootstrap_sandbox_unittest.mm b/sandbox/mac/bootstrap_sandbox_unittest.mm |
index fb3892374b7d1cf1ea10e09ab33b830c9bd863b3..5efa92549fdcdbdb845fb657e0d397e97b018711 100644 |
--- a/sandbox/mac/bootstrap_sandbox_unittest.mm |
+++ b/sandbox/mac/bootstrap_sandbox_unittest.mm |
@@ -225,11 +225,27 @@ struct SubstitutePortAckRecv : public SubstitutePortAckSend { |
const char kSubstituteAck[] = "Hello, this is doge!"; |
TEST_F(BootstrapSandboxTest, PolicySubstitutePort) { |
+ mach_port_t task = mach_task_self(); |
+ |
mach_port_t port; |
- ASSERT_EQ(KERN_SUCCESS, mach_port_allocate(mach_task_self(), |
- MACH_PORT_RIGHT_RECEIVE, &port)); |
+ ASSERT_EQ(KERN_SUCCESS, mach_port_allocate(task, MACH_PORT_RIGHT_RECEIVE, |
+ &port)); |
base::mac::ScopedMachReceiveRight scoped_port(port); |
+ mach_port_urefs_t send_rights = 0; |
+ ASSERT_EQ(KERN_SUCCESS, mach_port_get_refs(task, port, MACH_PORT_RIGHT_SEND, |
+ &send_rights)); |
+ EXPECT_EQ(0u, send_rights); |
+ |
+ ASSERT_EQ(KERN_SUCCESS, mach_port_insert_right(task, port, port, |
+ MACH_MSG_TYPE_MAKE_SEND)); |
+ base::mac::ScopedMachSendRight scoped_port_send(port); |
+ |
+ send_rights = 0; |
+ ASSERT_EQ(KERN_SUCCESS, mach_port_get_refs(task, port, MACH_PORT_RIGHT_SEND, |
+ &send_rights)); |
+ EXPECT_EQ(1u, send_rights); |
+ |
BootstrapSandboxPolicy policy(BaselinePolicy()); |
policy[kTestServer] = Rule(port); |
sandbox_->RegisterSandboxPolicy(1, policy); |
@@ -245,6 +261,11 @@ TEST_F(BootstrapSandboxTest, PolicySubstitutePort) { |
TestTimeouts::tiny_timeout().InMilliseconds(), MACH_PORT_NULL); |
EXPECT_EQ(KERN_SUCCESS, kr); |
+ send_rights = 0; |
+ ASSERT_EQ(KERN_SUCCESS, mach_port_get_refs(task, port, MACH_PORT_RIGHT_SEND, |
+ &send_rights)); |
+ EXPECT_EQ(1u, send_rights); |
+ |
EXPECT_EQ(0, strncmp(kSubstituteAck, msg.buf, sizeof(msg.buf))); |
} |