aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-03-03 14:24:02 +0000
committerNathan S. Evans <evans@in.tum.de>2010-03-03 14:24:02 +0000
commitbbcad62c9148ba628a424a1c7986d6d9afd3bfa7 (patch)
tree50574df6ea04290f7c62ab7272936030773ef142 /src/testing
parentbdd57a279ff49221288b0b326c926d10224b4716 (diff)
downloadgnunet-bbcad62c9148ba628a424a1c7986d6d9afd3bfa7.tar.gz
gnunet-bbcad62c9148ba628a424a1c7986d6d9afd3bfa7.zip
bug fixes, feature additions
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/test_testing_topology.c66
-rw-r--r--src/testing/testing_group.c150
2 files changed, 124 insertions, 92 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
index a0438f7be..3ae3046ab 100644
--- a/src/testing/test_testing_topology.c
+++ b/src/testing/test_testing_topology.c
@@ -27,6 +27,8 @@
27 27
28#define VERBOSE GNUNET_NO 28#define VERBOSE GNUNET_NO
29 29
30
31#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
30/** 32/**
31 * How long until we give up on connecting the peers? 33 * How long until we give up on connecting the peers?
32 */ 34 */
@@ -175,9 +177,10 @@ process_mtype (void *cls,
175static void 177static void
176end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 178end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
177{ 179{
180 char *msg = cls;
178#if VERBOSE 181#if VERBOSE
179 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
180 "End badly was called... stopping daemons.\n"); 183 "End badly was called (%s)... stopping daemons.\n", msg);
181#endif 184#endif
182 struct Connection *pos; 185 struct Connection *pos;
183 186
@@ -281,7 +284,7 @@ send_test_messages ()
281 struct TestMessageContext *pos; 284 struct TestMessageContext *pos;
282 struct Connection *conn_pos; 285 struct Connection *conn_pos;
283 die_task = GNUNET_SCHEDULER_add_delayed (sched, 286 die_task = GNUNET_SCHEDULER_add_delayed (sched,
284 TIMEOUT, 287 TEST_TIMEOUT,
285 &end_badly, "from send test messages"); 288 &end_badly, "from send test messages");
286 289
287 int count = 0; 290 int count = 0;
@@ -358,50 +361,6 @@ init_notify (void *cls,
358 GNUNET_SCHEDULER_cancel(sched, die_task); 361 GNUNET_SCHEDULER_cancel(sched, die_task);
359 GNUNET_SCHEDULER_add_now(sched, &send_test_messages, NULL); 362 GNUNET_SCHEDULER_add_now(sched, &send_test_messages, NULL);
360 } 363 }
361#if OLD
362 if (context->first_step_done == GNUNET_NO)
363 {
364 context->peer1handle = server;
365#if VERBOSE
366 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting core to peer 2\n");
367#endif
368 context->first_step_done = GNUNET_YES;
369 /* connect p2 */
370 GNUNET_CORE_connect (sched,
371 context->peer2->cfg,
372 TIMEOUT,
373 context,
374 &init_notify,
375 NULL,
376 NULL,
377 NULL,
378 NULL,
379 GNUNET_YES,
380 NULL, GNUNET_YES, handlers);
381
382 }
383 else
384 {
385 context->peer2handle = server;
386#if VERBOSE
387 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
388 "Asking core (1) for transmission to peer `%4s'\n",
389 GNUNET_i2s (&context->peer2->id));
390#endif
391 transmit_ready_scheduled++;
392 if (NULL == GNUNET_CORE_notify_transmit_ready (context->peer1->server,
393 0,
394 TIMEOUT,
395 &context->peer2->id,
396 sizeof (struct GNUNET_MessageHeader),
397 &transmit_ready, NULL))
398 {
399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
400 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
401 GNUNET_i2s (&context->peer2->id));
402 }
403 }
404#endif
405} 364}
406 365
407 366
@@ -413,7 +372,7 @@ setup_handlers ()
413 372
414 struct GNUNET_TESTING_Daemon *temp_daemon; 373 struct GNUNET_TESTING_Daemon *temp_daemon;
415 die_task = GNUNET_SCHEDULER_add_delayed (sched, 374 die_task = GNUNET_SCHEDULER_add_delayed (sched,
416 TIMEOUT, 375 TEST_TIMEOUT,
417 &end_badly, "from setup_handlers"); 376 &end_badly, "from setup_handlers");
418 377
419 378
@@ -479,7 +438,6 @@ topology_callback (void *cls,
479#if VERBOSE 438#if VERBOSE
480 else 439 else
481 { 440 {
482
483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error %s\n", 441 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error %s\n",
484 first_daemon->shortname, 442 first_daemon->shortname,
485 second_daemon->shortname, emsg); 443 second_daemon->shortname, emsg);
@@ -495,7 +453,8 @@ topology_callback (void *cls,
495#endif 453#endif
496 454
497 GNUNET_SCHEDULER_cancel (sched, die_task); 455 GNUNET_SCHEDULER_cancel (sched, die_task);
498 die_task = GNUNET_SCHEDULER_add_now (sched, &setup_handlers, NULL); 456 /* die_task = GNUNET_SCHEDULER_add_now (sched, &setup_handlers, NULL); */
457 die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1), &setup_handlers, NULL);
499 } 458 }
500 else 459 else
501 { 460 {
@@ -531,11 +490,11 @@ create_topology ()
531 if (expected_connections == GNUNET_SYSERR) 490 if (expected_connections == GNUNET_SYSERR)
532 { 491 {
533 die_task = GNUNET_SCHEDULER_add_now (sched, 492 die_task = GNUNET_SCHEDULER_add_now (sched,
534 &end_badly, NULL); 493 &end_badly, "from create topology (bad return)");
535 } 494 }
536 die_task = GNUNET_SCHEDULER_add_delayed (sched, 495 die_task = GNUNET_SCHEDULER_add_delayed (sched,
537 TIMEOUT, 496 TEST_TIMEOUT,
538 &end_badly, NULL); 497 &end_badly, "from create topology (timeout)");
539} 498}
540 499
541 500
@@ -632,6 +591,8 @@ check ()
632 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 591 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
633 argv, binary_name, "nohelp", 592 argv, binary_name, "nohelp",
634 options, &run, &ok); 593 options, &run, &ok);
594 GNUNET_free(binary_name);
595 GNUNET_free(config_file_name);
635 return ok; 596 return ok;
636} 597}
637 598
@@ -660,6 +621,7 @@ main (int argc, char *argv[])
660 ret = check (); 621 ret = check ();
661 sleep (1); 622 sleep (1);
662 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing"); 623 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
624 GNUNET_free(our_binary_name);
663 return ret; 625 return ret;
664} 626}
665 627
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 2c7cc80a5..4ce3c9ad1 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -229,7 +229,7 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t * port)
229 * @param first index of the first peer 229 * @param first index of the first peer
230 * @param second index of the second peer 230 * @param second index of the second peer
231 * 231 *
232 * @return the number of connections added (can be 0 1 or 2) 232 * @return the number of connections added (can be 0, 1 or 2)
233 * 233 *
234 * FIXME: add both, or only add one? 234 * FIXME: add both, or only add one?
235 * - if both are added, then we have to keep track 235 * - if both are added, then we have to keep track
@@ -313,17 +313,13 @@ create_small_world_ring(struct GNUNET_TESTING_PeerGroup *pg)
313 struct GNUNET_TIME_Absolute time; 313 struct GNUNET_TIME_Absolute time;
314 314
315 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "LOGNMODIFIER", &p_string); 315 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "LOGNMODIFIER", &p_string);
316 if (p_string != NULL) 316 if ((p_string == NULL) || (sscanf(p_string, "%lf", &logNModifier) != 1))
317 logNModifier = atof(p_string);
318 else
319 logNModifier = 0.5; /* FIXME: default modifier? */ 317 logNModifier = 0.5; /* FIXME: default modifier? */
320 318
321 GNUNET_free_non_null(p_string); 319 GNUNET_free_non_null(p_string);
322 320
323 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "PERCENTAGE", &p_string); 321 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "PERCENTAGE", &p_string);
324 if (p_string != NULL) 322 if ((p_string == NULL) || (sscanf(p_string, "%lf", &percentage) != 1))
325 percentage = atof(p_string);
326 else
327 percentage = 0.5; /* FIXME: default percentage? */ 323 percentage = 0.5; /* FIXME: default percentage? */
328 324
329 GNUNET_free_non_null(p_string); 325 GNUNET_free_non_null(p_string);
@@ -407,9 +403,7 @@ create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg)
407 char *p_string; 403 char *p_string;
408 404
409 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "NATPERCENTAGE", &p_string); 405 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "NATPERCENTAGE", &p_string);
410 if (p_string != NULL) 406 if ((p_string == NULL) || (sscanf(p_string, "%lf", &nat_percentage) != 1))
411 nat_percentage = atof(p_string);
412 else
413 nat_percentage = 0.6; /* FIXME: default modifier? */ 407 nat_percentage = 0.6; /* FIXME: default modifier? */
414 408
415 GNUNET_free_non_null(p_string); 409 GNUNET_free_non_null(p_string);
@@ -465,17 +459,13 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg)
465 cols = square; 459 cols = square;
466 460
467 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "PERCENTAGE", &p_string); 461 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "PERCENTAGE", &p_string);
468 if (p_string != NULL) 462 if ((p_string == NULL) || (sscanf(p_string, "%lf", &percentage) != 1))
469 percentage = atof(p_string);
470 else
471 percentage = 0.5; /* FIXME: default percentage? */ 463 percentage = 0.5; /* FIXME: default percentage? */
472 464
473 GNUNET_free_non_null(p_string); 465 GNUNET_free_non_null(p_string);
474 466
475 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "PROBABILITY", &p_string); 467 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "PROBABILITY", &p_string);
476 if (p_string != NULL) 468 if ((p_string == NULL) || (sscanf(p_string, "%lf", &probability) != 1))
477 probability = atof(p_string);
478 else
479 probability = 0.5; /* FIXME: default probability? */ 469 probability = 0.5; /* FIXME: default probability? */
480 470
481 GNUNET_free_non_null(p_string); 471 GNUNET_free_non_null(p_string);
@@ -583,14 +573,9 @@ create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg)
583 connect_attempts = 0; 573 connect_attempts = 0;
584 574
585 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "PROBABILITY", &p_string); 575 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "PROBABILITY", &p_string);
586 if (p_string != NULL) 576 if ((p_string == NULL) || (sscanf(p_string, "%lf", &probability) != 1))
587 { 577 probability = 0.5; /* FIXME: default probability? */
588 probability = atof(p_string); 578
589 }
590 else
591 {
592 probability = 0.5; /* FIXME: default probability? */
593 }
594 GNUNET_free_non_null (p_string); 579 GNUNET_free_non_null (p_string);
595 for (outer_count = 0; outer_count < pg->total - 1; outer_count++) 580 for (outer_count = 0; outer_count < pg->total - 1; outer_count++)
596 { 581 {
@@ -751,7 +736,7 @@ create_ring (struct GNUNET_TESTING_PeerGroup *pg)
751 * 736 *
752 * @param pg the peer group we are dealing with 737 * @param pg the peer group we are dealing with
753 */ 738 */
754static void 739static int
755create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) 740create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
756{ 741{
757 FILE *temp_friend_handle; 742 FILE *temp_friend_handle;
@@ -759,11 +744,17 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
759 struct PeerConnection *connection_iter; 744 struct PeerConnection *connection_iter;
760 struct GNUNET_CRYPTO_HashAsciiEncoded peer_enc; 745 struct GNUNET_CRYPTO_HashAsciiEncoded peer_enc;
761 char *temp_service_path; 746 char *temp_service_path;
762 pid_t pid; 747 pid_t *pidarr;
763 char *arg; 748 char *arg;
764 struct GNUNET_PeerIdentity *temppeer; 749 struct GNUNET_PeerIdentity *temppeer;
765 char * mytemp; 750 char * mytemp;
751 enum GNUNET_OS_ProcessStatusType type;
752 unsigned long return_code;
753 int count;
754 int ret;
755 int max_wait = 10;
766 756
757 pidarr = GNUNET_malloc(sizeof(pid_t) * pg->total);
767 for (pg_iter = 0; pg_iter < pg->total; pg_iter++) 758 for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
768 { 759 {
769 mytemp = GNUNET_DISK_mktemp("friends"); 760 mytemp = GNUNET_DISK_mktemp("friends");
@@ -794,12 +785,13 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
794 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ 785 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
795 { 786 {
796 GNUNET_asprintf (&arg, "%s/friends", temp_service_path); 787 GNUNET_asprintf (&arg, "%s/friends", temp_service_path);
797 pid = GNUNET_OS_start_process (NULL, NULL, "mv", 788 pidarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv",
798 "mv", mytemp, arg, NULL); 789 "mv", mytemp, arg, NULL);
799#if VERBOSE_TESTING 790#if VERBOSE_TESTING
800 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 791 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
801 _("Copying file with command cp %s %s\n"), mytemp, arg); 792 _("Copying file with command cp %s %s\n"), mytemp, arg);
802#endif 793#endif
794
803 GNUNET_free(arg); 795 GNUNET_free(arg);
804 } 796 }
805 else /* Remote, scp the file to the correct place */ 797 else /* Remote, scp the file to the correct place */
@@ -808,8 +800,9 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
808 GNUNET_asprintf (&arg, "%s@%s:%s/friends", pg->peers[pg_iter].daemon->username, pg->peers[pg_iter].daemon->hostname, temp_service_path); 800 GNUNET_asprintf (&arg, "%s@%s:%s/friends", pg->peers[pg_iter].daemon->username, pg->peers[pg_iter].daemon->hostname, temp_service_path);
809 else 801 else
810 GNUNET_asprintf (&arg, "%s:%s/friends", pg->peers[pg_iter].daemon->hostname, temp_service_path); 802 GNUNET_asprintf (&arg, "%s:%s/friends", pg->peers[pg_iter].daemon->hostname, temp_service_path);
811 pid = GNUNET_OS_start_process (NULL, NULL, "scp", 803 pidarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp",
812 "scp", mytemp, arg, NULL); 804 "scp", mytemp, arg, NULL);
805
813#if VERBOSE_TESTING 806#if VERBOSE_TESTING
814 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 807 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
815 _("Copying file with command scp %s %s\n"), mytemp, arg); 808 _("Copying file with command scp %s %s\n"), mytemp, arg);
@@ -819,6 +812,47 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
819 GNUNET_free (temp_service_path); 812 GNUNET_free (temp_service_path);
820 GNUNET_free (mytemp); 813 GNUNET_free (mytemp);
821 } 814 }
815
816 count = 0;
817 ret = GNUNET_SYSERR;
818 while ((count < max_wait) && (ret != GNUNET_OK))
819 {
820 ret = GNUNET_OK;
821 for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
822 {
823#if VERBOSE_TESTING
824 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
825 _("Checking copy status of file %d\n"), pg_iter);
826#endif
827 if (pidarr[pg_iter] != 0) /* Check for already completed! */
828 {
829 if (GNUNET_OS_process_status(pidarr[pg_iter], &type, &return_code) != GNUNET_OK)
830 {
831 ret = GNUNET_SYSERR;
832 }
833 else if ((type != GNUNET_OS_PROCESS_EXITED) || (return_code != 0))
834 {
835 ret = GNUNET_SYSERR;
836 }
837 else
838 {
839 pidarr[pg_iter] = 0;
840#if VERBOSE_TESTING
841 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
842 _("File %d copied\n"), pg_iter);
843#endif
844 }
845 }
846 }
847 count++;
848 if (ret == GNUNET_SYSERR)
849 {
850 sleep(1);
851 }
852 }
853
854 GNUNET_free(pidarr);
855 return ret;
822} 856}
823 857
824 858
@@ -834,7 +868,9 @@ connect_topology (struct GNUNET_TESTING_PeerGroup *pg)
834{ 868{
835 unsigned int pg_iter; 869 unsigned int pg_iter;
836 struct PeerConnection *connection_iter; 870 struct PeerConnection *connection_iter;
871 int connect_count;
837 872
873 connect_count = 0;
838 for (pg_iter = 0; pg_iter < pg->total; pg_iter++) 874 for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
839 { 875 {
840 connection_iter = pg->peers[pg_iter].connected_peers; 876 connection_iter = pg->peers[pg_iter].connected_peers;
@@ -846,6 +882,15 @@ connect_topology (struct GNUNET_TESTING_PeerGroup *pg)
846 pg->notify_connection, 882 pg->notify_connection,
847 pg->notify_connection_cls); 883 pg->notify_connection_cls);
848 connection_iter = connection_iter->next; 884 connection_iter = connection_iter->next;
885 connect_count++;
886 if (connect_count % 50 == 0)
887 {
888#if VERBOSE_TESTING
889 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
890 _("Sleeping to give peers a chance to connect!\n"));
891#endif
892 sleep(2);
893 }
849 } 894 }
850 } 895 }
851} 896}
@@ -860,12 +905,16 @@ connect_topology (struct GNUNET_TESTING_PeerGroup *pg)
860 * 905 *
861 * @param pg the peer group struct representing the running peers 906 * @param pg the peer group struct representing the running peers
862 * 907 *
908 * @return the number of connections should be created by the topology, so the
909 * caller knows how many to wait for (if it so chooses)
910 *
863 */ 911 */
864int 912int
865GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg) 913GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg)
866{ 914{
867 unsigned long long topology_num; 915 unsigned long long topology_num;
868 int ret; 916 int ret;
917 int num_connections;
869 918
870 GNUNET_assert (pg->notify_connection != NULL); 919 GNUNET_assert (pg->notify_connection != NULL);
871 ret = 0; 920 ret = 0;
@@ -880,62 +929,72 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg)
880 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 929 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
881 _("Creating clique topology (may take a bit!)\n")); 930 _("Creating clique topology (may take a bit!)\n"));
882#endif 931#endif
883 ret = create_clique (pg); 932 num_connections = create_clique (pg);
884 break; 933 break;
885 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: 934 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING:
886#if VERBOSE_TESTING 935#if VERBOSE_TESTING
887 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 936 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
888 _("Creating small world (ring) topology (may take a bit!)\n")); 937 _("Creating small world (ring) topology (may take a bit!)\n"));
889#endif 938#endif
890 ret = create_small_world_ring (pg); 939 num_connections = create_small_world_ring (pg);
891 break; 940 break;
892 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: 941 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD:
893#if VERBOSE_TESTING 942#if VERBOSE_TESTING
894 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 943 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
895 _("Creating small world (2d-torus) topology (may take a bit!)\n")); 944 _("Creating small world (2d-torus) topology (may take a bit!)\n"));
896#endif 945#endif
897 ret = create_small_world (pg); 946 num_connections = create_small_world (pg);
898 break; 947 break;
899 case GNUNET_TESTING_TOPOLOGY_RING: 948 case GNUNET_TESTING_TOPOLOGY_RING:
900#if VERBOSE_TESTING 949#if VERBOSE_TESTING
901 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 950 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
902 _("Creating ring topology (may take a bit!)\n")); 951 _("Creating ring topology (may take a bit!)\n"));
903#endif 952#endif
904 ret = create_ring (pg); 953 num_connections = create_ring (pg);
905 break; 954 break;
906 case GNUNET_TESTING_TOPOLOGY_2D_TORUS: 955 case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
907#if VERBOSE_TESTING 956#if VERBOSE_TESTING
908 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 957 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
909 _("Creating 2d torus topology (may take a bit!)\n")); 958 _("Creating 2d torus topology (may take a bit!)\n"));
910#endif 959#endif
911 ret = create_2d_torus (pg); 960 num_connections = create_2d_torus (pg);
912 break; 961 break;
913 case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: 962 case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
914#if VERBOSE_TESTING 963#if VERBOSE_TESTING
915 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 964 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
916 _("Creating Erdos-Renyi topology (may take a bit!)\n")); 965 _("Creating Erdos-Renyi topology (may take a bit!)\n"));
917#endif 966#endif
918 ret = create_erdos_renyi (pg); 967 num_connections = create_erdos_renyi (pg);
919 break; 968 break;
920 case GNUNET_TESTING_TOPOLOGY_INTERNAT: 969 case GNUNET_TESTING_TOPOLOGY_INTERNAT:
921#if VERBOSE_TESTING 970#if VERBOSE_TESTING
922 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 971 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
923 _("Creating InterNAT topology (may take a bit!)\n")); 972 _("Creating InterNAT topology (may take a bit!)\n"));
924#endif 973#endif
925 ret = create_nated_internet (pg); 974 num_connections = create_nated_internet (pg);
926 break; 975 break;
927 case GNUNET_TESTING_TOPOLOGY_NONE: 976 case GNUNET_TESTING_TOPOLOGY_NONE:
928 ret = 0; 977 num_connections = 0;
929 break; 978 break;
930 default: 979 default:
931 ret = GNUNET_SYSERR; 980 ret = GNUNET_SYSERR;
932 break; 981 break;
933 } 982 }
983 if (num_connections < 1)
984 return GNUNET_SYSERR;
934 985
935 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "F2F")) 986 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "F2F"))
936 create_and_copy_friend_files(pg); 987 ret = create_and_copy_friend_files(pg);
937 988 if (ret == GNUNET_OK)
938 connect_topology(pg); 989 connect_topology(pg);
990 else
991 {
992#if VERBOSE_TESTING
993 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
994 _("Failed during friend file copying!\n"));
995#endif
996 return GNUNET_SYSERR;
997 }
939 } 998 }
940 else 999 else
941 { 1000 {
@@ -943,7 +1002,7 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg)
943 _("No topology specified, was one intended?\n")); 1002 _("No topology specified, was one intended?\n"));
944 } 1003 }
945 1004
946 return ret; 1005 return num_connections;
947} 1006}
948 1007
949/** 1008/**
@@ -1126,6 +1185,8 @@ void
1126GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg) 1185GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg)
1127{ 1186{
1128 unsigned int off; 1187 unsigned int off;
1188 struct PeerConnection *pos;
1189 struct PeerConnection *next;
1129 1190
1130 for (off = 0; off < pg->total; off++) 1191 for (off = 0; off < pg->total; off++)
1131 { 1192 {
@@ -1138,6 +1199,15 @@ GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg)
1138 GNUNET_TESTING_daemon_stop (pg->peers[off].daemon, NULL, NULL); 1199 GNUNET_TESTING_daemon_stop (pg->peers[off].daemon, NULL, NULL);
1139 if (NULL != pg->peers[off].cfg) 1200 if (NULL != pg->peers[off].cfg)
1140 GNUNET_CONFIGURATION_destroy (pg->peers[off].cfg); 1201 GNUNET_CONFIGURATION_destroy (pg->peers[off].cfg);
1202
1203 pos = pg->peers[off].connected_peers;
1204 while (pos != NULL)
1205 {
1206 next = pos->next;
1207 GNUNET_free(pos);
1208 pos = next;
1209 }
1210
1141 } 1211 }
1142 GNUNET_free (pg->peers); 1212 GNUNET_free (pg->peers);
1143 if (NULL != pg->hosts) 1213 if (NULL != pg->hosts)