aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_reliability.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api_reliability.c')
-rw-r--r--src/transport/test_transport_api_reliability.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index 24ad4b81e..d6702cc25 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -50,6 +50,11 @@
50 */ 50 */
51#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 450 * FACTOR) 51#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 450 * FACTOR)
52 52
53/**
54 * If we are in an "xhdr" test, the factor by which we divide
55 * #TOTAL_MSGS for a more sane test duration.
56 */
57static unsigned int xhdr = 1;
53 58
54static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc; 59static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc;
55 60
@@ -105,7 +110,7 @@ get_size (unsigned int iter)
105static size_t 110static size_t
106get_size_cnt (unsigned int cnt_down) 111get_size_cnt (unsigned int cnt_down)
107{ 112{
108 size_t ret = get_size (TOTAL_MSGS - 1 - cnt_down); 113 size_t ret = get_size (TOTAL_MSGS / xhdr - 1 - cnt_down);
109 114
110 total_bytes += ret; 115 total_bytes += ret;
111 return ret; 116 return ret;
@@ -189,7 +194,7 @@ custom_shutdown (void *cls)
189 } 194 }
190 195
191 ok = 0; 196 ok = 0;
192 for (unsigned int i = 0; i < TOTAL_MSGS; i++) 197 for (unsigned int i = 0; i < TOTAL_MSGS / xhdr; i++)
193 { 198 {
194 if (get_bit (bitmap, i) == 0) 199 if (get_bit (bitmap, i) == 0)
195 { 200 {
@@ -208,27 +213,24 @@ static void
208notify_receive (void *cls, 213notify_receive (void *cls,
209 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, 214 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
210 const struct GNUNET_PeerIdentity *sender, 215 const struct GNUNET_PeerIdentity *sender,
211 const struct GNUNET_MessageHeader *message) 216 const struct GNUNET_TRANSPORT_TESTING_TestMessage *hdr)
212{ 217{
213 static int n; 218 static int n;
214 unsigned int s; 219 unsigned int s;
215 char cbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; 220 char cbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1];
216 const struct GNUNET_TRANSPORT_TESTING_TestMessage *hdr;
217
218 hdr = (const struct GNUNET_TRANSPORT_TESTING_TestMessage *) message;
219 221
220 if (GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE != ntohs (message->type)) 222 if (GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE != ntohs (hdr->header.type))
221 return; 223 return;
222 msg_recv = ntohl (hdr->num); 224 msg_recv = ntohl (hdr->num);
223 s = get_size (ntohl (hdr->num)); 225 s = get_size (ntohl (hdr->num));
224 226
225 if (ntohs (message->size) != s) 227 if (ntohs (hdr->header.size) != s)
226 { 228 {
227 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 229 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
228 "Expected message %u of size %u, got %u bytes of message %u\n", 230 "Expected message %u of size %u, got %u bytes of message %u\n",
229 ntohl (hdr->num), 231 ntohl (hdr->num),
230 s, 232 s,
231 ntohs (message->size), 233 ntohs (hdr->header.size),
232 ntohl (hdr->num)); 234 ntohl (hdr->num));
233 ccc->global_ret = GNUNET_SYSERR; 235 ccc->global_ret = GNUNET_SYSERR;
234 GNUNET_SCHEDULER_shutdown (); 236 GNUNET_SCHEDULER_shutdown ();
@@ -257,7 +259,7 @@ notify_receive (void *cls,
257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 259 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
258 "Got message %u of size %u\n", 260 "Got message %u of size %u\n",
259 ntohl (hdr->num), 261 ntohl (hdr->num),
260 ntohs (message->size)); 262 ntohs (hdr->header.size));
261 } 263 }
262#endif 264#endif
263 n++; 265 n++;
@@ -266,13 +268,13 @@ notify_receive (void *cls,
266 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 268 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
267 "Message id %u is bigger than maxmimum number of messages %u expected\n", 269 "Message id %u is bigger than maxmimum number of messages %u expected\n",
268 ntohl (hdr->num), 270 ntohl (hdr->num),
269 TOTAL_MSGS); 271 TOTAL_MSGS / xhdr);
270 } 272 }
271 if (0 == (n % (TOTAL_MSGS / 100))) 273 if (0 == (n % (TOTAL_MSGS / xhdr / 100)))
272 { 274 {
273 FPRINTF (stderr, "%s", "."); 275 FPRINTF (stderr, "%s", ".");
274 } 276 }
275 if (n == TOTAL_MSGS) 277 if (n == TOTAL_MSGS / xhdr)
276 { 278 {
277 /* end testcase with success */ 279 /* end testcase with success */
278 ccc->global_ret = GNUNET_OK; 280 ccc->global_ret = GNUNET_OK;
@@ -284,8 +286,10 @@ notify_receive (void *cls,
284int 286int
285main (int argc, char *argv[]) 287main (int argc, char *argv[])
286{ 288{
289 if (0 == strstr (argv[0], "xhdr"))
290 xhdr = 30;
287 struct GNUNET_TRANSPORT_TESTING_SendClosure sc = { 291 struct GNUNET_TRANSPORT_TESTING_SendClosure sc = {
288 .num_messages = TOTAL_MSGS, 292 .num_messages = TOTAL_MSGS / xhdr,
289 .get_size_cb = &get_size_cnt 293 .get_size_cb = &get_size_cnt
290 }; 294 };
291 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = { 295 struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = {