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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 391 |
392 for (size_t index = 0; | 392 for (size_t index = 0; |
393 index < options_.client_send_request_count; | 393 index < options_.client_send_request_count; |
394 ++index) { | 394 ++index) { |
395 if (options_.child_send_all_requests_before_receiving_any_replies) { | 395 if (options_.child_send_all_requests_before_receiving_any_replies) { |
396 // For this test, all of the messages need to go into the queue before | 396 // For this test, all of the messages need to go into the queue before |
397 // the parent is allowed to start processing them. Don’t attempt to | 397 // the parent is allowed to start processing them. Don’t attempt to |
398 // process replies before all of the requests are sent, because the | 398 // process replies before all of the requests are sent, because the |
399 // server won’t have sent any replies until all of the requests are in | 399 // server won’t have sent any replies until all of the requests are in |
400 // its queue. | 400 // its queue. |
401 ChildSendRequest(); | 401 ASSERT_NO_FATAL_FAILURE(ChildSendRequest()); |
402 } else { | 402 } else { |
403 ChildSendRequestAndWaitForReply(); | 403 ASSERT_NO_FATAL_FAILURE(ChildSendRequestAndWaitForReply()); |
404 } | |
405 if (testing::Test::HasFatalFailure()) { | |
406 return; | |
407 } | 404 } |
408 } | 405 } |
409 | 406 |
410 if (options_.parent_wait_for_child_pipe && | 407 if (options_.parent_wait_for_child_pipe && |
411 options_.child_send_all_requests_before_receiving_any_replies) { | 408 options_.child_send_all_requests_before_receiving_any_replies) { |
412 // Now that all of the requests have been sent, let the parent know that | 409 // Now that all of the requests have been sent, let the parent know that |
413 // it’s safe to begin processing them, and then wait for the replies. | 410 // it’s safe to begin processing them, and then wait for the replies. |
414 ChildNotifyParentViaPipe(); | 411 ASSERT_NO_FATAL_FAILURE(ChildNotifyParentViaPipe()); |
415 if (testing::Test::HasFatalFailure()) { | |
416 return; | |
417 } | |
418 | 412 |
419 for (size_t index = 0; | 413 for (size_t index = 0; |
420 index < options_.client_send_request_count; | 414 index < options_.client_send_request_count; |
421 ++index) { | 415 ++index) { |
422 ChildWaitForReply(); | 416 ASSERT_NO_FATAL_FAILURE(ChildWaitForReply()); |
423 if (testing::Test::HasFatalFailure()) { | |
424 return; | |
425 } | |
426 } | 417 } |
427 } | 418 } |
428 | 419 |
429 if (options_.child_wait_for_parent_pipe_late) { | 420 if (options_.child_wait_for_parent_pipe_late) { |
430 char c; | 421 char c; |
431 CheckedReadFD(ReadPipeFD(), &c, 1); | 422 CheckedReadFD(ReadPipeFD(), &c, 1); |
432 ASSERT_EQ('\0', c); | 423 ASSERT_EQ('\0', c); |
433 } | 424 } |
434 } | 425 } |
435 | 426 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 // The parent will be waiting in a read() on this pipe, and will proceed to | 546 // The parent will be waiting in a read() on this pipe, and will proceed to |
556 // running MachMessageServer() once it’s received. | 547 // running MachMessageServer() once it’s received. |
557 void ChildNotifyParentViaPipe() { | 548 void ChildNotifyParentViaPipe() { |
558 char c = '\0'; | 549 char c = '\0'; |
559 CheckedWriteFD(WritePipeFD(), &c, 1); | 550 CheckedWriteFD(WritePipeFD(), &c, 1); |
560 } | 551 } |
561 | 552 |
562 // In the child process, sends a request message to the server and then | 553 // In the child process, sends a request message to the server and then |
563 // receives a reply message. | 554 // receives a reply message. |
564 void ChildSendRequestAndWaitForReply() { | 555 void ChildSendRequestAndWaitForReply() { |
565 ChildSendRequest(); | 556 ASSERT_NO_FATAL_FAILURE(ChildSendRequest()); |
566 if (testing::Test::HasFatalFailure()) { | |
567 return; | |
568 } | |
569 | 557 |
570 if (options_.parent_wait_for_child_pipe && | 558 if (options_.parent_wait_for_child_pipe && |
571 !options_.child_send_all_requests_before_receiving_any_replies) { | 559 !options_.child_send_all_requests_before_receiving_any_replies) { |
572 // The parent is waiting to read a byte to indicate that the message has | 560 // The parent is waiting to read a byte to indicate that the message has |
573 // been placed in the queue. | 561 // been placed in the queue. |
574 ChildNotifyParentViaPipe(); | 562 ASSERT_NO_FATAL_FAILURE(ChildNotifyParentViaPipe()); |
575 if (testing::Test::HasFatalFailure()) { | |
576 return; | |
577 } | |
578 } | 563 } |
579 | 564 |
580 ChildWaitForReply(); | 565 ASSERT_NO_FATAL_FAILURE(ChildWaitForReply()); |
581 } | 566 } |
582 | 567 |
583 const Options& options_; | 568 const Options& options_; |
584 | 569 |
585 // A receive right allocated in the child process. A send right will be | 570 // A receive right allocated in the child process. A send right will be |
586 // created from this right and sent to the parent parent process in the | 571 // created from this right and sent to the parent parent process in the |
587 // request message. | 572 // request message. |
588 base::mac::ScopedMachReceiveRight child_complex_message_port_; | 573 base::mac::ScopedMachReceiveRight child_complex_message_port_; |
589 | 574 |
590 // The send right received in the parent process. This right is stored in a | 575 // The send right received in the parent process. This right is stored in a |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 TestMachMessageServer::Options options; | 824 TestMachMessageServer::Options options; |
840 options.server_options = MACH_RCV_LARGE; | 825 options.server_options = MACH_RCV_LARGE; |
841 options.client_send_large = true; | 826 options.client_send_large = true; |
842 TestMachMessageServer test_mach_message_server(options); | 827 TestMachMessageServer test_mach_message_server(options); |
843 test_mach_message_server.Test(); | 828 test_mach_message_server.Test(); |
844 } | 829 } |
845 | 830 |
846 } // namespace | 831 } // namespace |
847 } // namespace test | 832 } // namespace test |
848 } // namespace crashpad | 833 } // namespace crashpad |
OLD | NEW |