aboutsummaryrefslogtreecommitdiff
path: root/src/testing/test_testing_topology.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-06 18:04:22 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-06 18:04:22 +0000
commit5c748fe953690879274eb47049089dd4e6f85810 (patch)
tree55b76192ed10fe8c88e82fcb79a7376559fd58ef /src/testing/test_testing_topology.c
parent98ebd9b7431b176365a8cd7352b43ad306d3e1ad (diff)
downloadgnunet-5c748fe953690879274eb47049089dd4e6f85810.tar.gz
gnunet-5c748fe953690879274eb47049089dd4e6f85810.zip
-more to remove
Diffstat (limited to 'src/testing/test_testing_topology.c')
-rw-r--r--src/testing/test_testing_topology.c59
1 files changed, 0 insertions, 59 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
index 112838f2f..fe616906e 100644
--- a/src/testing/test_testing_topology.c
+++ b/src/testing/test_testing_topology.c
@@ -26,7 +26,6 @@
26#include "gnunet_core_service.h" 26#include "gnunet_core_service.h"
27#include "gnunet_os_lib.h" 27#include "gnunet_os_lib.h"
28 28
29#define VERBOSE GNUNET_NO
30 29
31#define PROGRESS_BARS GNUNET_YES 30#define PROGRESS_BARS GNUNET_YES
32 31
@@ -172,17 +171,13 @@ shutdown_callback (void *cls, const char *emsg)
172{ 171{
173 if (emsg != NULL) 172 if (emsg != NULL)
174 { 173 {
175#if VERBOSE
176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); 174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n");
177#endif
178 if (ok == 0) 175 if (ok == 0)
179 ok = 666; 176 ok = 666;
180 } 177 }
181 else 178 else
182 { 179 {
183#if VERBOSE
184 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers successfully shut down!\n"); 180 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers successfully shut down!\n");
185#endif
186 } 181 }
187} 182}
188 183
@@ -213,11 +208,8 @@ finish_testing ()
213 struct TestMessageContext *pos; 208 struct TestMessageContext *pos;
214 struct TestMessageContext *free_pos; 209 struct TestMessageContext *free_pos;
215 210
216#if VERBOSE
217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
218 "Called finish testing, stopping daemons.\n"); 212 "Called finish testing, stopping daemons.\n");
219#endif
220
221 pos = test_messages; 213 pos = test_messages;
222 while (pos != NULL) 214 while (pos != NULL)
223 { 215 {
@@ -239,16 +231,11 @@ finish_testing ()
239 } 231 }
240 GNUNET_free (free_pos); 232 GNUNET_free (free_pos);
241 } 233 }
242#if VERBOSE
243 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
244 "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", 235 "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n",
245 transmit_ready_scheduled, transmit_ready_failed, 236 transmit_ready_scheduled, transmit_ready_failed,
246 transmit_ready_called); 237 transmit_ready_called);
247#endif
248
249#if VERBOSE
250 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling daemons_stop\n"); 238 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling daemons_stop\n");
251#endif
252 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 239 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
253 240
254 if (dotOutFile != NULL) 241 if (dotOutFile != NULL)
@@ -267,16 +254,12 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
267 struct TestMessageContext *pos = cls; 254 struct TestMessageContext *pos = cls;
268 255
269 /* Disconnect from the respective cores */ 256 /* Disconnect from the respective cores */
270#if VERBOSE > 1
271 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n", 257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n",
272 GNUNET_i2s (&pos->peer1->id)); 258 GNUNET_i2s (&pos->peer1->id));
273#endif
274 if (pos->peer1handle != NULL) 259 if (pos->peer1handle != NULL)
275 GNUNET_CORE_disconnect (pos->peer1handle); 260 GNUNET_CORE_disconnect (pos->peer1handle);
276#if VERBOSE > 1
277 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n", 261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n",
278 GNUNET_i2s (&pos->peer2->id)); 262 GNUNET_i2s (&pos->peer2->id));
279#endif
280 if (pos->peer2handle != NULL) 263 if (pos->peer2handle != NULL)
281 GNUNET_CORE_disconnect (pos->peer2handle); 264 GNUNET_CORE_disconnect (pos->peer2handle);
282 /* Set handles to NULL so test case can be ended properly */ 265 /* Set handles to NULL so test case can be ended properly */
@@ -382,14 +365,12 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
382 365
383 total_messages_received++; 366 total_messages_received++;
384 367
385#if VERBOSE > 1
386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 368 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
387 "Received message from `%4s', type %d.\n", GNUNET_i2s (peer), 369 "Received message from `%4s', type %d.\n", GNUNET_i2s (peer),
388 ntohs (message->type)); 370 ntohs (message->type));
389 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 371 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
390 "Total messages received %d, expected %d.\n", 372 "Total messages received %d, expected %d.\n",
391 total_messages_received, expected_messages); 373 total_messages_received, expected_messages);
392#endif
393 374
394 if (total_messages_received == expected_messages) 375 if (total_messages_received == expected_messages)
395 { 376 {
@@ -444,7 +425,6 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
444 GNUNET_free (free_pos); 425 GNUNET_free (free_pos);
445 } 426 }
446 427
447#if VERBOSE
448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 428 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
449 "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", 429 "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n",
450 transmit_ready_scheduled, transmit_ready_failed, 430 transmit_ready_scheduled, transmit_ready_failed,
@@ -452,7 +432,6 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
452 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 432 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
453 "Total messages received %d, expected %d.\n", 433 "Total messages received %d, expected %d.\n",
454 total_messages_received, expected_messages); 434 total_messages_received, expected_messages);
455#endif
456 435
457 if (pg != NULL) 436 if (pg != NULL)
458 { 437 {
@@ -481,12 +460,10 @@ transmit_ready (void *cls, size_t size, void *buf)
481 m->header.size = htons (sizeof (struct GNUNET_TestMessage)); 460 m->header.size = htons (sizeof (struct GNUNET_TestMessage));
482 m->uid = htonl (pos->uid); 461 m->uid = htonl (pos->uid);
483 transmit_ready_called++; 462 transmit_ready_called++;
484#if VERBOSE > 1
485 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 463 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
486 "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", 464 "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n",
487 GNUNET_i2s (&pos->peer1->id), transmit_ready_scheduled, 465 GNUNET_i2s (&pos->peer1->id), transmit_ready_scheduled,
488 transmit_ready_called); 466 transmit_ready_called);
489#endif
490 return sizeof (struct GNUNET_TestMessage); 467 return sizeof (struct GNUNET_TestMessage);
491} 468}
492 469
@@ -511,12 +488,10 @@ init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server,
511 pos->peer2connected = GNUNET_YES; 488 pos->peer2connected = GNUNET_YES;
512 if (pos->peer1notified == GNUNET_YES) /* Peer 1 has been notified of connection to peer 2 */ 489 if (pos->peer1notified == GNUNET_YES) /* Peer 1 has been notified of connection to peer 2 */
513 { 490 {
514#if VERBOSE > 1
515 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 491 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
516 "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", 492 "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n",
517 GNUNET_i2s (my_identity), 493 GNUNET_i2s (my_identity),
518 GNUNET_h2s (&pos->peer1->id.hashPubKey)); 494 GNUNET_h2s (&pos->peer1->id.hashPubKey));
519#endif
520 if (NULL == 495 if (NULL ==
521 GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0, 496 GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0,
522 TIMEOUT, &pos->peer2->id, 497 TIMEOUT, &pos->peer2->id,
@@ -553,23 +528,19 @@ connect_notify_peers (void *cls, const struct GNUNET_PeerIdentity *peer,
553 if (0 == memcmp (peer, &pos->peer2->id, sizeof (struct GNUNET_PeerIdentity))) 528 if (0 == memcmp (peer, &pos->peer2->id, sizeof (struct GNUNET_PeerIdentity)))
554 { 529 {
555 pos->peer1notified = GNUNET_YES; 530 pos->peer1notified = GNUNET_YES;
556#if VERBOSE > 1
557 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 531 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
558 "Peer `%s' notified of connection to peer `%s'\n", 532 "Peer `%s' notified of connection to peer `%s'\n",
559 GNUNET_i2s (&pos->peer1->id), GNUNET_h2s (&peer->hashPubKey)); 533 GNUNET_i2s (&pos->peer1->id), GNUNET_h2s (&peer->hashPubKey));
560#endif
561 } 534 }
562 else 535 else
563 return; 536 return;
564 537
565 if (pos->peer2connected == GNUNET_YES) /* Already connected and notified of connection, send message! */ 538 if (pos->peer2connected == GNUNET_YES) /* Already connected and notified of connection, send message! */
566 { 539 {
567#if VERBOSE > 1
568 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 540 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
569 "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", 541 "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n",
570 GNUNET_i2s (&pos->peer2->id), 542 GNUNET_i2s (&pos->peer2->id),
571 GNUNET_h2s (&pos->peer1->id.hashPubKey)); 543 GNUNET_h2s (&pos->peer1->id.hashPubKey));
572#endif
573 if (NULL == 544 if (NULL ==
574 GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0, 545 GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0,
575 TIMEOUT, &pos->peer2->id, 546 TIMEOUT, &pos->peer2->id,
@@ -596,12 +567,9 @@ init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server,
596 567
597 total_server_connections++; 568 total_server_connections++;
598 569
599#if VERBOSE > 1
600 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 570 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
601 "Core connection to `%4s' established, setting up handles\n", 571 "Core connection to `%4s' established, setting up handles\n",
602 GNUNET_i2s (my_identity)); 572 GNUNET_i2s (my_identity));
603#endif
604
605 /* 573 /*
606 * Connect to the receiving peer 574 * Connect to the receiving peer
607 */ 575 */
@@ -694,10 +662,8 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
694 fflush (stdout); 662 fflush (stdout);
695#endif 663#endif
696 total_connections++; 664 total_connections++;
697#if VERBOSE > 1
698 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "connected peer %s to peer %s\n", 665 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "connected peer %s to peer %s\n",
699 first_daemon->shortname, second_daemon->shortname); 666 first_daemon->shortname, second_daemon->shortname);
700#endif
701 temp_context = GNUNET_malloc (sizeof (struct TestMessageContext)); 667 temp_context = GNUNET_malloc (sizeof (struct TestMessageContext));
702 temp_context->peer1 = first_daemon; 668 temp_context->peer1 = first_daemon;
703 temp_context->peer2 = second_daemon; 669 temp_context->peer2 = second_daemon;
@@ -711,7 +677,6 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
711 FPRINTF (dotOutFile, "\tn%s -- n%s;\n", first_daemon->shortname, 677 FPRINTF (dotOutFile, "\tn%s -- n%s;\n", first_daemon->shortname,
712 second_daemon->shortname); 678 second_daemon->shortname);
713 } 679 }
714#if VERBOSE
715 else 680 else
716 { 681 {
717 failed_connections++; 682 failed_connections++;
@@ -719,18 +684,15 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
719 "Failed to connect peer %s to peer %s with error :\n%s\n", 684 "Failed to connect peer %s to peer %s with error :\n%s\n",
720 first_daemon->shortname, second_daemon->shortname, emsg); 685 first_daemon->shortname, second_daemon->shortname, emsg);
721 } 686 }
722#endif
723 687
724 if (total_connections == expected_connections) 688 if (total_connections == expected_connections)
725 { 689 {
726#if PROGRESS_BARS 690#if PROGRESS_BARS
727 FPRINTF (stdout, "%s", "100%%]\n"); 691 FPRINTF (stdout, "%s", "100%%]\n");
728#endif 692#endif
729#if VERBOSE
730 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 693 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
731 "Created %d total connections, which is our target number! Calling send messages.\n", 694 "Created %d total connections, which is our target number! Calling send messages.\n",
732 total_connections); 695 total_connections);
733#endif
734 modnum = expected_messages / 4; 696 modnum = expected_messages / 4;
735 dotnum = (expected_messages / 50) + 1; 697 dotnum = (expected_messages / 50) + 1;
736 if (modnum == 0) 698 if (modnum == 0)
@@ -777,24 +739,20 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
777 } 739 }
778 else 740 else
779 { 741 {
780#if VERBOSE > 1
781 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
782 "Have %d total connections, %d failed connections, Want %d (at least %d)\n", 743 "Have %d total connections, %d failed connections, Want %d (at least %d)\n",
783 total_connections, failed_connections, expected_connections, 744 total_connections, failed_connections, expected_connections,
784 expected_connections - 745 expected_connections -
785 (unsigned int) (fail_percentage * expected_connections)); 746 (unsigned int) (fail_percentage * expected_connections));
786#endif
787 } 747 }
788} 748}
789 749
790static void 750static void
791topology_creation_finished (void *cls, const char *emsg) 751topology_creation_finished (void *cls, const char *emsg)
792{ 752{
793#if VERBOSE
794 if (emsg == NULL) 753 if (emsg == NULL)
795 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 754 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
796 "All topology connections created successfully!\n"); 755 "All topology connections created successfully!\n");
797#endif
798} 756}
799 757
800static void 758static void
@@ -884,10 +842,8 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,
884 return; 842 return;
885 } 843 }
886 GNUNET_assert (id != NULL); 844 GNUNET_assert (id != NULL);
887#if VERBOSE > 1
888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n", 845 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n",
889 (num_peers - peers_left) + 1, num_peers); 846 (num_peers - peers_left) + 1, num_peers);
890#endif
891#if PROGRESS_BARS 847#if PROGRESS_BARS
892 if ((num_peers - peers_left) % modnum == 0) 848 if ((num_peers - peers_left) % modnum == 0)
893 { 849 {
@@ -910,10 +866,8 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,
910#if PROGRESS_BARS 866#if PROGRESS_BARS
911 FPRINTF (stdout, "%s", "100%%]\n"); 867 FPRINTF (stdout, "%s", "100%%]\n");
912#endif 868#endif
913#if VERBOSE
914 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 869 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
915 "All %d daemons started, now connecting peers!\n", num_peers); 870 "All %d daemons started, now connecting peers!\n", num_peers);
916#endif
917 GNUNET_SCHEDULER_cancel (die_task); 871 GNUNET_SCHEDULER_cancel (die_task);
918 /* Set up task in case topology creation doesn't finish 872 /* Set up task in case topology creation doesn't finish
919 * within a reasonable amount of time */ 873 * within a reasonable amount of time */
@@ -952,12 +906,9 @@ hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
952 "Hostkey callback received error: %s\n", emsg); 906 "Hostkey callback received error: %s\n", emsg);
953 } 907 }
954 908
955#if VERBOSE > 1
956 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 909 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
957 "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left, 910 "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left,
958 num_peers, GNUNET_i2s (id)); 911 num_peers, GNUNET_i2s (id));
959#endif
960
961#if PROGRESS_BARS 912#if PROGRESS_BARS
962 if ((num_peers - peers_left) % modnum == 0) 913 if ((num_peers - peers_left) % modnum == 0)
963 { 914 {
@@ -1012,11 +963,8 @@ run (void *cls, char *const *args, const char *cfgfile,
1012 FPRINTF (dotOutFile, "%s", "strict graph G {\n"); 963 FPRINTF (dotOutFile, "%s", "strict graph G {\n");
1013 } 964 }
1014 965
1015#if VERBOSE
1016 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 966 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1017 "Starting daemons based on config file %s\n", cfgfile); 967 "Starting daemons based on config file %s\n", cfgfile);
1018#endif
1019
1020 if (GNUNET_YES != 968 if (GNUNET_YES !=
1021 GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome", 969 GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome",
1022 &test_directory)) 970 &test_directory))
@@ -1192,9 +1140,6 @@ check ()
1192 char *const argv[] = { binary_name, 1140 char *const argv[] = { binary_name,
1193 "-c", 1141 "-c",
1194 config_file_name, 1142 config_file_name,
1195#if VERBOSE
1196 "-L", "DEBUG",
1197#endif
1198 NULL 1143 NULL
1199 }; 1144 };
1200 struct GNUNET_GETOPT_CommandLineOption options[] = { 1145 struct GNUNET_GETOPT_CommandLineOption options[] = {
@@ -1238,11 +1183,7 @@ main (int argc, char *argv[])
1238 GNUNET_asprintf (&dotOutFileName, "topology_%s.dot", topology_string); 1183 GNUNET_asprintf (&dotOutFileName, "topology_%s.dot", topology_string);
1239 1184
1240 GNUNET_log_setup (our_binary_name, 1185 GNUNET_log_setup (our_binary_name,
1241#if VERBOSE
1242 "DEBUG",
1243#else
1244 "WARNING", 1186 "WARNING",
1245#endif
1246 NULL); 1187 NULL);
1247 ret = check (); 1188 ret = check ();
1248 GNUNET_free (topology_string); 1189 GNUNET_free (topology_string);