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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 | 716 |
717 TEST(MachMessageServer, Complex) { | 717 TEST(MachMessageServer, Complex) { |
718 // The client allocates a new receive right and sends a complex request | 718 // The client allocates a new receive right and sends a complex request |
719 // message to the server with a send right made out of this receive right. The | 719 // message to the server with a send right made out of this receive right. The |
720 // server receives this message and is instructed to destroy the send right | 720 // server receives this message and is instructed to destroy the send right |
721 // when it is done handling the request-reply transaction. The former send | 721 // when it is done handling the request-reply transaction. The former send |
722 // right is verified to be invalid after the server runs. This test ensures | 722 // right is verified to be invalid after the server runs. This test ensures |
723 // that resources transferred to a server process temporarily aren’t leaked. | 723 // that resources transferred to a server process temporarily aren’t leaked. |
724 TestMachMessageServer::Options options; | 724 TestMachMessageServer::Options options; |
725 options.client_send_complex = true; | 725 options.client_send_complex = true; |
726 options.child_wait_for_parent_pipe = true; | |
727 TestMachMessageServer test_mach_message_server(options); | 726 TestMachMessageServer test_mach_message_server(options); |
728 test_mach_message_server.Test(); | 727 test_mach_message_server.Test(); |
729 } | 728 } |
730 | 729 |
731 TEST(MachMessageServer, ComplexNotDestroyed) { | 730 TEST(MachMessageServer, ComplexNotDestroyed) { |
732 // As in MachMessageServer.Complex, but the server is instructed not to | 731 // As in MachMessageServer.Complex, but the server is instructed not to |
733 // destroy the send right. After the server runs, the send right is verified | 732 // destroy the send right. After the server runs, the send right is verified |
734 // to continue to exist in the server task. The client process is then | 733 // to continue to exist in the server task. The client process is then |
735 // signalled by pipe that it’s safe to exit so that the send right in the | 734 // signalled by pipe that it’s safe to exit so that the send right in the |
736 // server task doesn’t prematurely become a dead name. This test ensures that | 735 // server task doesn’t prematurely become a dead name. This test ensures that |
737 // rights that are expected to be retained in the server task are properly | 736 // rights that are expected to be retained in the server task are properly |
738 // retained. | 737 // retained. |
739 TestMachMessageServer::Options options; | 738 TestMachMessageServer::Options options; |
740 options.server_destroy_complex = false; | 739 options.server_destroy_complex = false; |
741 options.expect_server_destroyed_complex = false; | 740 options.expect_server_destroyed_complex = false; |
742 options.client_send_complex = true; | 741 options.client_send_complex = true; |
743 options.child_wait_for_parent_pipe = true; | |
744 TestMachMessageServer test_mach_message_server(options); | 742 TestMachMessageServer test_mach_message_server(options); |
745 test_mach_message_server.Test(); | 743 test_mach_message_server.Test(); |
746 } | 744 } |
747 | 745 |
748 TEST(MachMessageServer, ComplexDestroyedInvalidArgument) { | 746 TEST(MachMessageServer, ComplexDestroyedInvalidArgument) { |
749 // As in MachMessageServer.ComplexNotDestroyed, but the server does not return | 747 // As in MachMessageServer.ComplexNotDestroyed, but the server does not return |
750 // a successful code via MIG. The server is expected to destroy resources in | 748 // a successful code via MIG. The server is expected to destroy resources in |
751 // this case, because server_destroy_complex = false is only honored when a | 749 // this case, because server_destroy_complex = false is only honored when a |
752 // MIG request is handled successfully or with no reply. | 750 // MIG request is handled successfully or with no reply. |
753 TestMachMessageServer::Options options; | 751 TestMachMessageServer::Options options; |
754 options.server_mig_retcode = KERN_INVALID_TASK; | 752 options.server_mig_retcode = KERN_INVALID_TASK; |
755 options.server_destroy_complex = false; | 753 options.server_destroy_complex = false; |
756 options.client_send_complex = true; | 754 options.client_send_complex = true; |
757 options.child_wait_for_parent_pipe = true; | |
758 TestMachMessageServer test_mach_message_server(options); | 755 TestMachMessageServer test_mach_message_server(options); |
759 test_mach_message_server.Test(); | 756 test_mach_message_server.Test(); |
760 } | 757 } |
761 | 758 |
762 TEST(MachMessageServer, ComplexNotDestroyedNoReply) { | 759 TEST(MachMessageServer, ComplexNotDestroyedNoReply) { |
763 // As in MachMessageServer.ComplexNotDestroyed, but the server does not send | 760 // As in MachMessageServer.ComplexNotDestroyed, but the server does not send |
764 // a reply message and is expected to retain the send right in the server | 761 // a reply message and is expected to retain the send right in the server |
765 // task. | 762 // task. |
766 TestMachMessageServer::Options options; | 763 TestMachMessageServer::Options options; |
767 options.server_mig_retcode = MIG_NO_REPLY; | 764 options.server_mig_retcode = MIG_NO_REPLY; |
(...skipping 26 matching lines...) Expand all Loading... |
794 // so a new buffer is allocated to receive the message. The server receives | 791 // so a new buffer is allocated to receive the message. The server receives |
795 // the large request message, processes it, and returns a reply to the client. | 792 // the large request message, processes it, and returns a reply to the client. |
796 TestMachMessageServer::Options options; | 793 TestMachMessageServer::Options options; |
797 options.server_options = MACH_RCV_LARGE; | 794 options.server_options = MACH_RCV_LARGE; |
798 options.client_send_large = true; | 795 options.client_send_large = true; |
799 TestMachMessageServer test_mach_message_server(options); | 796 TestMachMessageServer test_mach_message_server(options); |
800 test_mach_message_server.Test(); | 797 test_mach_message_server.Test(); |
801 } | 798 } |
802 | 799 |
803 } // namespace | 800 } // namespace |
OLD | NEW |