OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 h) { | 765 h) { |
766 for (;;) { | 766 for (;;) { |
767 std::string message = ReadMessage(h); | 767 std::string message = ReadMessage(h); |
768 if (message == "exit") | 768 if (message == "exit") |
769 break; | 769 break; |
770 WriteMessage(h, message); | 770 WriteMessage(h, message); |
771 } | 771 } |
772 return 0; | 772 return 0; |
773 } | 773 } |
774 | 774 |
775 TEST_F(MultiprocessMessagePipeTest, MultiprocessChannelPipe) { | 775 #if defined(OS_ANDROID) |
| 776 // Android multi-process tests are not executing the new process. This is flaky. |
| 777 #define MAYBE_MultiprocessChannelPipe DISABLED_MultiprocessChannelPipe |
| 778 #else |
| 779 #define MAYBE_MultiprocessChannelPipe MultiprocessChannelPipe |
| 780 #endif |
| 781 TEST_F(MultiprocessMessagePipeTest, MAYBE_MultiprocessChannelPipe) { |
776 RUN_CHILD_ON_PIPE(ChannelEchoClient, h) | 782 RUN_CHILD_ON_PIPE(ChannelEchoClient, h) |
777 VerifyEcho(h, "in an interstellar burst"); | 783 VerifyEcho(h, "in an interstellar burst"); |
778 VerifyEcho(h, "i am back to save the universe"); | 784 VerifyEcho(h, "i am back to save the universe"); |
779 VerifyEcho(h, std::string(10 * 1024 * 1024, 'o')); | 785 VerifyEcho(h, std::string(10 * 1024 * 1024, 'o')); |
780 | 786 |
781 WriteMessage(h, "exit"); | 787 WriteMessage(h, "exit"); |
782 END_CHILD() | 788 END_CHILD() |
783 } | 789 } |
784 | 790 |
785 // Receives a pipe handle from the primordial channel and echos on it until | 791 // Receives a pipe handle from the primordial channel and echos on it until |
786 // "exit". Used to test simple pipe transfer across processes via channels. | 792 // "exit". Used to test simple pipe transfer across processes via channels. |
787 DEFINE_TEST_CLIENT_WITH_PIPE(EchoServiceClient, MultiprocessMessagePipeTest, | 793 DEFINE_TEST_CLIENT_WITH_PIPE(EchoServiceClient, MultiprocessMessagePipeTest, |
788 h) { | 794 h) { |
789 MojoHandle p; | 795 MojoHandle p; |
790 ReadMessageWithHandles(h, &p, 1); | 796 ReadMessageWithHandles(h, &p, 1); |
791 for (;;) { | 797 for (;;) { |
792 std::string message = ReadMessage(p); | 798 std::string message = ReadMessage(p); |
793 if (message == "exit") | 799 if (message == "exit") |
794 break; | 800 break; |
795 WriteMessage(p, message); | 801 WriteMessage(p, message); |
796 } | 802 } |
797 return 0; | 803 return 0; |
798 } | 804 } |
799 | 805 |
800 TEST_F(MultiprocessMessagePipeTest, PassMessagePipeCrossProcess) { | 806 #if defined(OS_ANDROID) |
| 807 // Android multi-process tests are not executing the new process. This is flaky. |
| 808 #define MAYBE_PassMessagePipeCrossProcess DISABLED_PassMessagePipeCrossProcess |
| 809 #else |
| 810 #define MAYBE_PassMessagePipeCrossProcess PassMessagePipeCrossProcess |
| 811 #endif |
| 812 TEST_F(MultiprocessMessagePipeTest, MAYBE_PassMessagePipeCrossProcess) { |
801 MojoHandle p0, p1; | 813 MojoHandle p0, p1; |
802 CreateMessagePipe(&p0, &p1); | 814 CreateMessagePipe(&p0, &p1); |
803 RUN_CHILD_ON_PIPE(EchoServiceClient, h) | 815 RUN_CHILD_ON_PIPE(EchoServiceClient, h) |
804 | 816 |
805 // Pass one end of the pipe to the other process. | 817 // Pass one end of the pipe to the other process. |
806 WriteMessageWithHandles(h, "here take this", &p1, 1); | 818 WriteMessageWithHandles(h, "here take this", &p1, 1); |
807 | 819 |
808 VerifyEcho(p0, "and you may ask yourself"); | 820 VerifyEcho(p0, "and you may ask yourself"); |
809 VerifyEcho(p0, "where does that highway go?"); | 821 VerifyEcho(p0, "where does that highway go?"); |
810 VerifyEcho(p0, std::string(20 * 1024 * 1024, 'i')); | 822 VerifyEcho(p0, std::string(20 * 1024 * 1024, 'i')); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 WriteMessage(handles[index], ReadMessage(handles[index])); | 859 WriteMessage(handles[index], ReadMessage(handles[index])); |
848 } | 860 } |
849 } | 861 } |
850 | 862 |
851 for (size_t i = 1; i < handles.size(); ++i) | 863 for (size_t i = 1; i < handles.size(); ++i) |
852 CloseHandle(handles[i]); | 864 CloseHandle(handles[i]); |
853 | 865 |
854 return 0; | 866 return 0; |
855 } | 867 } |
856 | 868 |
857 TEST_F(MultiprocessMessagePipeTest, PassMoarMessagePipesCrossProcess) { | 869 #if defined(OS_ANDROID) |
| 870 // Android multi-process tests are not executing the new process. This is flaky. |
| 871 #define MAYBE_PassMoarMessagePipesCrossProcess \ |
| 872 DISABLED_PassMoarMessagePipesCrossProcess |
| 873 #else |
| 874 #define MAYBE_PassMoarMessagePipesCrossProcess PassMoarMessagePipesCrossProcess |
| 875 #endif |
| 876 TEST_F(MultiprocessMessagePipeTest, MAYBE_PassMoarMessagePipesCrossProcess) { |
858 MojoHandle echo_factory_proxy, echo_factory_request; | 877 MojoHandle echo_factory_proxy, echo_factory_request; |
859 CreateMessagePipe(&echo_factory_proxy, &echo_factory_request); | 878 CreateMessagePipe(&echo_factory_proxy, &echo_factory_request); |
860 | 879 |
861 MojoHandle echo_proxy_a, echo_request_a; | 880 MojoHandle echo_proxy_a, echo_request_a; |
862 CreateMessagePipe(&echo_proxy_a, &echo_request_a); | 881 CreateMessagePipe(&echo_proxy_a, &echo_request_a); |
863 | 882 |
864 MojoHandle echo_proxy_b, echo_request_b; | 883 MojoHandle echo_proxy_b, echo_request_b; |
865 CreateMessagePipe(&echo_proxy_b, &echo_request_b); | 884 CreateMessagePipe(&echo_proxy_b, &echo_request_b); |
866 | 885 |
867 MojoHandle echo_proxy_c, echo_request_c; | 886 MojoHandle echo_proxy_c, echo_request_c; |
(...skipping 24 matching lines...) Expand all Loading... |
892 | 911 |
893 WriteMessage(h, "exit"); | 912 WriteMessage(h, "exit"); |
894 END_CHILD() | 913 END_CHILD() |
895 | 914 |
896 CloseHandle(echo_factory_proxy); | 915 CloseHandle(echo_factory_proxy); |
897 CloseHandle(echo_proxy_a); | 916 CloseHandle(echo_proxy_a); |
898 CloseHandle(echo_proxy_b); | 917 CloseHandle(echo_proxy_b); |
899 CloseHandle(echo_proxy_c); | 918 CloseHandle(echo_proxy_c); |
900 } | 919 } |
901 | 920 |
902 TEST_F(MultiprocessMessagePipeTest, ChannelPipesWithMultipleChildren) { | 921 #if defined(OS_ANDROID) |
| 922 // Android multi-process tests are not executing the new process. This is flaky. |
| 923 #define MAYBE_ChannelPipesWithMultipleChildren \ |
| 924 DISABLED_ChannelPipesWithMultipleChildren |
| 925 #else |
| 926 #define MAYBE_ChannelPipesWithMultipleChildren ChannelPipesWithMultipleChildren |
| 927 #endif |
| 928 TEST_F(MultiprocessMessagePipeTest, MAYBE_ChannelPipesWithMultipleChildren) { |
903 RUN_CHILD_ON_PIPE(ChannelEchoClient, a) | 929 RUN_CHILD_ON_PIPE(ChannelEchoClient, a) |
904 RUN_CHILD_ON_PIPE(ChannelEchoClient, b) | 930 RUN_CHILD_ON_PIPE(ChannelEchoClient, b) |
905 VerifyEcho(a, "hello child 0"); | 931 VerifyEcho(a, "hello child 0"); |
906 VerifyEcho(b, "hello child 1"); | 932 VerifyEcho(b, "hello child 1"); |
907 | 933 |
908 WriteMessage(a, "exit"); | 934 WriteMessage(a, "exit"); |
909 WriteMessage(b, "exit"); | 935 WriteMessage(b, "exit"); |
910 END_CHILD() | 936 END_CHILD() |
911 END_CHILD() | 937 END_CHILD() |
912 } | 938 } |
913 | 939 |
914 // Reads and turns a pipe handle some number of times to create lots of | 940 // Reads and turns a pipe handle some number of times to create lots of |
915 // transient proxies. | 941 // transient proxies. |
916 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(PingPongPipeClient, | 942 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(PingPongPipeClient, |
917 MultiprocessMessagePipeTest, h) { | 943 MultiprocessMessagePipeTest, h) { |
918 const size_t kNumBounces = 50; | 944 const size_t kNumBounces = 50; |
919 MojoHandle p0, p1; | 945 MojoHandle p0, p1; |
920 ReadMessageWithHandles(h, &p0, 1); | 946 ReadMessageWithHandles(h, &p0, 1); |
921 ReadMessageWithHandles(h, &p1, 1); | 947 ReadMessageWithHandles(h, &p1, 1); |
922 for (size_t i = 0; i < kNumBounces; ++i) { | 948 for (size_t i = 0; i < kNumBounces; ++i) { |
923 WriteMessageWithHandles(h, "", &p1, 1); | 949 WriteMessageWithHandles(h, "", &p1, 1); |
924 ReadMessageWithHandles(h, &p1, 1); | 950 ReadMessageWithHandles(h, &p1, 1); |
925 } | 951 } |
926 WriteMessageWithHandles(h, "", &p0, 1); | 952 WriteMessageWithHandles(h, "", &p0, 1); |
927 WriteMessage(p1, "bye"); | 953 WriteMessage(p1, "bye"); |
928 MojoClose(p1); | 954 MojoClose(p1); |
929 EXPECT_EQ("quit", ReadMessage(h)); | 955 EXPECT_EQ("quit", ReadMessage(h)); |
930 } | 956 } |
931 | 957 |
932 TEST_F(MultiprocessMessagePipeTest, PingPongPipe) { | 958 #if defined(OS_ANDROID) |
| 959 // Android multi-process tests are not executing the new process. This is flaky. |
| 960 #define MAYBE_PingPongPipe DISABLED_PingPongPipe |
| 961 #else |
| 962 #define MAYBE_PingPongPipe PingPongPipe |
| 963 #endif |
| 964 TEST_F(MultiprocessMessagePipeTest, MAYBE_PingPongPipe) { |
933 MojoHandle p0, p1; | 965 MojoHandle p0, p1; |
934 CreateMessagePipe(&p0, &p1); | 966 CreateMessagePipe(&p0, &p1); |
935 | 967 |
936 RUN_CHILD_ON_PIPE(PingPongPipeClient, h) | 968 RUN_CHILD_ON_PIPE(PingPongPipeClient, h) |
937 const size_t kNumBounces = 50; | 969 const size_t kNumBounces = 50; |
938 WriteMessageWithHandles(h, "", &p0, 1); | 970 WriteMessageWithHandles(h, "", &p0, 1); |
939 WriteMessageWithHandles(h, "", &p1, 1); | 971 WriteMessageWithHandles(h, "", &p1, 1); |
940 for (size_t i = 0; i < kNumBounces; ++i) { | 972 for (size_t i = 0; i < kNumBounces; ++i) { |
941 ReadMessageWithHandles(h, &p1, 1); | 973 ReadMessageWithHandles(h, &p1, 1); |
942 WriteMessageWithHandles(h, "", &p1, 1); | 974 WriteMessageWithHandles(h, "", &p1, 1); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 break; | 1053 break; |
1022 } | 1054 } |
1023 } | 1055 } |
1024 | 1056 |
1025 for (auto& pipe: named_pipes) | 1057 for (auto& pipe: named_pipes) |
1026 CloseHandle(pipe.second); | 1058 CloseHandle(pipe.second); |
1027 | 1059 |
1028 return 0; | 1060 return 0; |
1029 } | 1061 } |
1030 | 1062 |
1031 TEST_F(MultiprocessMessagePipeTest, ChildToChildPipes) { | 1063 #if defined(OS_ANDROID) |
| 1064 // Android multi-process tests are not executing the new process. This is flaky. |
| 1065 #define MAYBE_ChildToChildPipes DISABLED_ChildToChildPipes |
| 1066 #else |
| 1067 #define MAYBE_ChildToChildPipes ChildToChildPipes |
| 1068 #endif |
| 1069 TEST_F(MultiprocessMessagePipeTest, MAYBE_ChildToChildPipes) { |
1032 RUN_CHILD_ON_PIPE(CommandDrivenClient, h0) | 1070 RUN_CHILD_ON_PIPE(CommandDrivenClient, h0) |
1033 RUN_CHILD_ON_PIPE(CommandDrivenClient, h1) | 1071 RUN_CHILD_ON_PIPE(CommandDrivenClient, h1) |
1034 CommandDrivenClientController a(h0); | 1072 CommandDrivenClientController a(h0); |
1035 CommandDrivenClientController b(h1); | 1073 CommandDrivenClientController b(h1); |
1036 | 1074 |
1037 // Create a pipe and pass each end to a different client. | 1075 // Create a pipe and pass each end to a different client. |
1038 MojoHandle p0, p1; | 1076 MojoHandle p0, p1; |
1039 CreateMessagePipe(&p0, &p1); | 1077 CreateMessagePipe(&p0, &p1); |
1040 a.SendHandle("x", p0); | 1078 a.SendHandle("x", p0); |
1041 b.SendHandle("y", p1); | 1079 b.SendHandle("y", p1); |
1042 | 1080 |
1043 // Make sure they can talk. | 1081 // Make sure they can talk. |
1044 a.Send("say:x:hello sir"); | 1082 a.Send("say:x:hello sir"); |
1045 b.Send("hear:y:hello sir"); | 1083 b.Send("hear:y:hello sir"); |
1046 | 1084 |
1047 b.Send("say:y:i love multiprocess pipes!"); | 1085 b.Send("say:y:i love multiprocess pipes!"); |
1048 a.Send("hear:x:i love multiprocess pipes!"); | 1086 a.Send("hear:x:i love multiprocess pipes!"); |
1049 | 1087 |
1050 a.Exit(); | 1088 a.Exit(); |
1051 b.Exit(); | 1089 b.Exit(); |
1052 END_CHILD() | 1090 END_CHILD() |
1053 END_CHILD() | 1091 END_CHILD() |
1054 } | 1092 } |
1055 | 1093 |
1056 TEST_F(MultiprocessMessagePipeTest, MoreChildToChildPipes) { | 1094 #if defined(OS_ANDROID) |
| 1095 // Android multi-process tests are not executing the new process. This is flaky. |
| 1096 #define MAYBE_MoreChildToChildPipes DISABLED_MoreChildToChildPipes |
| 1097 #else |
| 1098 #define MAYBE_MoreChildToChildPipes MoreChildToChildPipes |
| 1099 #endif |
| 1100 TEST_F(MultiprocessMessagePipeTest, MAYBE_MoreChildToChildPipes) { |
1057 RUN_CHILD_ON_PIPE(CommandDrivenClient, h0) | 1101 RUN_CHILD_ON_PIPE(CommandDrivenClient, h0) |
1058 RUN_CHILD_ON_PIPE(CommandDrivenClient, h1) | 1102 RUN_CHILD_ON_PIPE(CommandDrivenClient, h1) |
1059 RUN_CHILD_ON_PIPE(CommandDrivenClient, h2) | 1103 RUN_CHILD_ON_PIPE(CommandDrivenClient, h2) |
1060 RUN_CHILD_ON_PIPE(CommandDrivenClient, h3) | 1104 RUN_CHILD_ON_PIPE(CommandDrivenClient, h3) |
1061 CommandDrivenClientController a(h0), b(h1), c(h2), d(h3); | 1105 CommandDrivenClientController a(h0), b(h1), c(h2), d(h3); |
1062 | 1106 |
1063 // Connect a to b and c to d | 1107 // Connect a to b and c to d |
1064 | 1108 |
1065 MojoHandle p0, p1; | 1109 MojoHandle p0, p1; |
1066 | 1110 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 | 1176 |
1133 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(ReceivePipeWithClosedPeer, | 1177 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(ReceivePipeWithClosedPeer, |
1134 MultiprocessMessagePipeTest, h) { | 1178 MultiprocessMessagePipeTest, h) { |
1135 MojoHandle p; | 1179 MojoHandle p; |
1136 EXPECT_EQ("foo", ReadMessageWithHandles(h, &p, 1)); | 1180 EXPECT_EQ("foo", ReadMessageWithHandles(h, &p, 1)); |
1137 | 1181 |
1138 EXPECT_EQ(MOJO_RESULT_OK, MojoWait(p, MOJO_HANDLE_SIGNAL_PEER_CLOSED, | 1182 EXPECT_EQ(MOJO_RESULT_OK, MojoWait(p, MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
1139 MOJO_DEADLINE_INDEFINITE, nullptr)); | 1183 MOJO_DEADLINE_INDEFINITE, nullptr)); |
1140 } | 1184 } |
1141 | 1185 |
1142 TEST_F(MultiprocessMessagePipeTest, SendPipeThenClosePeer) { | 1186 #if defined(OS_ANDROID) |
| 1187 // Android multi-process tests are not executing the new process. This is flaky. |
| 1188 #define MAYBE_SendPipeThenClosePeer DISABLED_SendPipeThenClosePeer |
| 1189 #else |
| 1190 #define MAYBE_SendPipeThenClosePeer SendPipeThenClosePeer |
| 1191 #endif |
| 1192 TEST_F(MultiprocessMessagePipeTest, MAYBE_SendPipeThenClosePeer) { |
1143 RUN_CHILD_ON_PIPE(ReceivePipeWithClosedPeer, h) | 1193 RUN_CHILD_ON_PIPE(ReceivePipeWithClosedPeer, h) |
1144 MojoHandle a, b; | 1194 MojoHandle a, b; |
1145 CreateMessagePipe(&a, &b); | 1195 CreateMessagePipe(&a, &b); |
1146 | 1196 |
1147 // Send |a| and immediately close |b|. The child should observe closure. | 1197 // Send |a| and immediately close |b|. The child should observe closure. |
1148 WriteMessageWithHandles(h, "foo", &a, 1); | 1198 WriteMessageWithHandles(h, "foo", &a, 1); |
1149 MojoClose(b); | 1199 MojoClose(b); |
1150 END_CHILD() | 1200 END_CHILD() |
1151 } | 1201 } |
1152 | 1202 |
(...skipping 30 matching lines...) Expand all Loading... |
1183 | 1233 |
1184 // Wait for the service client to signal closure. | 1234 // Wait for the service client to signal closure. |
1185 EXPECT_EQ(MOJO_RESULT_OK, MojoWait(service_client, | 1235 EXPECT_EQ(MOJO_RESULT_OK, MojoWait(service_client, |
1186 MOJO_HANDLE_SIGNAL_PEER_CLOSED, | 1236 MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
1187 MOJO_DEADLINE_INDEFINITE, nullptr)); | 1237 MOJO_DEADLINE_INDEFINITE, nullptr)); |
1188 | 1238 |
1189 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(service_client)); | 1239 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(service_client)); |
1190 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(application_client)); | 1240 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(application_client)); |
1191 } | 1241 } |
1192 | 1242 |
1193 TEST_F(MultiprocessMessagePipeTest, SendPipeWithClosedPeerBetweenChildren) { | 1243 #if defined(OS_ANDROID) |
| 1244 // Android multi-process tests are not executing the new process. This is flaky. |
| 1245 #define MAYBE_SendPipeWithClosedPeerBetweenChildren \ |
| 1246 DISABLED_SendPipeWithClosedPeerBetweenChildren |
| 1247 #else |
| 1248 #define MAYBE_SendPipeWithClosedPeerBetweenChildren \ |
| 1249 SendPipeWithClosedPeerBetweenChildren |
| 1250 #endif |
| 1251 TEST_F(MultiprocessMessagePipeTest, |
| 1252 MAYBE_SendPipeWithClosedPeerBetweenChildren) { |
1194 RUN_CHILD_ON_PIPE(SendOtherChildPipeWithClosedPeer, kid_a) | 1253 RUN_CHILD_ON_PIPE(SendOtherChildPipeWithClosedPeer, kid_a) |
1195 RUN_CHILD_ON_PIPE(ReceivePipeWithClosedPeerFromOtherChild, kid_b) | 1254 RUN_CHILD_ON_PIPE(ReceivePipeWithClosedPeerFromOtherChild, kid_b) |
1196 // Receive an "application request" from the first child and forward it | 1255 // Receive an "application request" from the first child and forward it |
1197 // to the second child. | 1256 // to the second child. |
1198 MojoHandle application_request; | 1257 MojoHandle application_request; |
1199 EXPECT_EQ("c2a plz", | 1258 EXPECT_EQ("c2a plz", |
1200 ReadMessageWithHandles(kid_a, &application_request, 1)); | 1259 ReadMessageWithHandles(kid_a, &application_request, 1)); |
1201 | 1260 |
1202 WriteMessageWithHandles(kid_b, "c2a", &application_request, 1); | 1261 WriteMessageWithHandles(kid_b, "c2a", &application_request, 1); |
1203 END_CHILD() | 1262 END_CHILD() |
1204 | 1263 |
1205 WriteMessage(kid_a, "quit"); | 1264 WriteMessage(kid_a, "quit"); |
1206 END_CHILD() | 1265 END_CHILD() |
1207 } | 1266 } |
1208 | 1267 |
1209 TEST_F(MultiprocessMessagePipeTest, SendClosePeerSend) { | 1268 |
| 1269 #if defined(OS_ANDROID) |
| 1270 // Android multi-process tests are not executing the new process. This is flaky. |
| 1271 #define MAYBE_SendClosePeerSend DISABLED_SendClosePeerSend |
| 1272 #else |
| 1273 #define MAYBE_SendClosePeerSend SendClosePeerSend |
| 1274 #endif |
| 1275 TEST_F(MultiprocessMessagePipeTest, MAYBE_SendClosePeerSend) { |
1210 MojoHandle a, b; | 1276 MojoHandle a, b; |
1211 CreateMessagePipe(&a, &b); | 1277 CreateMessagePipe(&a, &b); |
1212 | 1278 |
1213 MojoHandle c, d; | 1279 MojoHandle c, d; |
1214 CreateMessagePipe(&c, &d); | 1280 CreateMessagePipe(&c, &d); |
1215 | 1281 |
1216 // Send |a| over |c|, immediately close |b|, then send |a| back over |d|. | 1282 // Send |a| over |c|, immediately close |b|, then send |a| back over |d|. |
1217 WriteMessageWithHandles(c, "foo", &a, 1); | 1283 WriteMessageWithHandles(c, "foo", &a, 1); |
1218 EXPECT_EQ("foo", ReadMessageWithHandles(d, &a, 1)); | 1284 EXPECT_EQ("foo", ReadMessageWithHandles(d, &a, 1)); |
1219 WriteMessageWithHandles(d, "bar", &a, 1); | 1285 WriteMessageWithHandles(d, "bar", &a, 1); |
(...skipping 22 matching lines...) Expand all Loading... |
1242 // the parent, just for some extra proxying goodness. | 1308 // the parent, just for some extra proxying goodness. |
1243 WriteMessageWithHandles(c, "foo", &pipe[1], 1); | 1309 WriteMessageWithHandles(c, "foo", &pipe[1], 1); |
1244 EXPECT_EQ("foo", ReadMessageWithHandles(d, &pipe[1], 1)); | 1310 EXPECT_EQ("foo", ReadMessageWithHandles(d, &pipe[1], 1)); |
1245 | 1311 |
1246 // And finally pass it back to the parent. | 1312 // And finally pass it back to the parent. |
1247 WriteMessageWithHandles(h, "bar", &pipe[1], 1); | 1313 WriteMessageWithHandles(h, "bar", &pipe[1], 1); |
1248 | 1314 |
1249 EXPECT_EQ("quit", ReadMessage(h)); | 1315 EXPECT_EQ("quit", ReadMessage(h)); |
1250 } | 1316 } |
1251 | 1317 |
1252 TEST_F(MultiprocessMessagePipeTest, WriteCloseSendPeer) { | 1318 #if defined(OS_ANDROID) |
| 1319 // Android multi-process tests are not executing the new process. This is flaky. |
| 1320 #define MAYBE_WriteCloseSendPeer DISABLED_WriteCloseSendPeer |
| 1321 #else |
| 1322 #define MAYBE_WriteCloseSendPeer WriteCloseSendPeer |
| 1323 #endif |
| 1324 TEST_F(MultiprocessMessagePipeTest, MAYBE_WriteCloseSendPeer) { |
1253 MojoHandle pipe[2]; | 1325 MojoHandle pipe[2]; |
1254 CreateMessagePipe(&pipe[0], &pipe[1]); | 1326 CreateMessagePipe(&pipe[0], &pipe[1]); |
1255 | 1327 |
1256 RUN_CHILD_ON_PIPE(WriteCloseSendPeerClient, h) | 1328 RUN_CHILD_ON_PIPE(WriteCloseSendPeerClient, h) |
1257 // Pass the pipe to the child. | 1329 // Pass the pipe to the child. |
1258 WriteMessageWithHandles(h, "foo", pipe, 2); | 1330 WriteMessageWithHandles(h, "foo", pipe, 2); |
1259 | 1331 |
1260 // Read back an endpoint which should have messages on it. | 1332 // Read back an endpoint which should have messages on it. |
1261 MojoHandle p; | 1333 MojoHandle p; |
1262 EXPECT_EQ("bar", ReadMessageWithHandles(h, &p, 1)); | 1334 EXPECT_EQ("bar", ReadMessageWithHandles(h, &p, 1)); |
(...skipping 19 matching lines...) Expand all Loading... |
1282 edk::PassWrappedPlatformHandle(channel_handle, &channel)); | 1354 edk::PassWrappedPlatformHandle(channel_handle, &channel)); |
1283 ASSERT_TRUE(channel.is_valid()); | 1355 ASSERT_TRUE(channel.is_valid()); |
1284 | 1356 |
1285 // Create a new pipe using our end of the channel. | 1357 // Create a new pipe using our end of the channel. |
1286 ScopedMessagePipeHandle pipe = edk::CreateMessagePipe(std::move(channel)); | 1358 ScopedMessagePipeHandle pipe = edk::CreateMessagePipe(std::move(channel)); |
1287 | 1359 |
1288 // Ensure that we can read and write on the new pipe. | 1360 // Ensure that we can read and write on the new pipe. |
1289 VerifyEcho(pipe.get().value(), "goodbye"); | 1361 VerifyEcho(pipe.get().value(), "goodbye"); |
1290 } | 1362 } |
1291 | 1363 |
1292 TEST_F(MultiprocessMessagePipeTest, BootstrapMessagePipeAsync) { | 1364 #if defined(OS_ANDROID) |
| 1365 // Android multi-process tests are not executing the new process. This is flaky. |
| 1366 #define MAYBE_BootstrapMessagePipeAsync DISABLED_BootstrapMessagePipeAsync |
| 1367 #else |
| 1368 #define MAYBE_BootstrapMessagePipeAsync BootstrapMessagePipeAsync |
| 1369 #endif |
| 1370 TEST_F(MultiprocessMessagePipeTest, MAYBE_BootstrapMessagePipeAsync) { |
1293 // Tests that new cross-process message pipes can be created synchronously | 1371 // Tests that new cross-process message pipes can be created synchronously |
1294 // using asynchronous negotiation over an arbitrary platform channel. | 1372 // using asynchronous negotiation over an arbitrary platform channel. |
1295 RUN_CHILD_ON_PIPE(BootstrapMessagePipeAsyncClient, child) | 1373 RUN_CHILD_ON_PIPE(BootstrapMessagePipeAsyncClient, child) |
1296 // Pass one end of a platform channel to the child. | 1374 // Pass one end of a platform channel to the child. |
1297 PlatformChannelPair platform_channel; | 1375 PlatformChannelPair platform_channel; |
1298 MojoHandle client_channel_handle; | 1376 MojoHandle client_channel_handle; |
1299 EXPECT_EQ(MOJO_RESULT_OK, | 1377 EXPECT_EQ(MOJO_RESULT_OK, |
1300 CreatePlatformHandleWrapper(platform_channel.PassClientHandle(), | 1378 CreatePlatformHandleWrapper(platform_channel.PassClientHandle(), |
1301 &client_channel_handle)); | 1379 &client_channel_handle)); |
1302 WriteMessageWithHandles(child, "hi", &client_channel_handle, 1); | 1380 WriteMessageWithHandles(child, "hi", &client_channel_handle, 1); |
1303 | 1381 |
1304 // Create a new pipe using our end of the channel. | 1382 // Create a new pipe using our end of the channel. |
1305 ScopedMessagePipeHandle pipe = | 1383 ScopedMessagePipeHandle pipe = |
1306 edk::CreateMessagePipe(platform_channel.PassServerHandle()); | 1384 edk::CreateMessagePipe(platform_channel.PassServerHandle()); |
1307 | 1385 |
1308 // Ensure that we can read and write on the new pipe. | 1386 // Ensure that we can read and write on the new pipe. |
1309 VerifyEcho(pipe.get().value(), "goodbye"); | 1387 VerifyEcho(pipe.get().value(), "goodbye"); |
1310 END_CHILD() | 1388 END_CHILD() |
1311 } | 1389 } |
1312 | 1390 |
1313 } // namespace | 1391 } // namespace |
1314 } // namespace edk | 1392 } // namespace edk |
1315 } // namespace mojo | 1393 } // namespace mojo |
OLD | NEW |