aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_unreliability.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
commit83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch)
treed0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/transport/test_transport_api_unreliability.c
parent28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff)
downloadgnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.tar.gz
gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.zip
curly wars / auto-indentation
Diffstat (limited to 'src/transport/test_transport_api_unreliability.c')
-rw-r--r--src/transport/test_transport_api_unreliability.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c
index 90b5280ce..3077eaae6 100644
--- a/src/transport/test_transport_api_unreliability.c
+++ b/src/transport/test_transport_api_unreliability.c
@@ -78,7 +78,7 @@ char *cfg_file_p2;
78uint32_t max_bps_p1; 78uint32_t max_bps_p1;
79uint32_t max_bps_p2; 79uint32_t max_bps_p2;
80 80
81struct GNUNET_TRANSPORT_TESTING_handle * tth; 81struct GNUNET_TRANSPORT_TESTING_handle *tth;
82 82
83/* 83/*
84 * Testcase specific declarations 84 * Testcase specific declarations
@@ -156,7 +156,7 @@ end ()
156 th = NULL; 156 th = NULL;
157 157
158 if (cc != NULL) 158 if (cc != NULL)
159 GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); 159 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
160 cc = NULL; 160 cc = NULL;
161 161
162 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 162 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
@@ -190,13 +190,15 @@ end_badly ()
190 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers got NOT connected\n"); 190 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers got NOT connected\n");
191 191
192 if (test_sending == GNUNET_NO) 192 if (test_sending == GNUNET_NO)
193 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Testcase did not send any messages timeout\n"); 193 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
194 "Testcase did not send any messages timeout\n");
194 else 195 else
195 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 196 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
196 "Reliability failed: Last message sent %u, Next message scheduled %u, Last message received %u, Message expected %u\n", 197 "Reliability failed: Last message sent %u, Next message scheduled %u, Last message received %u, Message expected %u\n",
197 msg_sent, msg_scheduled, msg_recv, msg_recv_expected); 198 msg_sent, msg_scheduled, msg_recv, msg_recv_expected);
198 if (test_send_timeout == GNUNET_YES) 199 if (test_send_timeout == GNUNET_YES)
199 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test had timeout while waiting to send data\n"); 200 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
201 "Test had timeout while waiting to send data\n");
200 202
201 203
202 if (th != NULL) 204 if (th != NULL)
@@ -204,7 +206,7 @@ end_badly ()
204 th = NULL; 206 th = NULL;
205 207
206 if (cc != NULL) 208 if (cc != NULL)
207 GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); 209 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
208 cc = NULL; 210 cc = NULL;
209 211
210 if (p1 != NULL) 212 if (p1 != NULL)
@@ -273,8 +275,7 @@ get_bit (const char *map, unsigned int bit)
273static void 275static void
274notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, 276notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
275 const struct GNUNET_MessageHeader *message, 277 const struct GNUNET_MessageHeader *message,
276 const struct GNUNET_ATS_Information *ats, 278 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
277 uint32_t ats_count)
278{ 279{
279 static int n; 280 static int n;
280 281
@@ -400,8 +401,7 @@ notify_ready (void *cls, size_t size, void *buf)
400 else 401 else
401 { 402 {
402 fprintf (stderr, "\n"); 403 fprintf (stderr, "\n");
403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 404 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All messages scheduled to be sent\n");
404 "All messages scheduled to be sent\n");
405 if (GNUNET_SCHEDULER_NO_TASK != die_task) 405 if (GNUNET_SCHEDULER_NO_TASK != die_task)
406 GNUNET_SCHEDULER_cancel (die_task); 406 GNUNET_SCHEDULER_cancel (die_task);
407 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 407 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
@@ -418,8 +418,7 @@ notify_ready (void *cls, size_t size, void *buf)
418 418
419static void 419static void
420notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, 420notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
421 const struct GNUNET_ATS_Information *ats, 421 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
422 uint32_t ats_count)
423{ 422{
424 423
425 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", 424 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
@@ -450,6 +449,7 @@ static void
450testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 449testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
451{ 450{
452 char *p1_c = strdup (GNUNET_i2s (&p1->id)); 451 char *p1_c = strdup (GNUNET_i2s (&p1->id));
452
453 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c, 453 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c,
454 GNUNET_i2s (&p2->id)); 454 GNUNET_i2s (&p2->id));
455 GNUNET_free (p1_c); 455 GNUNET_free (p1_c);
@@ -460,21 +460,22 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
460 GNUNET_SCHEDULER_add_now (&sendtask, NULL); 460 GNUNET_SCHEDULER_add_now (&sendtask, NULL);
461} 461}
462 462
463void start_cb (struct PeerContext * p, 463void
464 void *cls) 464start_cb (struct PeerContext *p, void *cls)
465{ 465{
466 static int started; 466 static int started;
467
467 started++; 468 started++;
468 469
469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", 470 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
470 p->no, 471 GNUNET_i2s (&p->id));
471 GNUNET_i2s (&p->id));
472 472
473 if (started != 2) 473 if (started != 2)
474 return; 474 return;
475 475
476 test_connected = GNUNET_NO; 476 test_connected = GNUNET_NO;
477 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL); 477 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
478 NULL);
478 479
479} 480}
480 481
@@ -487,14 +488,12 @@ run (void *cls, char *const *args, const char *cfgfile,
487 488
488 489
489 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, 490 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
490 &notify_receive, 491 &notify_receive, &notify_connect,
491 &notify_connect, &notify_disconnect, 492 &notify_disconnect, &start_cb,
492 &start_cb,
493 NULL); 493 NULL);
494 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, 494 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
495 &notify_receive, 495 &notify_receive, &notify_connect,
496 &notify_connect, &notify_disconnect, 496 &notify_disconnect, &start_cb,
497 &start_cb,
498 NULL); 497 NULL);
499 498
500 499