OLD | NEW |
---|---|
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "util/mach/mach_message_server.h" | 23 #include "util/mach/mach_message_server.h" |
24 #include "util/test/mac/mach_errors.h" | 24 #include "util/test/mac/mach_errors.h" |
25 | 25 |
26 namespace crashpad { | 26 namespace crashpad { |
27 namespace test { | 27 namespace test { |
28 namespace { | 28 namespace { |
29 | 29 |
30 using testing::AllOf; | 30 using testing::AllOf; |
31 using testing::Eq; | 31 using testing::Eq; |
32 using testing::Invoke; | 32 using testing::Invoke; |
33 using testing::Ne; | |
34 using testing::Pointee; | 33 using testing::Pointee; |
35 using testing::ResultOf; | 34 using testing::ResultOf; |
36 using testing::Return; | 35 using testing::Return; |
37 using testing::SetArgPointee; | 36 using testing::SetArgPointee; |
38 using testing::StrictMock; | 37 using testing::StrictMock; |
39 using testing::WithArg; | 38 using testing::WithArg; |
40 | 39 |
41 //! \brief Adds a send right to an existing receive right. | 40 //! \brief Adds a send right to an existing receive right. |
42 //! | 41 //! |
43 //! \param[in] receive_right The receive right to add a send right to. | 42 //! \param[in] receive_right The receive right to add a send right to. |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 //! The server will listen on ServerPort() in persistent nonblocking mode, and | 228 //! The server will listen on ServerPort() in persistent nonblocking mode, and |
230 //! dispatch received messages to the appropriate NotifyServer::Interface | 229 //! dispatch received messages to the appropriate NotifyServer::Interface |
231 //! method. gmock expectations check that the proper method, if any, is called | 230 //! method. gmock expectations check that the proper method, if any, is called |
232 //! exactly once, and that no undesired methods are called. | 231 //! exactly once, and that no undesired methods are called. |
233 //! | 232 //! |
234 //! MachMessageServer::Run() is expected to return `MACH_RCV_TIMED_OUT`, | 233 //! MachMessageServer::Run() is expected to return `MACH_RCV_TIMED_OUT`, |
235 //! because it runs in persistent nonblocking mode. If it returns anything | 234 //! because it runs in persistent nonblocking mode. If it returns anything |
236 //! else, a gtest assertion is added. | 235 //! else, a gtest assertion is added. |
237 void RunServer() { | 236 void RunServer() { |
238 NotifyServer notify_server(this); | 237 NotifyServer notify_server(this); |
239 mach_msg_return_t mr = | 238 mach_msg_return_t mr = MachMessageServer::Run( |
240 MachMessageServer::Run(¬ify_server, | 239 ¬ify_server, |
241 ServerPort(), | 240 ServerPort(), |
242 MACH_MSG_OPTION_NONE, | 241 MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) | |
243 MachMessageServer::kPersistent, | 242 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:
| |
244 MachMessageServer::kReceiveLargeError, | 243 MachMessageServer::kPersistent, |
245 kMachMessageTimeoutNonblocking); | 244 MachMessageServer::kReceiveLargeError, |
245 kMachMessageTimeoutNonblocking); | |
246 ASSERT_EQ(MACH_RCV_TIMED_OUT, mr) | 246 ASSERT_EQ(MACH_RCV_TIMED_OUT, mr) |
247 << MachErrorMessage(mr, "MachMessageServer::Run"); | 247 << MachErrorMessage(mr, "MachMessageServer::Run"); |
248 } | 248 } |
249 | 249 |
250 //! \brief Returns the receive right to be used for the server. | 250 //! \brief Returns the receive right to be used for the server. |
251 //! | 251 //! |
252 //! This receive right is created lazily on a per-test basis. It is destroyed | 252 //! This receive right is created lazily on a per-test basis. It is destroyed |
253 //! by TearDown() at the conclusion of each test. | 253 //! by TearDown() at the conclusion of each test. |
254 //! | 254 //! |
255 //! \return The server port receive right, creating it if one has not yet been | 255 //! \return The server port receive right, creating it if one has not yet been |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 // a port-deleted notification should be generated. | 308 // a port-deleted notification should be generated. |
309 TEST_F(NotifyServerTest, MachNotifyPortDeleted) { | 309 TEST_F(NotifyServerTest, MachNotifyPortDeleted) { |
310 base::mac::ScopedMachReceiveRight receive_right( | 310 base::mac::ScopedMachReceiveRight receive_right( |
311 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); | 311 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
312 ASSERT_NE(kMachPortNull, receive_right); | 312 ASSERT_NE(kMachPortNull, receive_right); |
313 | 313 |
314 base::mac::ScopedMachSendRight send_once_right( | 314 base::mac::ScopedMachSendRight send_once_right( |
315 SendOnceRightFromReceiveRight(receive_right)); | 315 SendOnceRightFromReceiveRight(receive_right)); |
316 ASSERT_NE(kMachPortNull, send_once_right); | 316 ASSERT_NE(kMachPortNull, send_once_right); |
317 | 317 |
318 ASSERT_TRUE(RequestMachPortNotification( | 318 ASSERT_TRUE( |
319 send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); | 319 RequestMachPortNotification(send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); |
320 | 320 |
321 EXPECT_CALL(*this, DoMachNotifyPortDeleted(ServerPort(), | 321 EXPECT_CALL( |
322 send_once_right.get(), | 322 *this, |
323 Ne(nullptr))) | 323 DoMachNotifyPortDeleted(ServerPort(), |
324 send_once_right.get(), | |
325 ResultOf(AuditPIDFromMachMessageTrailer, 0))) | |
324 .WillOnce(Return(MIG_NO_REPLY)) | 326 .WillOnce(Return(MIG_NO_REPLY)) |
325 .RetiresOnSaturation(); | 327 .RetiresOnSaturation(); |
326 | 328 |
327 send_once_right.reset(); | 329 send_once_right.reset(); |
328 | 330 |
329 RunServer(); | 331 RunServer(); |
330 } | 332 } |
331 | 333 |
332 // When a receive right with a port-destroyed notification request is destroyed, | 334 // When a receive right with a port-destroyed notification request is destroyed, |
333 // a port-destroyed notification should be generated. | 335 // a port-destroyed notification should be generated. |
334 TEST_F(NotifyServerTest, MachNotifyPortDestroyed) { | 336 TEST_F(NotifyServerTest, MachNotifyPortDestroyed) { |
335 base::mac::ScopedMachReceiveRight receive_right( | 337 base::mac::ScopedMachReceiveRight receive_right( |
336 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); | 338 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
337 ASSERT_NE(kMachPortNull, receive_right); | 339 ASSERT_NE(kMachPortNull, receive_right); |
338 | 340 |
339 ASSERT_TRUE(RequestMachPortNotification( | 341 ASSERT_TRUE(RequestMachPortNotification( |
340 receive_right, MACH_NOTIFY_PORT_DESTROYED, 0)); | 342 receive_right, MACH_NOTIFY_PORT_DESTROYED, 0)); |
341 | 343 |
342 EXPECT_CALL(*this, DoMachNotifyPortDestroyed(ServerPort(), | 344 EXPECT_CALL( |
343 ResultOf(IsReceiveRight, true), | 345 *this, |
344 Ne(nullptr), | 346 DoMachNotifyPortDestroyed(ServerPort(), |
345 Pointee(Eq(false)))) | 347 ResultOf(IsReceiveRight, true), |
348 ResultOf(AuditPIDFromMachMessageTrailer, 0), | |
349 Pointee(Eq(false)))) | |
346 .WillOnce(DoAll(SetArgPointee<3>(true), Return(MIG_NO_REPLY))) | 350 .WillOnce(DoAll(SetArgPointee<3>(true), Return(MIG_NO_REPLY))) |
347 .RetiresOnSaturation(); | 351 .RetiresOnSaturation(); |
348 | 352 |
349 receive_right.reset(); | 353 receive_right.reset(); |
350 | 354 |
351 RunServer(); | 355 RunServer(); |
352 } | 356 } |
353 | 357 |
354 // When a receive right with a port-destroyed notification request is not | 358 // When a receive right with a port-destroyed notification request is not |
355 // destroyed, no port-destroyed notification should be generated. | 359 // destroyed, no port-destroyed notification should be generated. |
356 TEST_F(NotifyServerTest, MachNotifyPortDestroyed_NoNotification) { | 360 TEST_F(NotifyServerTest, MachNotifyPortDestroyed_NoNotification) { |
357 base::mac::ScopedMachReceiveRight receive_right( | 361 base::mac::ScopedMachReceiveRight receive_right( |
358 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); | 362 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
359 ASSERT_NE(kMachPortNull, receive_right); | 363 ASSERT_NE(kMachPortNull, receive_right); |
360 | 364 |
361 ASSERT_TRUE(RequestMachPortNotification( | 365 ASSERT_TRUE(RequestMachPortNotification( |
362 receive_right, MACH_NOTIFY_PORT_DESTROYED, 0)); | 366 receive_right, MACH_NOTIFY_PORT_DESTROYED, 0)); |
363 | 367 |
364 RunServer(); | 368 RunServer(); |
365 } | 369 } |
366 | 370 |
367 // When a no-senders notification request is registered for a receive right with | 371 // When a no-senders notification request is registered for a receive right with |
368 // no senders, a no-senders notification should be generated. | 372 // no senders, a no-senders notification should be generated. |
369 TEST_F(NotifyServerTest, MachNotifyNoSenders_NoSendRight) { | 373 TEST_F(NotifyServerTest, MachNotifyNoSenders_NoSendRight) { |
370 base::mac::ScopedMachReceiveRight receive_right( | 374 base::mac::ScopedMachReceiveRight receive_right( |
371 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); | 375 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
372 ASSERT_NE(kMachPortNull, receive_right); | 376 ASSERT_NE(kMachPortNull, receive_right); |
373 | 377 |
374 ASSERT_TRUE(RequestMachPortNotification( | 378 ASSERT_TRUE( |
375 receive_right, MACH_NOTIFY_NO_SENDERS, 0)); | 379 RequestMachPortNotification(receive_right, MACH_NOTIFY_NO_SENDERS, 0)); |
376 | 380 |
377 EXPECT_CALL(*this, DoMachNotifyNoSenders(ServerPort(), 0, Ne(nullptr))) | 381 EXPECT_CALL(*this, |
382 DoMachNotifyNoSenders( | |
383 ServerPort(), 0, ResultOf(AuditPIDFromMachMessageTrailer, 0))) | |
378 .WillOnce(Return(MIG_NO_REPLY)) | 384 .WillOnce(Return(MIG_NO_REPLY)) |
379 .RetiresOnSaturation(); | 385 .RetiresOnSaturation(); |
380 | 386 |
381 RunServer(); | 387 RunServer(); |
382 } | 388 } |
383 | 389 |
384 // When the last send right corresponding to a receive right with a no-senders | 390 // When the last send right corresponding to a receive right with a no-senders |
385 // notification request is deallocated, a no-senders notification should be | 391 // notification request is deallocated, a no-senders notification should be |
386 // generated. | 392 // generated. |
387 TEST_F(NotifyServerTest, MachNotifyNoSenders_SendRightDeallocated) { | 393 TEST_F(NotifyServerTest, MachNotifyNoSenders_SendRightDeallocated) { |
388 base::mac::ScopedMachReceiveRight receive_right( | 394 base::mac::ScopedMachReceiveRight receive_right( |
389 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); | 395 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
390 ASSERT_NE(kMachPortNull, receive_right); | 396 ASSERT_NE(kMachPortNull, receive_right); |
391 | 397 |
392 base::mac::ScopedMachSendRight send_right( | 398 base::mac::ScopedMachSendRight send_right( |
393 SendRightFromReceiveRight(receive_right)); | 399 SendRightFromReceiveRight(receive_right)); |
394 ASSERT_NE(kMachPortNull, send_right); | 400 ASSERT_NE(kMachPortNull, send_right); |
395 | 401 |
396 ASSERT_TRUE(RequestMachPortNotification( | 402 ASSERT_TRUE( |
397 receive_right, MACH_NOTIFY_NO_SENDERS, 1)); | 403 RequestMachPortNotification(receive_right, MACH_NOTIFY_NO_SENDERS, 1)); |
398 | 404 |
399 EXPECT_CALL(*this, DoMachNotifyNoSenders(ServerPort(), 1, Ne(nullptr))) | 405 EXPECT_CALL(*this, |
406 DoMachNotifyNoSenders( | |
407 ServerPort(), 1, ResultOf(AuditPIDFromMachMessageTrailer, 0))) | |
400 .WillOnce(Return(MIG_NO_REPLY)) | 408 .WillOnce(Return(MIG_NO_REPLY)) |
401 .RetiresOnSaturation(); | 409 .RetiresOnSaturation(); |
402 | 410 |
403 send_right.reset(); | 411 send_right.reset(); |
404 | 412 |
405 RunServer(); | 413 RunServer(); |
406 } | 414 } |
407 | 415 |
408 // When the a receive right with a no-senders notification request never loses | 416 // When the a receive right with a no-senders notification request never loses |
409 // all senders, no no-senders notification should be generated. | 417 // all senders, no no-senders notification should be generated. |
410 TEST_F(NotifyServerTest, MachNotifyNoSenders_NoNotification) { | 418 TEST_F(NotifyServerTest, MachNotifyNoSenders_NoNotification) { |
411 base::mac::ScopedMachReceiveRight receive_right( | 419 base::mac::ScopedMachReceiveRight receive_right( |
412 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); | 420 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
413 ASSERT_NE(kMachPortNull, receive_right); | 421 ASSERT_NE(kMachPortNull, receive_right); |
414 | 422 |
415 base::mac::ScopedMachSendRight send_right_0( | 423 base::mac::ScopedMachSendRight send_right_0( |
416 SendRightFromReceiveRight(receive_right)); | 424 SendRightFromReceiveRight(receive_right)); |
417 ASSERT_NE(kMachPortNull, send_right_0); | 425 ASSERT_NE(kMachPortNull, send_right_0); |
418 | 426 |
419 base::mac::ScopedMachSendRight send_right_1( | 427 base::mac::ScopedMachSendRight send_right_1( |
420 SendRightFromReceiveRight(receive_right)); | 428 SendRightFromReceiveRight(receive_right)); |
421 ASSERT_NE(kMachPortNull, send_right_1); | 429 ASSERT_NE(kMachPortNull, send_right_1); |
422 | 430 |
423 ASSERT_TRUE(RequestMachPortNotification( | 431 ASSERT_TRUE( |
424 receive_right, MACH_NOTIFY_NO_SENDERS, 1)); | 432 RequestMachPortNotification(receive_right, MACH_NOTIFY_NO_SENDERS, 1)); |
425 | 433 |
426 send_right_1.reset(); | 434 send_right_1.reset(); |
427 | 435 |
428 RunServer(); | 436 RunServer(); |
429 | 437 |
430 EXPECT_EQ(1u, RightRefCount(receive_right, MACH_PORT_RIGHT_RECEIVE)); | 438 EXPECT_EQ(1u, RightRefCount(receive_right, MACH_PORT_RIGHT_RECEIVE)); |
431 EXPECT_EQ(1u, RightRefCount(receive_right, MACH_PORT_RIGHT_SEND)); | 439 EXPECT_EQ(1u, RightRefCount(receive_right, MACH_PORT_RIGHT_SEND)); |
432 } | 440 } |
433 | 441 |
434 // When a send-once right is deallocated without being used, a send-once | 442 // When a send-once right is deallocated without being used, a send-once |
435 // notification notification should be sent via the send-once right. | 443 // notification notification should be sent via the send-once right. |
436 TEST_F(NotifyServerTest, MachNotifySendOnce_ExplicitDeallocation) { | 444 TEST_F(NotifyServerTest, MachNotifySendOnce_ExplicitDeallocation) { |
437 base::mac::ScopedMachSendRight send_once_right( | 445 base::mac::ScopedMachSendRight send_once_right( |
438 SendOnceRightFromReceiveRight(ServerPort())); | 446 SendOnceRightFromReceiveRight(ServerPort())); |
439 ASSERT_NE(kMachPortNull, send_once_right); | 447 ASSERT_NE(kMachPortNull, send_once_right); |
440 | 448 |
441 EXPECT_CALL(*this, DoMachNotifySendOnce(ServerPort(), Ne(nullptr))) | 449 EXPECT_CALL(*this, |
450 DoMachNotifySendOnce(ServerPort(), | |
451 ResultOf(AuditPIDFromMachMessageTrailer, 0))) | |
442 .WillOnce(Return(MIG_NO_REPLY)) | 452 .WillOnce(Return(MIG_NO_REPLY)) |
443 .RetiresOnSaturation(); | 453 .RetiresOnSaturation(); |
444 | 454 |
445 send_once_right.reset(); | 455 send_once_right.reset(); |
446 | 456 |
447 RunServer(); | 457 RunServer(); |
448 } | 458 } |
449 | 459 |
450 // When a send-once right is sent to a receiver that never dequeues the message, | 460 // When a send-once right is sent to a receiver that never dequeues the message, |
451 // the send-once right is destroyed, and a send-once notification should appear | 461 // the send-once right is destroyed, and a send-once notification should appear |
(...skipping 11 matching lines...) Expand all Loading... | |
463 message.header.msgh_local_port = ServerPort(); | 473 message.header.msgh_local_port = ServerPort(); |
464 mach_msg_return_t mr = mach_msg(&message.header, | 474 mach_msg_return_t mr = mach_msg(&message.header, |
465 MACH_SEND_MSG | MACH_SEND_TIMEOUT, | 475 MACH_SEND_MSG | MACH_SEND_TIMEOUT, |
466 message.header.msgh_size, | 476 message.header.msgh_size, |
467 0, | 477 0, |
468 MACH_PORT_NULL, | 478 MACH_PORT_NULL, |
469 0, | 479 0, |
470 MACH_PORT_NULL); | 480 MACH_PORT_NULL); |
471 ASSERT_EQ(MACH_MSG_SUCCESS, mr) << MachErrorMessage(mr, "mach_msg"); | 481 ASSERT_EQ(MACH_MSG_SUCCESS, mr) << MachErrorMessage(mr, "mach_msg"); |
472 | 482 |
473 EXPECT_CALL(*this, DoMachNotifySendOnce(ServerPort(), Ne(nullptr))) | 483 EXPECT_CALL(*this, |
484 DoMachNotifySendOnce(ServerPort(), | |
485 ResultOf(AuditPIDFromMachMessageTrailer, 0))) | |
474 .WillOnce(Return(MIG_NO_REPLY)) | 486 .WillOnce(Return(MIG_NO_REPLY)) |
475 .RetiresOnSaturation(); | 487 .RetiresOnSaturation(); |
476 | 488 |
477 receive_right.reset(); | 489 receive_right.reset(); |
478 | 490 |
479 RunServer(); | 491 RunServer(); |
480 } | 492 } |
481 | 493 |
482 // When the receive right corresponding to a send-once right with a dead-name | 494 // When the receive right corresponding to a send-once right with a dead-name |
483 // notification request is destroyed, a dead-name notification should be | 495 // notification request is destroyed, a dead-name notification should be |
484 // generated. | 496 // generated. |
485 TEST_F(NotifyServerTest, MachNotifyDeadName) { | 497 TEST_F(NotifyServerTest, MachNotifyDeadName) { |
486 base::mac::ScopedMachReceiveRight receive_right( | 498 base::mac::ScopedMachReceiveRight receive_right( |
487 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); | 499 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
488 ASSERT_NE(kMachPortNull, receive_right); | 500 ASSERT_NE(kMachPortNull, receive_right); |
489 | 501 |
490 base::mac::ScopedMachSendRight send_once_right( | 502 base::mac::ScopedMachSendRight send_once_right( |
491 SendOnceRightFromReceiveRight(receive_right)); | 503 SendOnceRightFromReceiveRight(receive_right)); |
492 ASSERT_NE(kMachPortNull, send_once_right); | 504 ASSERT_NE(kMachPortNull, send_once_right); |
493 | 505 |
494 ASSERT_TRUE(RequestMachPortNotification( | 506 ASSERT_TRUE( |
495 send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); | 507 RequestMachPortNotification(send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); |
496 | 508 |
497 // send_once_right becomes a dead name with the send-once right’s original | 509 // send_once_right becomes a dead name with the send-once right’s original |
498 // user reference count of 1, but the dead-name notification increments the | 510 // user reference count of 1, but the dead-name notification increments the |
499 // dead-name reference count, so it becomes 2. Take care to deallocate that | 511 // dead-name reference count, so it becomes 2. Take care to deallocate that |
500 // reference. The original reference is managed by send_once_right_owner. | 512 // reference. The original reference is managed by send_once_right_owner. |
501 EXPECT_CALL(*this, | 513 EXPECT_CALL(*this, |
502 DoMachNotifyDeadName(ServerPort(), | 514 DoMachNotifyDeadName(ServerPort(), |
503 AllOf(send_once_right.get(), | 515 AllOf(send_once_right.get(), |
504 ResultOf(DeadNameRightRefCount, 2)), | 516 ResultOf(DeadNameRightRefCount, 2)), |
505 Ne(nullptr))) | 517 ResultOf(AuditPIDFromMachMessageTrailer, 0))) |
506 .WillOnce(DoAll(WithArg<1>(Invoke(MachPortDeallocate)), | 518 .WillOnce( |
507 Return(MIG_NO_REPLY))) | 519 DoAll(WithArg<1>(Invoke(MachPortDeallocate)), Return(MIG_NO_REPLY))) |
508 .RetiresOnSaturation(); | 520 .RetiresOnSaturation(); |
509 | 521 |
510 receive_right.reset(); | 522 receive_right.reset(); |
511 | 523 |
512 RunServer(); | 524 RunServer(); |
513 | 525 |
514 EXPECT_TRUE(IsRight(send_once_right, MACH_PORT_TYPE_DEAD_NAME)); | 526 EXPECT_TRUE(IsRight(send_once_right, MACH_PORT_TYPE_DEAD_NAME)); |
515 | 527 |
516 EXPECT_EQ(0u, RightRefCount(send_once_right, MACH_PORT_RIGHT_SEND_ONCE)); | 528 EXPECT_EQ(0u, RightRefCount(send_once_right, MACH_PORT_RIGHT_SEND_ONCE)); |
517 EXPECT_EQ(1u, DeadNameRightRefCount(send_once_right)); | 529 EXPECT_EQ(1u, DeadNameRightRefCount(send_once_right)); |
518 } | 530 } |
519 | 531 |
520 // When the receive right corresponding to a send-once right with a dead-name | 532 // When the receive right corresponding to a send-once right with a dead-name |
521 // notification request is not destroyed, no dead-name notification should be | 533 // notification request is not destroyed, no dead-name notification should be |
522 // generated. | 534 // generated. |
523 TEST_F(NotifyServerTest, MachNotifyDeadName_NoNotification) { | 535 TEST_F(NotifyServerTest, MachNotifyDeadName_NoNotification) { |
524 base::mac::ScopedMachReceiveRight receive_right( | 536 base::mac::ScopedMachReceiveRight receive_right( |
525 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); | 537 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
526 ASSERT_NE(kMachPortNull, receive_right); | 538 ASSERT_NE(kMachPortNull, receive_right); |
527 | 539 |
528 base::mac::ScopedMachSendRight send_once_right( | 540 base::mac::ScopedMachSendRight send_once_right( |
529 SendOnceRightFromReceiveRight(receive_right)); | 541 SendOnceRightFromReceiveRight(receive_right)); |
530 ASSERT_NE(kMachPortNull, send_once_right); | 542 ASSERT_NE(kMachPortNull, send_once_right); |
531 | 543 |
532 ASSERT_TRUE(RequestMachPortNotification( | 544 ASSERT_TRUE( |
533 send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); | 545 RequestMachPortNotification(send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); |
534 | 546 |
535 RunServer(); | 547 RunServer(); |
536 | 548 |
537 EXPECT_FALSE(IsRight(send_once_right, MACH_PORT_TYPE_DEAD_NAME)); | 549 EXPECT_FALSE(IsRight(send_once_right, MACH_PORT_TYPE_DEAD_NAME)); |
538 | 550 |
539 EXPECT_EQ(1u, RightRefCount(send_once_right, MACH_PORT_RIGHT_SEND_ONCE)); | 551 EXPECT_EQ(1u, RightRefCount(send_once_right, MACH_PORT_RIGHT_SEND_ONCE)); |
540 EXPECT_EQ(0u, DeadNameRightRefCount(send_once_right)); | 552 EXPECT_EQ(0u, DeadNameRightRefCount(send_once_right)); |
541 } | 553 } |
542 | 554 |
543 } // namespace | 555 } // namespace |
544 } // namespace test | 556 } // namespace test |
545 } // namespace crashpad | 557 } // namespace crashpad |
OLD | NEW |