aboutsummaryrefslogtreecommitdiff
path: root/src/testing/test_testing_topology.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-07 07:38:43 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-07 07:38:43 +0000
commitea35b849436708f4402d5d4f41d4c6ce44572c05 (patch)
tree6e5f49f13612cb258a3158c8a046cc05b319783b /src/testing/test_testing_topology.c
parent968fcecb4701064fd37d8e3350888be94c9d5b67 (diff)
downloadgnunet-ea35b849436708f4402d5d4f41d4c6ce44572c05.tar.gz
gnunet-ea35b849436708f4402d5d4f41d4c6ce44572c05.zip
-improving error messages of failing test
Diffstat (limited to 'src/testing/test_testing_topology.c')
-rw-r--r--src/testing/test_testing_topology.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
index fe616906e..ab6644c10 100644
--- a/src/testing/test_testing_topology.c
+++ b/src/testing/test_testing_topology.c
@@ -166,12 +166,13 @@ static struct TestMessageContext *test_messages;
166/** 166/**
167 * Check whether peers successfully shut down. 167 * Check whether peers successfully shut down.
168 */ 168 */
169void 169static void
170shutdown_callback (void *cls, const char *emsg) 170shutdown_callback (void *cls, const char *emsg)
171{ 171{
172 if (emsg != NULL) 172 if (emsg != NULL)
173 { 173 {
174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); 174 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Shutdown of peers failed: %s!\n",
175 emsg);
175 if (ok == 0) 176 if (ok == 0)
176 ok = 666; 177 ok = 666;
177 } 178 }
@@ -181,6 +182,7 @@ shutdown_callback (void *cls, const char *emsg)
181 } 182 }
182} 183}
183 184
185
184#if DELAY_FOR_LOGGING 186#if DELAY_FOR_LOGGING
185static void 187static void
186gather_log_data () 188gather_log_data ()
@@ -198,9 +200,9 @@ gather_log_data ()
198 GNUNET_OS_process_close (mem_process); 200 GNUNET_OS_process_close (mem_process);
199 mem_process = NULL; 201 mem_process = NULL;
200} 202}
201
202#endif 203#endif
203 204
205
204static void 206static void
205finish_testing () 207finish_testing ()
206{ 208{
@@ -243,7 +245,6 @@ finish_testing ()
243 FPRINTF (dotOutFile, "%s", "}"); 245 FPRINTF (dotOutFile, "%s", "}");
244 FCLOSE (dotOutFile); 246 FCLOSE (dotOutFile);
245 } 247 }
246
247 ok = 0; 248 ok = 0;
248} 249}
249 250
@@ -257,14 +258,17 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n", 258 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n",
258 GNUNET_i2s (&pos->peer1->id)); 259 GNUNET_i2s (&pos->peer1->id));
259 if (pos->peer1handle != NULL) 260 if (pos->peer1handle != NULL)
261 {
260 GNUNET_CORE_disconnect (pos->peer1handle); 262 GNUNET_CORE_disconnect (pos->peer1handle);
263 pos->peer1handle = NULL;
264 }
261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n", 265 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n",
262 GNUNET_i2s (&pos->peer2->id)); 266 GNUNET_i2s (&pos->peer2->id));
263 if (pos->peer2handle != NULL) 267 if (pos->peer2handle != NULL)
268 {
264 GNUNET_CORE_disconnect (pos->peer2handle); 269 GNUNET_CORE_disconnect (pos->peer2handle);
265 /* Set handles to NULL so test case can be ended properly */ 270 pos->peer2handle = NULL;
266 pos->peer1handle = NULL; 271 }
267 pos->peer2handle = NULL;
268 pos->disconnect_task = GNUNET_SCHEDULER_NO_TASK; 272 pos->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
269 /* Decrement total connections so new can be established */ 273 /* Decrement total connections so new can be established */
270 total_server_connections -= 2; 274 total_server_connections -= 2;
@@ -299,6 +303,7 @@ stats_print (void *cls, const struct GNUNET_PeerIdentity *peer,
299} 303}
300#endif 304#endif
301 305
306
302static void 307static void
303topology_cb (void *cls, const struct GNUNET_PeerIdentity *first, 308topology_cb (void *cls, const struct GNUNET_PeerIdentity *first,
304 const struct GNUNET_PeerIdentity *second, const char *emsg) 309 const struct GNUNET_PeerIdentity *second, const char *emsg)
@@ -331,6 +336,7 @@ topology_cb (void *cls, const struct GNUNET_PeerIdentity *first,
331 } 336 }
332} 337}
333 338
339
334static int 340static int
335process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, 341process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
336 const struct GNUNET_MessageHeader *message, 342 const struct GNUNET_MessageHeader *message,
@@ -397,13 +403,14 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
397 return GNUNET_OK; 403 return GNUNET_OK;
398} 404}
399 405
406
400static void 407static void
401end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 408end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
402{ 409{
403 char *msg = cls; 410 char *msg = cls;
404 411
405 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 412 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
406 "End badly was called (%s)... stopping daemons.\n", msg); 413 "Ending with error: %s\n", msg);
407 struct TestMessageContext *pos; 414 struct TestMessageContext *pos;
408 struct TestMessageContext *free_pos; 415 struct TestMessageContext *free_pos;
409 416
@@ -448,6 +455,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
448 } 455 }
449} 456}
450 457
458
451static size_t 459static size_t
452transmit_ready (void *cls, size_t size, void *buf) 460transmit_ready (void *cls, size_t size, void *buf)
453{ 461{
@@ -472,11 +480,13 @@ static struct GNUNET_CORE_MessageHandler no_handlers[] = {
472 {NULL, 0, 0} 480 {NULL, 0, 0}
473}; 481};
474 482
483
475static struct GNUNET_CORE_MessageHandler handlers[] = { 484static struct GNUNET_CORE_MessageHandler handlers[] = {
476 {&process_mtype, MTYPE, sizeof (struct GNUNET_TestMessage)}, 485 {&process_mtype, MTYPE, sizeof (struct GNUNET_TestMessage)},
477 {NULL, 0, 0} 486 {NULL, 0, 0}
478}; 487};
479 488
489
480static void 490static void
481init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server, 491init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server,
482 const struct GNUNET_PeerIdentity *my_identity) 492 const struct GNUNET_PeerIdentity *my_identity)
@@ -510,6 +520,7 @@ init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server,
510 } 520 }
511} 521}
512 522
523
513/** 524/**
514 * Method called whenever a given peer connects. 525 * Method called whenever a given peer connects.
515 * 526 *
@@ -559,6 +570,7 @@ connect_notify_peers (void *cls, const struct GNUNET_PeerIdentity *peer,
559 } 570 }
560} 571}
561 572
573
562static void 574static void
563init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server, 575init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server,
564 const struct GNUNET_PeerIdentity *my_identity) 576 const struct GNUNET_PeerIdentity *my_identity)
@@ -566,7 +578,6 @@ init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server,
566 struct TestMessageContext *pos = cls; 578 struct TestMessageContext *pos = cls;
567 579
568 total_server_connections++; 580 total_server_connections++;
569
570 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
571 "Core connection to `%4s' established, setting up handles\n", 582 "Core connection to `%4s' established, setting up handles\n",
572 GNUNET_i2s (my_identity)); 583 GNUNET_i2s (my_identity));
@@ -631,7 +642,7 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
631} 642}
632 643
633 644
634void 645static void
635topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, 646topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
636 const struct GNUNET_PeerIdentity *second, uint32_t distance, 647 const struct GNUNET_PeerIdentity *second, uint32_t distance,
637 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 648 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
@@ -680,7 +691,7 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
680 else 691 else
681 { 692 {
682 failed_connections++; 693 failed_connections++;
683 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 694 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
684 "Failed to connect peer %s to peer %s with error :\n%s\n", 695 "Failed to connect peer %s to peer %s with error :\n%s\n",
685 first_daemon->shortname, second_daemon->shortname, emsg); 696 first_daemon->shortname, second_daemon->shortname, emsg);
686 } 697 }
@@ -747,6 +758,7 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
747 } 758 }
748} 759}
749 760
761
750static void 762static void
751topology_creation_finished (void *cls, const char *emsg) 763topology_creation_finished (void *cls, const char *emsg)
752{ 764{
@@ -755,6 +767,7 @@ topology_creation_finished (void *cls, const char *emsg)
755 "All topology connections created successfully!\n"); 767 "All topology connections created successfully!\n");
756} 768}
757 769
770
758static void 771static void
759connect_topology () 772connect_topology ()
760{ 773{
@@ -768,7 +781,7 @@ connect_topology ()
768 connect_timeout, connect_attempts, 781 connect_timeout, connect_attempts,
769 &topology_creation_finished, NULL); 782 &topology_creation_finished, NULL);
770#if PROGRESS_BARS 783#if PROGRESS_BARS
771 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %d expected connections\n", 784 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n",
772 expected_connections); 785 expected_connections);
773#endif 786#endif
774 } 787 }
@@ -944,6 +957,7 @@ hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
944 } 957 }
945} 958}
946 959
960
947static void 961static void
948run (void *cls, char *const *args, const char *cfgfile, 962run (void *cls, char *const *args, const char *cfgfile,
949 const struct GNUNET_CONFIGURATION_Handle *cfg) 963 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -1126,6 +1140,7 @@ run (void *cls, char *const *args, const char *cfgfile,
1126 1140
1127} 1141}
1128 1142
1143
1129static int 1144static int
1130check () 1145check ()
1131{ 1146{
@@ -1159,6 +1174,7 @@ check ()
1159 return ok; 1174 return ok;
1160} 1175}
1161 1176
1177
1162int 1178int
1163main (int argc, char *argv[]) 1179main (int argc, char *argv[])
1164{ 1180{