Index: util/mach/notify_server_test.cc |
diff --git a/util/mach/notify_server_test.cc b/util/mach/notify_server_test.cc |
index 4799f143d0f5310b90f91c13b7affff46016460e..4bd163bdc47880574e59de61f5d98fb59df6a112 100644 |
--- a/util/mach/notify_server_test.cc |
+++ b/util/mach/notify_server_test.cc |
@@ -30,7 +30,6 @@ namespace { |
using testing::AllOf; |
using testing::Eq; |
using testing::Invoke; |
-using testing::Ne; |
using testing::Pointee; |
using testing::ResultOf; |
using testing::Return; |
@@ -236,13 +235,14 @@ class NotifyServerTestBase : public testing::Test, |
//! else, a gtest assertion is added. |
void RunServer() { |
NotifyServer notify_server(this); |
- mach_msg_return_t mr = |
- MachMessageServer::Run(¬ify_server, |
- ServerPort(), |
- MACH_MSG_OPTION_NONE, |
- MachMessageServer::kPersistent, |
- MachMessageServer::kReceiveLargeError, |
- kMachMessageTimeoutNonblocking); |
+ mach_msg_return_t mr = MachMessageServer::Run( |
+ ¬ify_server, |
+ ServerPort(), |
+ MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) | |
+ MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT), |
Robert Sesek
2015/03/12 16:01:05
Would it be useful to collapse this expression int
Mark Mentovai
2015/03/12 17:50:52
Robert Sesek wrote:
|
+ MachMessageServer::kPersistent, |
+ MachMessageServer::kReceiveLargeError, |
+ kMachMessageTimeoutNonblocking); |
ASSERT_EQ(MACH_RCV_TIMED_OUT, mr) |
<< MachErrorMessage(mr, "MachMessageServer::Run"); |
} |
@@ -315,12 +315,14 @@ TEST_F(NotifyServerTest, MachNotifyPortDeleted) { |
SendOnceRightFromReceiveRight(receive_right)); |
ASSERT_NE(kMachPortNull, send_once_right); |
- ASSERT_TRUE(RequestMachPortNotification( |
- send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); |
+ ASSERT_TRUE( |
+ RequestMachPortNotification(send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); |
- EXPECT_CALL(*this, DoMachNotifyPortDeleted(ServerPort(), |
- send_once_right.get(), |
- Ne(nullptr))) |
+ EXPECT_CALL( |
+ *this, |
+ DoMachNotifyPortDeleted(ServerPort(), |
+ send_once_right.get(), |
+ ResultOf(AuditPIDFromMachMessageTrailer, 0))) |
.WillOnce(Return(MIG_NO_REPLY)) |
.RetiresOnSaturation(); |
@@ -339,10 +341,12 @@ TEST_F(NotifyServerTest, MachNotifyPortDestroyed) { |
ASSERT_TRUE(RequestMachPortNotification( |
receive_right, MACH_NOTIFY_PORT_DESTROYED, 0)); |
- EXPECT_CALL(*this, DoMachNotifyPortDestroyed(ServerPort(), |
- ResultOf(IsReceiveRight, true), |
- Ne(nullptr), |
- Pointee(Eq(false)))) |
+ EXPECT_CALL( |
+ *this, |
+ DoMachNotifyPortDestroyed(ServerPort(), |
+ ResultOf(IsReceiveRight, true), |
+ ResultOf(AuditPIDFromMachMessageTrailer, 0), |
+ Pointee(Eq(false)))) |
.WillOnce(DoAll(SetArgPointee<3>(true), Return(MIG_NO_REPLY))) |
.RetiresOnSaturation(); |
@@ -371,10 +375,12 @@ TEST_F(NotifyServerTest, MachNotifyNoSenders_NoSendRight) { |
NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
ASSERT_NE(kMachPortNull, receive_right); |
- ASSERT_TRUE(RequestMachPortNotification( |
- receive_right, MACH_NOTIFY_NO_SENDERS, 0)); |
+ ASSERT_TRUE( |
+ RequestMachPortNotification(receive_right, MACH_NOTIFY_NO_SENDERS, 0)); |
- EXPECT_CALL(*this, DoMachNotifyNoSenders(ServerPort(), 0, Ne(nullptr))) |
+ EXPECT_CALL(*this, |
+ DoMachNotifyNoSenders( |
+ ServerPort(), 0, ResultOf(AuditPIDFromMachMessageTrailer, 0))) |
.WillOnce(Return(MIG_NO_REPLY)) |
.RetiresOnSaturation(); |
@@ -393,10 +399,12 @@ TEST_F(NotifyServerTest, MachNotifyNoSenders_SendRightDeallocated) { |
SendRightFromReceiveRight(receive_right)); |
ASSERT_NE(kMachPortNull, send_right); |
- ASSERT_TRUE(RequestMachPortNotification( |
- receive_right, MACH_NOTIFY_NO_SENDERS, 1)); |
+ ASSERT_TRUE( |
+ RequestMachPortNotification(receive_right, MACH_NOTIFY_NO_SENDERS, 1)); |
- EXPECT_CALL(*this, DoMachNotifyNoSenders(ServerPort(), 1, Ne(nullptr))) |
+ EXPECT_CALL(*this, |
+ DoMachNotifyNoSenders( |
+ ServerPort(), 1, ResultOf(AuditPIDFromMachMessageTrailer, 0))) |
.WillOnce(Return(MIG_NO_REPLY)) |
.RetiresOnSaturation(); |
@@ -420,8 +428,8 @@ TEST_F(NotifyServerTest, MachNotifyNoSenders_NoNotification) { |
SendRightFromReceiveRight(receive_right)); |
ASSERT_NE(kMachPortNull, send_right_1); |
- ASSERT_TRUE(RequestMachPortNotification( |
- receive_right, MACH_NOTIFY_NO_SENDERS, 1)); |
+ ASSERT_TRUE( |
+ RequestMachPortNotification(receive_right, MACH_NOTIFY_NO_SENDERS, 1)); |
send_right_1.reset(); |
@@ -438,7 +446,9 @@ TEST_F(NotifyServerTest, MachNotifySendOnce_ExplicitDeallocation) { |
SendOnceRightFromReceiveRight(ServerPort())); |
ASSERT_NE(kMachPortNull, send_once_right); |
- EXPECT_CALL(*this, DoMachNotifySendOnce(ServerPort(), Ne(nullptr))) |
+ EXPECT_CALL(*this, |
+ DoMachNotifySendOnce(ServerPort(), |
+ ResultOf(AuditPIDFromMachMessageTrailer, 0))) |
.WillOnce(Return(MIG_NO_REPLY)) |
.RetiresOnSaturation(); |
@@ -470,7 +480,9 @@ TEST_F(NotifyServerTest, MachNotifySendOnce_ImplicitDeallocation) { |
MACH_PORT_NULL); |
ASSERT_EQ(MACH_MSG_SUCCESS, mr) << MachErrorMessage(mr, "mach_msg"); |
- EXPECT_CALL(*this, DoMachNotifySendOnce(ServerPort(), Ne(nullptr))) |
+ EXPECT_CALL(*this, |
+ DoMachNotifySendOnce(ServerPort(), |
+ ResultOf(AuditPIDFromMachMessageTrailer, 0))) |
.WillOnce(Return(MIG_NO_REPLY)) |
.RetiresOnSaturation(); |
@@ -491,8 +503,8 @@ TEST_F(NotifyServerTest, MachNotifyDeadName) { |
SendOnceRightFromReceiveRight(receive_right)); |
ASSERT_NE(kMachPortNull, send_once_right); |
- ASSERT_TRUE(RequestMachPortNotification( |
- send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); |
+ ASSERT_TRUE( |
+ RequestMachPortNotification(send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); |
// send_once_right becomes a dead name with the send-once right’s original |
// user reference count of 1, but the dead-name notification increments the |
@@ -502,9 +514,9 @@ TEST_F(NotifyServerTest, MachNotifyDeadName) { |
DoMachNotifyDeadName(ServerPort(), |
AllOf(send_once_right.get(), |
ResultOf(DeadNameRightRefCount, 2)), |
- Ne(nullptr))) |
- .WillOnce(DoAll(WithArg<1>(Invoke(MachPortDeallocate)), |
- Return(MIG_NO_REPLY))) |
+ ResultOf(AuditPIDFromMachMessageTrailer, 0))) |
+ .WillOnce( |
+ DoAll(WithArg<1>(Invoke(MachPortDeallocate)), Return(MIG_NO_REPLY))) |
.RetiresOnSaturation(); |
receive_right.reset(); |
@@ -529,8 +541,8 @@ TEST_F(NotifyServerTest, MachNotifyDeadName_NoNotification) { |
SendOnceRightFromReceiveRight(receive_right)); |
ASSERT_NE(kMachPortNull, send_once_right); |
- ASSERT_TRUE(RequestMachPortNotification( |
- send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); |
+ ASSERT_TRUE( |
+ RequestMachPortNotification(send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); |
RunServer(); |