Branch data Line data Source code
1 : : /* Copyright 2006-2011 Savarese Software Research Corporation
2 : : *
3 : : * Licensed under the Apache License, Version 2.0 (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
6 : : *
7 : : * http://www.savarese.com/software/ApacheLicense-2.0
8 : : *
9 : : * Unless required by applicable law or agreed to in writing, software
10 : : * distributed under the License is distributed on an "AS IS" BASIS,
11 : : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : : * See the License for the specific language governing permissions and
13 : : * limitations under the License.
14 : : */
15 : :
16 : : #include <ssrc/wisp/utility/TimeValue.h>
17 : : #include <ssrc/wisp/protocol/Caller.h>
18 : :
19 : : #define BOOST_TEST_MODULE CallerTest
20 : : #include <boost/test/unit_test.hpp>
21 : :
22 : : using namespace NS_SSRC_WISP;
23 : : using namespace NS_SSRC_WISP_PROTOCOL;
24 : : using NS_SSRC_WISP_UTILITY::TimeValue;
25 : : using ssrc::spread::Message;
26 : :
27 : : #define MBOX WISP_SPREAD_DAEMON
28 : :
29 : : enum ProtocolNumber { ProtoTest = 1776 };
30 : :
31 : 38 : WISP_DEFINE_PROTOCOL(ProtoTest);
32 : :
33 : : struct InitTest {
34 : 1 : InitTest() {
35 : 1 : std::srand(TimeValue::now_seconds());
36 : 1 : }
37 : : };
38 : :
39 : 1 : BOOST_GLOBAL_FIXTURE(InitTest);
40 : :
41 : : struct TestProtocol : public ServiceProtocol<ProtoTest> {
42 : : enum MessageType {
43 : : Stop, EchoRequest, EchoReply, SendString, RequestBigPacket, ReturnBigPacket
44 : : };
45 : :
46 : : typedef MessageProtoTest<Stop> MessageStop;
47 : : typedef MessageProtoTest<EchoRequest> MessageEchoRequest;
48 : : typedef MessageProtoTest<EchoReply> MessageEchoReply;
49 : :
50 : 10 : WISP_PROTOCOL_MESSAGE(SendString, MessageProtoTest, ((std::string, str)));
51 : :
52 : : typedef MessageProtoTest<RequestBigPacket> MessageRequestBigPacket;
53 : :
54 : 42 : WISP_PROTOCOL_MESSAGE_WITH_INIT(ReturnBigPacket, MessageProtoTest,
55 : : ((ByteBuffer, payload)),
56 : : (ByteBuffer(0)));
57 : :
58 : : WISP_ONE_WAY_CALL(caller_type, Stop);
59 : : WISP_ONE_WAY_CALL(caller_type, EchoReply);
60 : : WISP_TWO_WAY_CALL(caller_type, EchoRequest, EchoReply);
61 : : WISP_ONE_WAY_CALL(caller_type, SendString);
62 : : WISP_ONE_WAY_CALL(caller_type, ReturnBigPacket);
63 : : WISP_TWO_WAY_CALL(caller_type, RequestBigPacket, ReturnBigPacket);
64 : : };
65 : :
66 : : // We have commented out this value and replaced it with Mesage::DefaultCapacity
67 : : // to ensure we exercise the Caller::send message buffer auto-resizing feature
68 : : // (see WISP-11 for more information).
69 : : //const unsigned int JumboCapacity = 1048832;
70 : : const unsigned int JumboCapacity = Message::DefaultCapacity;
71 : : const unsigned int JumboPayloadSize = 1048576;
72 : :
73 : : WISP_IMPORT(TestProtocol, MessageStop);
74 : : WISP_IMPORT(TestProtocol, MessageEchoRequest);
75 : : WISP_IMPORT(TestProtocol, MessageEchoReply);
76 : : WISP_IMPORT(TestProtocol, MessageSendString);
77 : : WISP_IMPORT(TestProtocol, CallStop);
78 : : WISP_IMPORT(TestProtocol, CallEchoRequest);
79 : : WISP_IMPORT(TestProtocol, CallEchoReply);
80 : : WISP_IMPORT(TestProtocol, CallSendString);
81 : :
82 : : WISP_IMPORT(TestProtocol, MessageReturnBigPacket);
83 : : WISP_IMPORT(TestProtocol, CallRequestBigPacket);
84 : : WISP_IMPORT(TestProtocol, CallReturnBigPacket);
85 : :
86 [ + - + - : 3 : BOOST_AUTO_TEST_CASE(test_receive) {
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - ]
87 [ + - + - : 2 : Caller<> call(MBOX, "", Message::DefaultCapacity, true);
+ - ]
88 : :
89 : : CallEchoRequest::future_ptr future_echo =
90 [ + - ]: 2 : call(CallEchoRequest(), call.name(), Message::Safe);
91 : :
92 : 2 : message_info_ptr info;
93 [ + - ]: 1 : call.receive(info);
94 : :
95 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageEchoRequest::id);
+ - + - +
- + - -
+ ]
96 [ + - + - : 1 : BOOST_REQUIRE(info->role() == TwoWayRequest);
+ - + - +
- + - -
+ ]
97 [ + - + - : 1 : BOOST_REQUIRE(info->token() == future_echo->token());
+ - + - +
- + - -
+ ]
98 : :
99 [ + - ]: 1 : call(CallEchoReply(), call.name(), future_echo->token(), Message::Safe);
100 : :
101 [ + - ]: 1 : call.receive(info);
102 : :
103 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageEchoReply::id);
+ - + - +
- + - -
+ ]
104 [ + - + - : 1 : BOOST_REQUIRE(info->role() == TwoWayResponse);
+ - + - +
- + - -
+ ]
105 [ + - + - : 1 : BOOST_REQUIRE(info->token() == future_echo->token());
+ - + - +
- + - -
+ ]
106 : :
107 : : MessageEchoReply msg_reply;
108 [ + - + - : 1 : BOOST_REQUIRE_NO_THROW(future_echo->unpack(msg_reply, *info));
+ - + - +
- + - + -
- + - + #
# # # # #
# # # # #
# # # #
# ]
109 [ + - + - : 1 : BOOST_REQUIRE(!future_echo->valid());
+ - + - +
- + - -
+ ]
110 : 1 : }
111 : :
112 [ + - + - : 3 : BOOST_AUTO_TEST_CASE(test_future) {
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - ]
113 [ + - + - : 2 : Caller<> call(MBOX, "", Message::DefaultCapacity, true);
+ - ]
114 : :
115 : : CallEchoRequest::future_ptr future_echo1 =
116 [ + - ]: 2 : call(CallEchoRequest(), call.name(), Message::Safe);
117 [ + - ]: 1 : call(CallEchoReply(), call.name(), future_echo1->token(), Message::Safe);
118 : :
119 [ + - ]: 1 : call(CallStop(), call.name(), Message::Safe);
120 : :
121 : : CallEchoRequest::future_ptr future_echo3 =
122 [ + - ]: 2 : call(CallEchoRequest(), call.name(), Message::Safe);
123 : :
124 [ + - ]: 1 : call(CallStop(), call.name(), Message::Safe);
125 : :
126 [ + - ]: 1 : call.send<CallSendString>(Message::Safe, call.name(), "bar");
127 [ + - ]: 1 : call.send<CallSendString>(Message::Safe, call.name(), "foo");
128 : :
129 [ + - + - ]: 1 : call.join("foo");
130 : :
131 [ + - ]: 1 : call(CallEchoReply(), call.name(), future_echo3->token(), Message::Safe);
132 : :
133 : 2 : message_info_ptr info;
134 [ + - ]: 1 : call.receive_request(info);
135 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageEchoRequest::id);
+ - + - +
- + - -
+ ]
136 [ + - ]: 1 : call.receive_request(info);
137 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageStop::id);
+ - + - +
- + - -
+ ]
138 : :
139 [ + - ]: 1 : call(CallStop(), call.name(), Message::Safe);
140 : :
141 : : CallEchoRequest::future_ptr future_echo2 =
142 [ + - ]: 2 : call(CallEchoRequest(), call.name(), Message::Safe);
143 : :
144 [ + - + - ]: 1 : call.leave("foo");
145 : :
146 [ + - ]: 1 : call(CallEchoReply(), call.name(), future_echo2->token(), Message::Safe);
147 : :
148 [ + - + - : 1 : BOOST_REQUIRE(!future_echo2->ready());
+ - + - +
- + - + -
- + ]
149 [ + - + - : 1 : BOOST_REQUIRE(future_echo2->valid());
+ - + - +
- + - -
+ ]
150 : :
151 : : MessageEchoReply msg_reply;
152 [ + - + - : 1 : BOOST_REQUIRE_NO_THROW(future_echo1->receive(msg_reply));
+ - + - +
- + - + -
- + - + #
# # # # #
# # # # #
# # # #
# ]
153 [ + - + - : 1 : BOOST_REQUIRE(!future_echo1->valid());
+ - + - +
- + - -
+ ]
154 : :
155 [ + - + - : 1 : BOOST_REQUIRE_NO_THROW(future_echo2->receive(msg_reply));
+ - + - +
- + - + -
- + - + #
# # # # #
# # # # #
# # # #
# ]
156 [ + - + - : 1 : BOOST_REQUIRE(!future_echo2->valid());
+ - + - +
- + - -
+ ]
157 : :
158 [ + - ]: 1 : call.receive_request(info);
159 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageEchoRequest::id);
+ - + - +
- + - -
+ ]
160 : :
161 [ + - ]: 1 : call.receive_request(info);
162 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageStop::id);
+ - + - +
- + - -
+ ]
163 : :
164 : 2 : MessageSendString msg_send_str;
165 [ + - ]: 1 : call.receive_request(info);
166 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageSendString::id);
+ - + - +
- + - -
+ ]
167 [ + - ]: 1 : call.unpack(msg_send_str, *info);
168 [ + - + - : 1 : BOOST_REQUIRE("bar" == msg_send_str.str);
+ - + - +
- + - + -
- + ]
169 : :
170 [ + - + - : 1 : BOOST_REQUIRE(future_echo3->ready());
+ - + - +
- + - + -
- + ]
171 [ + - + - : 1 : BOOST_REQUIRE(future_echo3->valid());
+ - + - +
- + - -
+ ]
172 [ + - + - : 1 : BOOST_REQUIRE_NO_THROW(future_echo3->receive(msg_reply));
+ - + - +
- + - + -
- + - + #
# # # # #
# # # # #
# # # #
# ]
173 [ + - + - : 1 : BOOST_REQUIRE(!future_echo3->valid());
+ - + - +
- + - -
+ ]
174 : :
175 [ + - ]: 1 : call.receive_request(info);
176 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageSendString::id);
+ - + - +
- + - -
+ ]
177 [ + - ]: 1 : call.unpack(msg_send_str, *info);
178 [ + - + - : 1 : BOOST_REQUIRE("foo" == msg_send_str.str);
+ - + - +
- + - + -
- + ]
179 : :
180 [ + - ]: 1 : call.receive_request(info);
181 [ + - + - : 1 : BOOST_REQUIRE(info->message.is_membership());
+ - + - +
- + - -
+ ]
182 : :
183 [ + - ]: 1 : call.receive_request(info);
184 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageStop::id);
+ - + - +
- + - -
+ ]
185 : :
186 [ + - ]: 1 : call.receive_request(info);
187 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageEchoRequest::id);
+ - + - +
- + - -
+ ]
188 : :
189 [ + - ]: 1 : call.receive_request(info);
190 [ + - + - : 1 : BOOST_REQUIRE(info->message.is_membership());
+ - + - +
- + - -
+ ]
191 : 1 : }
192 : :
193 [ + - + - : 3 : BOOST_AUTO_TEST_CASE(test_receive_jumbo_response) {
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - ]
194 [ + - + - : 2 : Caller<> call(MBOX, "", JumboCapacity, true);
+ - ]
195 : :
196 : : CallRequestBigPacket::future_ptr future_packet =
197 [ + - ]: 2 : call(CallRequestBigPacket(), call.name(), Message::Safe);
198 : :
199 : : CallEchoRequest::future_ptr future_echo =
200 [ + - ]: 2 : call(CallEchoRequest(), call.name(), Message::Safe);
201 : :
202 : 2 : message_info_ptr info;
203 [ + - ]: 1 : call.receive(info);
204 : :
205 [ + - + - : 1 : BOOST_REQUIRE(info->id() == CallRequestBigPacket::parameter_type::id);
+ - + - +
- + - -
+ ]
206 [ + - + - : 1 : BOOST_REQUIRE(info->role() == TwoWayRequest);
+ - + - +
- + - -
+ ]
207 [ + - + - : 1 : BOOST_REQUIRE(info->token() == future_packet->token());
+ - + - +
- + - -
+ ]
208 : :
209 [ + - + - ]: 2 : MessageReturnBigPacket packet_msg;
210 : :
211 [ + - ]: 1 : packet_msg.payload.resize(JumboPayloadSize);
212 [ + + ]: 524289 : while(packet_msg.payload.offset() < JumboPayloadSize) {
213 : 262144 : int bytes = std::rand();
214 [ + - ]: 262144 : packet_msg.payload.write(&bytes, sizeof(bytes));
215 : : }
216 : :
217 : 1 : call.reply<CallReturnBigPacket>(info->sender(), info->token(), packet_msg,
218 [ + - ]: 1 : Message::Safe);
219 [ + - ]: 1 : call.receive(info);
220 : :
221 [ + - + - : 1 : BOOST_CHECK_GT(call.message_capacity_send(), call.message_capacity_initial());
+ - + - +
- - + ]
222 : :
223 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageEchoRequest::id);
+ - + - +
- + - -
+ ]
224 [ + - + - : 1 : BOOST_REQUIRE(info->role() == TwoWayRequest);
+ - + - +
- + - -
+ ]
225 [ + - + - : 1 : BOOST_REQUIRE(info->token() == future_echo->token());
+ - + - +
- + - -
+ ]
226 : :
227 [ + - ]: 1 : call(CallEchoReply(), call.name(), info->token(), Message::Safe);
228 : 1 : info.reset();
229 : :
230 : : MessageEchoReply echo_reply;
231 [ + - + - : 1 : BOOST_REQUIRE_NO_THROW(future_echo->receive(echo_reply));
+ - + - +
- + - + -
- + - + #
# # # # #
# # # # #
# # # #
# ]
232 [ + - + - : 1 : BOOST_REQUIRE(!future_echo->valid());
+ - + - +
- + - -
+ ]
233 : :
234 [ + - + - ]: 2 : MessageReturnBigPacket packet_reply;
235 : :
236 [ + - + - : 1 : BOOST_REQUIRE_NO_THROW(future_packet->receive(packet_reply));
+ - + - +
- + - + -
- + - + #
# # # # #
# # # # #
# # # #
# ]
237 [ + - + - : 1 : BOOST_REQUIRE(!future_packet->valid());
+ - + - +
- + - -
+ ]
238 : :
239 [ + - + - : 1 : BOOST_REQUIRE_EQUAL(packet_reply.payload.size(), packet_msg.payload.size());
+ - + - +
- - + ]
240 [ + - + - : 1 : BOOST_REQUIRE_EQUAL(std::memcmp(&packet_msg.payload[0],
+ - + - +
- - + ]
241 : : &packet_reply.payload[0],
242 : : packet_msg.payload.size()), 0);
243 : 1 : }
244 : :
245 [ + - + - : 3 : BOOST_AUTO_TEST_CASE(test_receive_jumbo_request) {
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - ]
246 [ + - + - : 2 : Caller<> call(MBOX, "", JumboCapacity, true);
+ - ]
247 : :
248 : : CallEchoRequest::future_ptr future_echo =
249 [ + - ]: 2 : call(CallEchoRequest(), call.name(), Message::Safe);
250 : :
251 [ + - + - ]: 2 : MessageReturnBigPacket packet_msg;
252 : :
253 [ + - ]: 1 : packet_msg.payload.resize(JumboPayloadSize);
254 [ + + ]: 524289 : while(packet_msg.payload.offset() < JumboPayloadSize) {
255 : 262144 : int bytes = std::rand();
256 [ + - ]: 262144 : packet_msg.payload.write(&bytes, sizeof(bytes));
257 : : }
258 : :
259 [ + - ]: 1 : call.send<CallReturnBigPacket>(call.name(), packet_msg, Message::Safe);
260 : :
261 : 2 : message_info_ptr info;
262 [ + - ]: 1 : call.receive_request(info);
263 : :
264 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageEchoRequest::id);
+ - + - +
- + - -
+ ]
265 [ + - + - : 1 : BOOST_REQUIRE(info->role() == TwoWayRequest);
+ - + - +
- + - -
+ ]
266 [ + - + - : 1 : BOOST_REQUIRE(info->token() == future_echo->token());
+ - + - +
- + - -
+ ]
267 : :
268 [ + - ]: 1 : call(CallEchoReply(), call.name(), info->token(), Message::Safe);
269 : 1 : info.reset();
270 : :
271 : : MessageEchoReply echo_reply;
272 [ + - + - : 1 : BOOST_REQUIRE_NO_THROW(future_echo->receive(echo_reply));
+ - + - +
- + - + -
- + - + #
# # # # #
# # # # #
# # # #
# ]
273 [ + - + - : 1 : BOOST_REQUIRE(!future_echo->valid());
+ - + - +
- + - -
+ ]
274 : :
275 [ + - ]: 1 : call.receive_request(info);
276 : :
277 [ + - + - : 1 : BOOST_REQUIRE(info->header.message_size > packet_msg.payload.size());
+ - + - +
- + - -
+ ]
278 : :
279 : : const unsigned int header_size =
280 : 1 : info->header.message_size - packet_msg.payload.size();
281 : :
282 [ + - + - : 1 : BOOST_REQUIRE_EQUAL(std::memcmp(&packet_msg.payload[0],
+ - + - +
- - + ]
283 : : &info->message[header_size],
284 : : packet_msg.payload.size()), 0);
285 : 1 : }
286 : :
287 [ + - + - : 3 : BOOST_AUTO_TEST_CASE(test_receive_jumbo) {
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - ]
288 [ + - + - : 2 : Caller<> call(MBOX, "", JumboCapacity, true);
+ - ]
289 : :
290 : : CallEchoRequest::future_ptr future_echo =
291 [ + - ]: 2 : call(CallEchoRequest(), call.name(), Message::Safe);
292 : :
293 [ + - + - ]: 2 : MessageReturnBigPacket packet_msg;
294 : :
295 [ + - ]: 1 : packet_msg.payload.resize(JumboPayloadSize);
296 [ + + ]: 524289 : while(packet_msg.payload.offset() < JumboPayloadSize) {
297 : 262144 : int bytes = std::rand();
298 [ + - ]: 262144 : packet_msg.payload.write(&bytes, sizeof(bytes));
299 : : }
300 : :
301 [ + - ]: 1 : call.send<CallReturnBigPacket>(call.name(), packet_msg, Message::Safe);
302 : :
303 : 2 : message_info_ptr info;
304 [ + - ]: 1 : call.receive(info);
305 : :
306 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageEchoRequest::id);
+ - + - +
- + - -
+ ]
307 [ + - + - : 1 : BOOST_REQUIRE(info->role() == TwoWayRequest);
+ - + - +
- + - -
+ ]
308 [ + - + - : 1 : BOOST_REQUIRE(info->token() == future_echo->token());
+ - + - +
- + - -
+ ]
309 : :
310 [ + - ]: 1 : call(CallEchoReply(), call.name(), info->token(), Message::Safe);
311 : :
312 : : MessageEchoReply echo_reply;
313 [ + - + - : 1 : BOOST_REQUIRE_NO_THROW(future_echo->receive(echo_reply));
+ - + - +
- + - + -
- + - + #
# # # # #
# # # # #
# # # #
# ]
314 [ + - + - : 1 : BOOST_REQUIRE(!future_echo->valid());
+ - + - +
- + - -
+ ]
315 : :
316 [ + - ]: 1 : call.receive(info);
317 : :
318 [ + - + - : 1 : BOOST_REQUIRE(info->header.message_size > packet_msg.payload.size());
+ - + - +
- + - -
+ ]
319 : :
320 : : const unsigned int header_size =
321 : 1 : info->header.message_size - packet_msg.payload.size();
322 : :
323 [ + - + - : 1 : BOOST_REQUIRE(info->groups[0] == call.name());
+ - + - +
- + - + -
- + ]
324 [ + - + - : 1 : BOOST_REQUIRE_EQUAL(std::memcmp(&packet_msg.payload[0],
+ - + - +
- - + ]
325 : : &info->message[header_size],
326 : : packet_msg.payload.size()), 0);
327 : :
328 [ + - + - ]: 2 : MessageReturnBigPacket packet_recv;
329 : :
330 [ + - + - : 1 : BOOST_REQUIRE_NO_THROW(call.unpacker().unpack(packet_recv,info->message));
+ - + - +
- + - + -
- + - + #
# # # # #
# # # # #
# # # #
# ]
331 [ + - + - : 1 : BOOST_REQUIRE_EQUAL(packet_recv.payload.size(), packet_msg.payload.size());
+ - + - +
- - + ]
332 [ + - + - : 1 : BOOST_REQUIRE_EQUAL(std::memcmp(&packet_msg.payload[0],
+ - + - +
- - + ]
333 : : &packet_recv.payload[0],
334 : : packet_msg.payload.size()), 0);
335 : 1 : }
336 : :
337 [ + - + - : 3 : BOOST_AUTO_TEST_CASE(test_erase_jumbo_messages) {
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - ]
338 : 1 : const unsigned int message_size = Caller<>::MaxUnfragmentedMessageSize;
339 [ + - + - : 2 : Caller<> call(MBOX, "", message_size, true);
+ - ]
340 : :
341 : : CallRequestBigPacket::future_ptr future_packet =
342 [ + - ]: 2 : call(CallRequestBigPacket(), call.name(), Message::Safe);
343 : :
344 : : CallEchoRequest::future_ptr future_echo =
345 [ + - ]: 2 : call(CallEchoRequest(), call.name(), Message::Safe);
346 : :
347 : 2 : message_info_ptr info;
348 [ + - ]: 1 : call.receive(info);
349 : :
350 [ + - + - : 1 : BOOST_REQUIRE(info->id() == CallRequestBigPacket::parameter_type::id);
+ - + - +
- + - -
+ ]
351 [ + - + - : 1 : BOOST_REQUIRE(info->role() == TwoWayRequest);
+ - + - +
- + - -
+ ]
352 [ + - + - : 1 : BOOST_REQUIRE(info->token() == future_packet->token());
+ - + - +
- + - -
+ ]
353 : :
354 : 1 : CallHeader header(MessageReturnBigPacket::id,info->token(),TwoWayResponse);
355 [ + - ]: 2 : Message message(message_size + 1024);
356 : :
357 [ + - ]: 1 : call.packer().pack(header, message);
358 : :
359 [ + + ]: 66041 : while(message.offset() < message_size + 1024) {
360 : 33020 : int bytes = std::rand();
361 [ + - ]: 33020 : message.write(&bytes, sizeof(bytes));
362 : : }
363 : :
364 [ + - ]: 1 : header.message_size = message.size();
365 [ + - ]: 1 : message.rewind();
366 : :
367 [ + - ]: 1 : call.packer().pack(header, message);
368 : :
369 [ + - ]: 1 : message.resize(message_size);
370 : : // Cheat so we can send
371 : 1 : ssrc::spread::Mailbox *mbox = &const_cast<Mailbox &>(call.mbox());
372 [ + - ]: 1 : mbox->send(message, call.name());
373 : :
374 [ + - ]: 1 : call.receive(info);
375 : :
376 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageEchoRequest::id);
+ - + - +
- + - -
+ ]
377 [ + - + - : 1 : BOOST_REQUIRE(info->role() == TwoWayRequest);
+ - + - +
- + - -
+ ]
378 [ + - + - : 1 : BOOST_REQUIRE(info->token() == future_echo->token());
+ - + - +
- + - -
+ ]
379 : :
380 [ + - ]: 1 : call(CallEchoReply(), call.name(), info->token(), Message::Safe);
381 : 1 : info.reset();
382 : :
383 : : MessageEchoReply echo_reply;
384 [ + - + - : 1 : BOOST_REQUIRE_NO_THROW(future_echo->receive(echo_reply));
+ - + - +
- + - + -
- + - + #
# # # # #
# # # # #
# # # #
# ]
385 [ + - + - : 1 : BOOST_REQUIRE(!future_echo->valid());
+ - + - +
- + - -
+ ]
386 : :
387 [ + - ]: 1 : future_echo = call(CallEchoRequest(), call.name(), Message::Safe);
388 : :
389 : 2 : std::vector<Caller<>::jumbo_message_key_type> keys;
390 : :
391 [ + - + - : 1 : BOOST_REQUIRE_EQUAL(static_cast<unsigned int>(keys.size()), 0u);
+ - + - +
- - + ]
392 [ + - + - : 1 : BOOST_REQUIRE_EQUAL(call.count_jumbo_messages(), 1u);
+ - + - +
- - + ]
393 : :
394 [ + - ]: 1 : call.collect_jumbo_message_keys(keys);
395 : :
396 [ + - + - : 1 : BOOST_REQUIRE_EQUAL(static_cast<unsigned int>(keys.size()), 1u);
+ - + - +
- - + ]
397 : :
398 [ + - ]: 1 : call.erase_jumbo_messages(keys.begin(), keys.end());
399 : :
400 [ + - + - : 1 : BOOST_REQUIRE_EQUAL(call.count_jumbo_messages(), 0u);
+ - + - +
- - + ]
401 : :
402 [ + - ]: 1 : call.erase_jumbo_messages(keys.begin(), keys.end());
403 : :
404 [ + - + - : 1 : BOOST_REQUIRE_EQUAL(call.count_jumbo_messages(), 0u);
+ - + - +
- - + ]
405 : :
406 [ + - ]: 1 : call.receive(info);
407 : :
408 [ + - + - : 1 : BOOST_REQUIRE(info->id() == MessageEchoRequest::id);
+ - + - +
- + - -
+ ]
409 [ + - + - : 1 : BOOST_REQUIRE(info->role() == TwoWayRequest);
+ - + - +
- + - -
+ ]
410 [ + - + - : 1 : BOOST_REQUIRE(info->token() == future_echo->token());
+ - + - +
- + - -
+ ]
411 [ + - + - ]: 4 : }
|