Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: util/mach/notify_server_test.cc

Issue 1405273002: Mach port scopers should use get() instead of type conversion operators (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: More is_valid() Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « util/mach/mach_message_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
256 //! established for the current test. On failure, returns `MACH_PORT_NULL` 256 //! established for the current test. On failure, returns `MACH_PORT_NULL`
257 //! with a gtest failure added. 257 //! with a gtest failure added.
258 mach_port_t ServerPort() { 258 mach_port_t ServerPort() {
259 if (!server_port_) { 259 if (!server_port_.is_valid()) {
260 server_port_.reset(NewMachPort(MACH_PORT_RIGHT_RECEIVE)); 260 server_port_.reset(NewMachPort(MACH_PORT_RIGHT_RECEIVE));
261 EXPECT_NE(kMachPortNull, server_port_); 261 EXPECT_TRUE(server_port_.is_valid());
262 } 262 }
263 263
264 return server_port_; 264 return server_port_.get();
265 } 265 }
266 266
267 // testing::Test: 267 // testing::Test:
268 void TearDown() override { 268 void TearDown() override {
269 server_port_.reset(); 269 server_port_.reset();
270 } 270 }
271 271
272 private: 272 private:
273 base::mac::ScopedMachReceiveRight server_port_; 273 base::mac::ScopedMachReceiveRight server_port_;
274 274
(...skipping 27 matching lines...) Expand all
302 // When no notifications are requested, nothing should happen. 302 // When no notifications are requested, nothing should happen.
303 TEST_F(NotifyServerTest, NoNotification) { 303 TEST_F(NotifyServerTest, NoNotification) {
304 RunServer(); 304 RunServer();
305 } 305 }
306 306
307 // When a send-once right with a dead-name notification request is deallocated, 307 // When a send-once right with a dead-name notification request is deallocated,
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_TRUE(receive_right.is_valid());
313 313
314 base::mac::ScopedMachSendRight send_once_right( 314 base::mac::ScopedMachSendRight send_once_right(
315 SendOnceRightFromReceiveRight(receive_right)); 315 SendOnceRightFromReceiveRight(receive_right.get()));
316 ASSERT_NE(kMachPortNull, send_once_right); 316 ASSERT_TRUE(send_once_right.is_valid());
317 317
318 ASSERT_TRUE( 318 ASSERT_TRUE(RequestMachPortNotification(
319 RequestMachPortNotification(send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); 319 send_once_right.get(), MACH_NOTIFY_DEAD_NAME, 0));
320 320
321 EXPECT_CALL( 321 EXPECT_CALL(
322 *this, 322 *this,
323 DoMachNotifyPortDeleted(ServerPort(), 323 DoMachNotifyPortDeleted(ServerPort(),
324 send_once_right.get(), 324 send_once_right.get(),
325 ResultOf(AuditPIDFromMachMessageTrailer, 0))) 325 ResultOf(AuditPIDFromMachMessageTrailer, 0)))
326 .WillOnce(Return(MIG_NO_REPLY)) 326 .WillOnce(Return(MIG_NO_REPLY))
327 .RetiresOnSaturation(); 327 .RetiresOnSaturation();
328 328
329 send_once_right.reset(); 329 send_once_right.reset();
330 330
331 RunServer(); 331 RunServer();
332 } 332 }
333 333
334 // 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,
335 // a port-destroyed notification should be generated. 335 // a port-destroyed notification should be generated.
336 TEST_F(NotifyServerTest, MachNotifyPortDestroyed) { 336 TEST_F(NotifyServerTest, MachNotifyPortDestroyed) {
337 base::mac::ScopedMachReceiveRight receive_right( 337 base::mac::ScopedMachReceiveRight receive_right(
338 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); 338 NewMachPort(MACH_PORT_RIGHT_RECEIVE));
339 ASSERT_NE(kMachPortNull, receive_right); 339 ASSERT_TRUE(receive_right.is_valid());
340 340
341 ASSERT_TRUE(RequestMachPortNotification( 341 ASSERT_TRUE(RequestMachPortNotification(
342 receive_right, MACH_NOTIFY_PORT_DESTROYED, 0)); 342 receive_right.get(), MACH_NOTIFY_PORT_DESTROYED, 0));
343 343
344 EXPECT_CALL( 344 EXPECT_CALL(
345 *this, 345 *this,
346 DoMachNotifyPortDestroyed(ServerPort(), 346 DoMachNotifyPortDestroyed(ServerPort(),
347 ResultOf(IsReceiveRight, true), 347 ResultOf(IsReceiveRight, true),
348 ResultOf(AuditPIDFromMachMessageTrailer, 0), 348 ResultOf(AuditPIDFromMachMessageTrailer, 0),
349 Pointee(Eq(false)))) 349 Pointee(Eq(false))))
350 .WillOnce(DoAll(SetArgPointee<3>(true), Return(MIG_NO_REPLY))) 350 .WillOnce(DoAll(SetArgPointee<3>(true), Return(MIG_NO_REPLY)))
351 .RetiresOnSaturation(); 351 .RetiresOnSaturation();
352 352
353 receive_right.reset(); 353 receive_right.reset();
354 354
355 RunServer(); 355 RunServer();
356 } 356 }
357 357
358 // 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
359 // destroyed, no port-destroyed notification should be generated. 359 // destroyed, no port-destroyed notification should be generated.
360 TEST_F(NotifyServerTest, MachNotifyPortDestroyed_NoNotification) { 360 TEST_F(NotifyServerTest, MachNotifyPortDestroyed_NoNotification) {
361 base::mac::ScopedMachReceiveRight receive_right( 361 base::mac::ScopedMachReceiveRight receive_right(
362 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); 362 NewMachPort(MACH_PORT_RIGHT_RECEIVE));
363 ASSERT_NE(kMachPortNull, receive_right); 363 ASSERT_TRUE(receive_right.is_valid());
364 364
365 ASSERT_TRUE(RequestMachPortNotification( 365 ASSERT_TRUE(RequestMachPortNotification(
366 receive_right, MACH_NOTIFY_PORT_DESTROYED, 0)); 366 receive_right.get(), MACH_NOTIFY_PORT_DESTROYED, 0));
367 367
368 RunServer(); 368 RunServer();
369 } 369 }
370 370
371 // 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
372 // no senders, a no-senders notification should be generated. 372 // no senders, a no-senders notification should be generated.
373 TEST_F(NotifyServerTest, MachNotifyNoSenders_NoSendRight) { 373 TEST_F(NotifyServerTest, MachNotifyNoSenders_NoSendRight) {
374 base::mac::ScopedMachReceiveRight receive_right( 374 base::mac::ScopedMachReceiveRight receive_right(
375 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); 375 NewMachPort(MACH_PORT_RIGHT_RECEIVE));
376 ASSERT_NE(kMachPortNull, receive_right); 376 ASSERT_TRUE(receive_right.is_valid());
377 377
378 ASSERT_TRUE( 378 ASSERT_TRUE(RequestMachPortNotification(
379 RequestMachPortNotification(receive_right, MACH_NOTIFY_NO_SENDERS, 0)); 379 receive_right.get(), MACH_NOTIFY_NO_SENDERS, 0));
380 380
381 EXPECT_CALL(*this, 381 EXPECT_CALL(*this,
382 DoMachNotifyNoSenders( 382 DoMachNotifyNoSenders(
383 ServerPort(), 0, ResultOf(AuditPIDFromMachMessageTrailer, 0))) 383 ServerPort(), 0, ResultOf(AuditPIDFromMachMessageTrailer, 0)))
384 .WillOnce(Return(MIG_NO_REPLY)) 384 .WillOnce(Return(MIG_NO_REPLY))
385 .RetiresOnSaturation(); 385 .RetiresOnSaturation();
386 386
387 RunServer(); 387 RunServer();
388 } 388 }
389 389
390 // 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
391 // notification request is deallocated, a no-senders notification should be 391 // notification request is deallocated, a no-senders notification should be
392 // generated. 392 // generated.
393 TEST_F(NotifyServerTest, MachNotifyNoSenders_SendRightDeallocated) { 393 TEST_F(NotifyServerTest, MachNotifyNoSenders_SendRightDeallocated) {
394 base::mac::ScopedMachReceiveRight receive_right( 394 base::mac::ScopedMachReceiveRight receive_right(
395 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); 395 NewMachPort(MACH_PORT_RIGHT_RECEIVE));
396 ASSERT_NE(kMachPortNull, receive_right); 396 ASSERT_TRUE(receive_right.is_valid());
397 397
398 base::mac::ScopedMachSendRight send_right( 398 base::mac::ScopedMachSendRight send_right(
399 SendRightFromReceiveRight(receive_right)); 399 SendRightFromReceiveRight(receive_right.get()));
400 ASSERT_NE(kMachPortNull, send_right); 400 ASSERT_TRUE(send_right.is_valid());
401 401
402 ASSERT_TRUE( 402 ASSERT_TRUE(RequestMachPortNotification(
403 RequestMachPortNotification(receive_right, MACH_NOTIFY_NO_SENDERS, 1)); 403 receive_right.get(), MACH_NOTIFY_NO_SENDERS, 1));
404 404
405 EXPECT_CALL(*this, 405 EXPECT_CALL(*this,
406 DoMachNotifyNoSenders( 406 DoMachNotifyNoSenders(
407 ServerPort(), 1, ResultOf(AuditPIDFromMachMessageTrailer, 0))) 407 ServerPort(), 1, ResultOf(AuditPIDFromMachMessageTrailer, 0)))
408 .WillOnce(Return(MIG_NO_REPLY)) 408 .WillOnce(Return(MIG_NO_REPLY))
409 .RetiresOnSaturation(); 409 .RetiresOnSaturation();
410 410
411 send_right.reset(); 411 send_right.reset();
412 412
413 RunServer(); 413 RunServer();
414 } 414 }
415 415
416 // 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
417 // all senders, no no-senders notification should be generated. 417 // all senders, no no-senders notification should be generated.
418 TEST_F(NotifyServerTest, MachNotifyNoSenders_NoNotification) { 418 TEST_F(NotifyServerTest, MachNotifyNoSenders_NoNotification) {
419 base::mac::ScopedMachReceiveRight receive_right( 419 base::mac::ScopedMachReceiveRight receive_right(
420 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); 420 NewMachPort(MACH_PORT_RIGHT_RECEIVE));
421 ASSERT_NE(kMachPortNull, receive_right); 421 ASSERT_TRUE(receive_right.is_valid());
422 422
423 base::mac::ScopedMachSendRight send_right_0( 423 base::mac::ScopedMachSendRight send_right_0(
424 SendRightFromReceiveRight(receive_right)); 424 SendRightFromReceiveRight(receive_right.get()));
425 ASSERT_NE(kMachPortNull, send_right_0); 425 ASSERT_TRUE(send_right_0.is_valid());
426 426
427 base::mac::ScopedMachSendRight send_right_1( 427 base::mac::ScopedMachSendRight send_right_1(
428 SendRightFromReceiveRight(receive_right)); 428 SendRightFromReceiveRight(receive_right.get()));
429 ASSERT_NE(kMachPortNull, send_right_1); 429 ASSERT_TRUE(send_right_1.is_valid());
430 430
431 ASSERT_TRUE( 431 ASSERT_TRUE(RequestMachPortNotification(
432 RequestMachPortNotification(receive_right, MACH_NOTIFY_NO_SENDERS, 1)); 432 receive_right.get(), MACH_NOTIFY_NO_SENDERS, 1));
433 433
434 send_right_1.reset(); 434 send_right_1.reset();
435 435
436 RunServer(); 436 RunServer();
437 437
438 EXPECT_EQ(1u, RightRefCount(receive_right, MACH_PORT_RIGHT_RECEIVE)); 438 EXPECT_EQ(1u, RightRefCount(receive_right.get(), MACH_PORT_RIGHT_RECEIVE));
439 EXPECT_EQ(1u, RightRefCount(receive_right, MACH_PORT_RIGHT_SEND)); 439 EXPECT_EQ(1u, RightRefCount(receive_right.get(), MACH_PORT_RIGHT_SEND));
440 } 440 }
441 441
442 // 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
443 // notification notification should be sent via the send-once right. 443 // notification notification should be sent via the send-once right.
444 TEST_F(NotifyServerTest, MachNotifySendOnce_ExplicitDeallocation) { 444 TEST_F(NotifyServerTest, MachNotifySendOnce_ExplicitDeallocation) {
445 base::mac::ScopedMachSendRight send_once_right( 445 base::mac::ScopedMachSendRight send_once_right(
446 SendOnceRightFromReceiveRight(ServerPort())); 446 SendOnceRightFromReceiveRight(ServerPort()));
447 ASSERT_NE(kMachPortNull, send_once_right); 447 ASSERT_TRUE(send_once_right.is_valid());
448 448
449 EXPECT_CALL(*this, 449 EXPECT_CALL(*this,
450 DoMachNotifySendOnce(ServerPort(), 450 DoMachNotifySendOnce(ServerPort(),
451 ResultOf(AuditPIDFromMachMessageTrailer, 0))) 451 ResultOf(AuditPIDFromMachMessageTrailer, 0)))
452 .WillOnce(Return(MIG_NO_REPLY)) 452 .WillOnce(Return(MIG_NO_REPLY))
453 .RetiresOnSaturation(); 453 .RetiresOnSaturation();
454 454
455 send_once_right.reset(); 455 send_once_right.reset();
456 456
457 RunServer(); 457 RunServer();
458 } 458 }
459 459
460 // 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,
461 // 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
462 // on the reply port. 462 // on the reply port.
463 TEST_F(NotifyServerTest, MachNotifySendOnce_ImplicitDeallocation) { 463 TEST_F(NotifyServerTest, MachNotifySendOnce_ImplicitDeallocation) {
464 base::mac::ScopedMachReceiveRight receive_right( 464 base::mac::ScopedMachReceiveRight receive_right(
465 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); 465 NewMachPort(MACH_PORT_RIGHT_RECEIVE));
466 ASSERT_NE(kMachPortNull, receive_right); 466 ASSERT_TRUE(receive_right.is_valid());
467 467
468 mach_msg_empty_send_t message = {}; 468 mach_msg_empty_send_t message = {};
469 message.header.msgh_bits = 469 message.header.msgh_bits =
470 MACH_MSGH_BITS(MACH_MSG_TYPE_MAKE_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE); 470 MACH_MSGH_BITS(MACH_MSG_TYPE_MAKE_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE);
471 message.header.msgh_size = sizeof(message); 471 message.header.msgh_size = sizeof(message);
472 message.header.msgh_remote_port = receive_right; 472 message.header.msgh_remote_port = receive_right.get();
473 message.header.msgh_local_port = ServerPort(); 473 message.header.msgh_local_port = ServerPort();
474 mach_msg_return_t mr = mach_msg(&message.header, 474 mach_msg_return_t mr = mach_msg(&message.header,
475 MACH_SEND_MSG | MACH_SEND_TIMEOUT, 475 MACH_SEND_MSG | MACH_SEND_TIMEOUT,
476 message.header.msgh_size, 476 message.header.msgh_size,
477 0, 477 0,
478 MACH_PORT_NULL, 478 MACH_PORT_NULL,
479 0, 479 0,
480 MACH_PORT_NULL); 480 MACH_PORT_NULL);
481 ASSERT_EQ(MACH_MSG_SUCCESS, mr) << MachErrorMessage(mr, "mach_msg"); 481 ASSERT_EQ(MACH_MSG_SUCCESS, mr) << MachErrorMessage(mr, "mach_msg");
482 482
483 EXPECT_CALL(*this, 483 EXPECT_CALL(*this,
484 DoMachNotifySendOnce(ServerPort(), 484 DoMachNotifySendOnce(ServerPort(),
485 ResultOf(AuditPIDFromMachMessageTrailer, 0))) 485 ResultOf(AuditPIDFromMachMessageTrailer, 0)))
486 .WillOnce(Return(MIG_NO_REPLY)) 486 .WillOnce(Return(MIG_NO_REPLY))
487 .RetiresOnSaturation(); 487 .RetiresOnSaturation();
488 488
489 receive_right.reset(); 489 receive_right.reset();
490 490
491 RunServer(); 491 RunServer();
492 } 492 }
493 493
494 // 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
495 // notification request is destroyed, a dead-name notification should be 495 // notification request is destroyed, a dead-name notification should be
496 // generated. 496 // generated.
497 TEST_F(NotifyServerTest, MachNotifyDeadName) { 497 TEST_F(NotifyServerTest, MachNotifyDeadName) {
498 base::mac::ScopedMachReceiveRight receive_right( 498 base::mac::ScopedMachReceiveRight receive_right(
499 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); 499 NewMachPort(MACH_PORT_RIGHT_RECEIVE));
500 ASSERT_NE(kMachPortNull, receive_right); 500 ASSERT_TRUE(receive_right.is_valid());
501 501
502 base::mac::ScopedMachSendRight send_once_right( 502 base::mac::ScopedMachSendRight send_once_right(
503 SendOnceRightFromReceiveRight(receive_right)); 503 SendOnceRightFromReceiveRight(receive_right.get()));
504 ASSERT_NE(kMachPortNull, send_once_right); 504 ASSERT_TRUE(send_once_right.is_valid());
505 505
506 ASSERT_TRUE( 506 ASSERT_TRUE(RequestMachPortNotification(
507 RequestMachPortNotification(send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); 507 send_once_right.get(), MACH_NOTIFY_DEAD_NAME, 0));
508 508
509 // 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
510 // 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
511 // 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
512 // reference. The original reference is managed by send_once_right_owner. 512 // reference. The original reference is managed by send_once_right_owner.
513 EXPECT_CALL(*this, 513 EXPECT_CALL(*this,
514 DoMachNotifyDeadName(ServerPort(), 514 DoMachNotifyDeadName(ServerPort(),
515 AllOf(send_once_right.get(), 515 AllOf(send_once_right.get(),
516 ResultOf(DeadNameRightRefCount, 2)), 516 ResultOf(DeadNameRightRefCount, 2)),
517 ResultOf(AuditPIDFromMachMessageTrailer, 0))) 517 ResultOf(AuditPIDFromMachMessageTrailer, 0)))
518 .WillOnce( 518 .WillOnce(
519 DoAll(WithArg<1>(Invoke(MachPortDeallocate)), Return(MIG_NO_REPLY))) 519 DoAll(WithArg<1>(Invoke(MachPortDeallocate)), Return(MIG_NO_REPLY)))
520 .RetiresOnSaturation(); 520 .RetiresOnSaturation();
521 521
522 receive_right.reset(); 522 receive_right.reset();
523 523
524 RunServer(); 524 RunServer();
525 525
526 EXPECT_TRUE(IsRight(send_once_right, MACH_PORT_TYPE_DEAD_NAME)); 526 EXPECT_TRUE(IsRight(send_once_right.get(), MACH_PORT_TYPE_DEAD_NAME));
527 527
528 EXPECT_EQ(0u, RightRefCount(send_once_right, MACH_PORT_RIGHT_SEND_ONCE)); 528 EXPECT_EQ(0u,
529 EXPECT_EQ(1u, DeadNameRightRefCount(send_once_right)); 529 RightRefCount(send_once_right.get(), MACH_PORT_RIGHT_SEND_ONCE));
530 EXPECT_EQ(1u, DeadNameRightRefCount(send_once_right.get()));
530 } 531 }
531 532
532 // When the receive right corresponding to a send-once right with a dead-name 533 // When the receive right corresponding to a send-once right with a dead-name
533 // notification request is not destroyed, no dead-name notification should be 534 // notification request is not destroyed, no dead-name notification should be
534 // generated. 535 // generated.
535 TEST_F(NotifyServerTest, MachNotifyDeadName_NoNotification) { 536 TEST_F(NotifyServerTest, MachNotifyDeadName_NoNotification) {
536 base::mac::ScopedMachReceiveRight receive_right( 537 base::mac::ScopedMachReceiveRight receive_right(
537 NewMachPort(MACH_PORT_RIGHT_RECEIVE)); 538 NewMachPort(MACH_PORT_RIGHT_RECEIVE));
538 ASSERT_NE(kMachPortNull, receive_right); 539 ASSERT_TRUE(receive_right.is_valid());
539 540
540 base::mac::ScopedMachSendRight send_once_right( 541 base::mac::ScopedMachSendRight send_once_right(
541 SendOnceRightFromReceiveRight(receive_right)); 542 SendOnceRightFromReceiveRight(receive_right.get()));
542 ASSERT_NE(kMachPortNull, send_once_right); 543 ASSERT_TRUE(send_once_right.is_valid());
543 544
544 ASSERT_TRUE( 545 ASSERT_TRUE(RequestMachPortNotification(
545 RequestMachPortNotification(send_once_right, MACH_NOTIFY_DEAD_NAME, 0)); 546 send_once_right.get(), MACH_NOTIFY_DEAD_NAME, 0));
546 547
547 RunServer(); 548 RunServer();
548 549
549 EXPECT_FALSE(IsRight(send_once_right, MACH_PORT_TYPE_DEAD_NAME)); 550 EXPECT_FALSE(IsRight(send_once_right.get(), MACH_PORT_TYPE_DEAD_NAME));
550 551
551 EXPECT_EQ(1u, RightRefCount(send_once_right, MACH_PORT_RIGHT_SEND_ONCE)); 552 EXPECT_EQ(1u,
552 EXPECT_EQ(0u, DeadNameRightRefCount(send_once_right)); 553 RightRefCount(send_once_right.get(), MACH_PORT_RIGHT_SEND_ONCE));
554 EXPECT_EQ(0u, DeadNameRightRefCount(send_once_right.get()));
553 } 555 }
554 556
555 } // namespace 557 } // namespace
556 } // namespace test 558 } // namespace test
557 } // namespace crashpad 559 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/mach/mach_message_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698