2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file testing/test_testing_topology.c
22 * @brief base testcase for testing all the topologies provided
25 #include "gnunet_testing_lib.h"
26 #include "gnunet_core_service.h"
27 #include "gnunet_os_lib.h"
29 #define VERBOSE GNUNET_NO
31 #define DELAY_FOR_LOGGING GNUNET_NO
34 * How long until we fail the whole testcase?
36 #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
39 * How long until we give up on starting the peers?
41 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 500)
43 #define SECONDS_PER_PEER_START 45
45 #define DEFAULT_NUM_PEERS 4
47 #define MAX_OUTSTANDING_CONNECTIONS 300
49 static float fail_percentage = 0.05;
53 static unsigned long long num_peers;
55 static unsigned int total_connections;
57 static unsigned int failed_connections;
59 static unsigned int total_server_connections;
61 static unsigned int total_messages_received;
63 static unsigned int expected_messages;
65 static unsigned int expected_connections;
67 static unsigned long long peers_left;
69 static struct GNUNET_TESTING_PeerGroup *pg;
71 static struct GNUNET_SCHEDULER_Handle *sched;
73 const struct GNUNET_CONFIGURATION_Handle *main_cfg;
75 GNUNET_SCHEDULER_TaskIdentifier die_task;
77 static char *dotOutFileName;
79 static FILE *dotOutFile;
81 static char *topology_string;
83 static char *blacklist_transports;
85 static int transmit_ready_scheduled;
87 static int transmit_ready_failed;
89 static int transmit_ready_called;
91 static unsigned int modnum;
93 static unsigned int dotnum;
95 static enum GNUNET_TESTING_Topology topology;
97 static enum GNUNET_TESTING_Topology blacklist_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* Don't do any blacklisting */
99 static enum GNUNET_TESTING_Topology connection_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* NONE actually means connect all allowed peers */
101 static enum GNUNET_TESTING_TopologyOption connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL;
103 static double connect_topology_option_modifier = 0.0;
105 static char *test_directory;
109 struct GNUNET_TestMessage
112 * Header of the message
114 struct GNUNET_MessageHeader header;
117 * Unique identifier for this message.
122 struct TestMessageContext
124 /* This is a linked list */
125 struct TestMessageContext *next;
127 /* Handle to the sending peer core */
128 struct GNUNET_CORE_Handle *peer1handle;
130 /* Handle to the receiving peer core */
131 struct GNUNET_CORE_Handle *peer2handle;
133 /* Handle to the sending peer daemon */
134 struct GNUNET_TESTING_Daemon *peer1;
136 /* Handle to the receiving peer daemon */
137 struct GNUNET_TESTING_Daemon *peer2;
139 /* Identifier for this message, so we don't disconnect other peers! */
142 /* Task for disconnecting cores, allow task to be cancelled on shutdown */
143 GNUNET_SCHEDULER_TaskIdentifier disconnect_task;
147 static struct TestMessageContext *test_messages;
150 * Check whether peers successfully shut down.
152 void shutdown_callback (void *cls,
158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
159 "Shutdown of peers failed!\n");
167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
168 "All peers successfully shut down!\n");
173 #if DELAY_FOR_LOGGING
174 static void gather_log_data ()
177 char *connect_number;
179 GNUNET_asprintf(&peer_number, "%llu", num_peers);
180 GNUNET_asprintf(&connect_number, "%llu", expected_connections);
181 mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl",
182 "memsize.pl", "totals.txt", peer_number, connect_number, NULL);
183 GNUNET_OS_process_wait(mem_process);
190 GNUNET_assert (pg != NULL);
191 struct TestMessageContext *pos;
192 struct TestMessageContext *free_pos;
194 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
195 "Called finish testing, stopping daemons.\n");
203 if (pos->peer1handle != NULL)
205 GNUNET_CORE_disconnect(pos->peer1handle);
206 pos->peer1handle = NULL;
208 if (pos->peer2handle != NULL)
210 GNUNET_CORE_disconnect(pos->peer2handle);
211 pos->peer2handle = NULL;
215 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
217 GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task);
219 GNUNET_free(free_pos);
222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
223 "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, transmit_ready_called);
227 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
228 "Calling daemons_stop\n");
230 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
232 if (dotOutFile != NULL)
234 fprintf(dotOutFile, "}");
243 disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
245 struct TestMessageContext *pos = cls;
247 /* Disconnect from the respective cores */
249 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
250 "Disconnecting from peer 1 `%4s'\n", GNUNET_i2s (&pos->peer1->id));
252 if (pos->peer1handle != NULL)
253 GNUNET_CORE_disconnect(pos->peer1handle);
255 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
256 "Disconnecting from peer 2 `%4s'\n", GNUNET_i2s (&pos->peer2->id));
258 if (pos->peer2handle != NULL)
259 GNUNET_CORE_disconnect(pos->peer2handle);
260 /* Set handles to NULL so test case can be ended properly */
261 pos->peer1handle = NULL;
262 pos->peer2handle = NULL;
263 pos->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
264 /* Decrement total connections so new can be established */
265 total_server_connections -= 2;
269 process_mtype (void *cls,
270 const struct GNUNET_PeerIdentity *peer,
271 const struct GNUNET_MessageHeader *message,
272 struct GNUNET_TIME_Relative latency,
275 struct TestMessageContext *pos = cls;
276 struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *)message;
277 if (pos->uid != ntohl(msg->uid))
281 if ((total_messages_received) % modnum == 0)
283 if (total_messages_received == 0)
284 fprintf (stdout, "0%%");
286 fprintf (stdout, "%d%%",
287 (int) (((float) total_messages_received /
288 expected_messages) * 100));
291 else if (total_messages_received % dotnum == 0)
293 fprintf (stdout, ".");
298 total_messages_received++;
300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
301 "Received message from `%4s', type %d.\n", GNUNET_i2s (peer), ntohs(message->type));
302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
303 "Total messages received %d, expected %d.\n", total_messages_received, expected_messages);
306 if (total_messages_received == expected_messages)
309 fprintf(stdout, "100%%]\n");
311 GNUNET_SCHEDULER_cancel (sched, die_task);
312 GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL);
316 pos->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &disconnect_cores, pos);
323 end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
326 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
327 "End badly was called (%s)... stopping daemons.\n", msg);
328 struct TestMessageContext *pos;
329 struct TestMessageContext *free_pos;
334 if (pos->peer1handle != NULL)
336 GNUNET_CORE_disconnect(pos->peer1handle);
337 pos->peer1handle = NULL;
339 if (pos->peer2handle != NULL)
341 GNUNET_CORE_disconnect(pos->peer2handle);
342 pos->peer2handle = NULL;
346 GNUNET_free(free_pos);
351 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
352 ok = 7331; /* Opposite of leet */
355 ok = 401; /* Never got peers started */
357 if (dotOutFile != NULL)
359 fprintf(dotOutFile, "}");
365 transmit_ready (void *cls, size_t size, void *buf)
367 struct GNUNET_TestMessage *m;
368 struct TestMessageContext *pos = cls;
370 GNUNET_assert (buf != NULL);
371 m = (struct GNUNET_TestMessage *) buf;
372 m->header.type = htons (MTYPE);
373 m->header.size = htons (sizeof (struct GNUNET_TestMessage));
374 m->uid = htonl(pos->uid);
375 transmit_ready_called++;
377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
378 "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", GNUNET_i2s(&pos->peer1->id), transmit_ready_scheduled, transmit_ready_called);
380 return sizeof (struct GNUNET_TestMessage);
384 static struct GNUNET_CORE_MessageHandler no_handlers[] = {
388 static struct GNUNET_CORE_MessageHandler handlers[] = {
389 {&process_mtype, MTYPE, sizeof (struct GNUNET_TestMessage)},
394 init_notify_peer2 (void *cls,
395 struct GNUNET_CORE_Handle *server,
396 const struct GNUNET_PeerIdentity *my_identity,
397 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
399 struct TestMessageContext *pos = cls;
402 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
403 "Core connection to `%4s' established, scheduling message send\n",
404 GNUNET_i2s (my_identity));
406 total_server_connections++;
408 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle,
412 sizeof (struct GNUNET_TestMessage),
413 &transmit_ready, pos))
415 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
416 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
417 GNUNET_i2s (&pos->peer2->id));
418 transmit_ready_failed++;
422 transmit_ready_scheduled++;
428 init_notify_peer1 (void *cls,
429 struct GNUNET_CORE_Handle *server,
430 const struct GNUNET_PeerIdentity *my_identity,
431 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
433 struct TestMessageContext *pos = cls;
434 total_server_connections++;
437 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
438 "Core connection to `%4s' established, setting up handles\n",
439 GNUNET_i2s (my_identity));
443 * Connect to the receiving peer
445 pos->peer2handle = GNUNET_CORE_connect (sched,
453 GNUNET_YES, NULL, GNUNET_YES, handlers);
459 send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
461 struct TestMessageContext *pos = cls;
463 if ((tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) || (cls == NULL))
466 if (die_task == GNUNET_SCHEDULER_NO_TASK)
468 die_task = GNUNET_SCHEDULER_add_delayed (sched,
470 &end_badly, "from create topology (timeout)");
473 if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS)
475 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
476 &send_test_messages, pos);
477 return; /* Otherwise we'll double schedule messages here! */
481 * Connect to the sending peer
483 pos->peer1handle = GNUNET_CORE_connect (sched,
491 GNUNET_NO, NULL, GNUNET_NO, no_handlers);
493 GNUNET_assert(pos->peer1handle != NULL);
495 if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS)
497 GNUNET_SCHEDULER_add_now (sched,
498 &send_test_messages, pos->next);
502 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
503 &send_test_messages, pos->next);
509 topology_callback (void *cls,
510 const struct GNUNET_PeerIdentity *first,
511 const struct GNUNET_PeerIdentity *second,
513 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
514 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
515 struct GNUNET_TESTING_Daemon *first_daemon,
516 struct GNUNET_TESTING_Daemon *second_daemon,
519 struct TestMessageContext *temp_context;
523 if ((total_connections) % modnum == 0)
525 if (total_connections == 0)
526 fprintf (stdout, "0%%");
528 fprintf (stdout, "%d%%",
529 (int) (((float) total_connections /
530 expected_connections) * 100));
533 else if (total_connections % dotnum == 0)
535 fprintf (stdout, ".");
541 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s\n",
542 first_daemon->shortname,
543 second_daemon->shortname);
545 temp_context = GNUNET_malloc(sizeof(struct TestMessageContext));
546 temp_context->peer1 = first_daemon;
547 temp_context->peer2 = second_daemon;
548 temp_context->next = test_messages;
549 temp_context->uid = total_connections;
550 temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
551 test_messages = temp_context;
554 if (dotOutFile != NULL)
555 fprintf(dotOutFile, "\tn%s -- n%s;\n", first_daemon->shortname, second_daemon->shortname);
560 failed_connections++;
561 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error :\n%s\n",
562 first_daemon->shortname,
563 second_daemon->shortname, emsg);
567 if (total_connections == expected_connections)
570 fprintf(stdout, "100%%]\n");
573 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
574 "Created %d total connections, which is our target number! Calling send messages.\n",
577 modnum = expected_messages / 4;
578 dotnum = (expected_messages / 50) + 1;
579 GNUNET_SCHEDULER_cancel (sched, die_task);
580 die_task = GNUNET_SCHEDULER_NO_TASK;
581 #if DELAY_FOR_LOGGING
582 fprintf(stdout, "Sending test messages in 10 seconds.\n");
583 GNUNET_SCHEDULER_add_delayed (sched,
584 GNUNET_TIME_relative_multiply
585 (GNUNET_TIME_UNIT_SECONDS, 10),
586 &send_test_messages, test_messages);
589 GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages);
592 fprintf(stdout, "Test message progress: [");
596 else if (total_connections + failed_connections == expected_connections)
598 if (failed_connections < (unsigned int)(fail_percentage * total_connections))
600 GNUNET_SCHEDULER_cancel (sched, die_task);
601 die_task = GNUNET_SCHEDULER_NO_TASK;
602 GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages);
606 GNUNET_SCHEDULER_cancel (sched, die_task);
607 die_task = GNUNET_SCHEDULER_add_now (sched,
608 &end_badly, "from topology_callback (too many failed connections)");
614 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
615 "Have %d total connections, %d failed connections, Want %d (at least %d)\n",
616 total_connections, failed_connections, expected_connections, expected_connections - (unsigned int)(fail_percentage * expected_connections));
624 expected_connections = -1;
625 if ((pg != NULL) && (peers_left == 0))
627 expected_connections = GNUNET_TESTING_connect_topology (pg, connection_topology, connect_topology_option, connect_topology_option_modifier);
629 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
630 "Have %d expected connections\n", expected_connections);
634 GNUNET_SCHEDULER_cancel (sched, die_task);
635 if (expected_connections == GNUNET_SYSERR)
637 die_task = GNUNET_SCHEDULER_add_now (sched,
638 &end_badly, "from connect topology (bad return)");
641 die_task = GNUNET_SCHEDULER_add_delayed (sched,
643 &end_badly, "from connect topology (timeout)");
644 modnum = expected_connections / 4;
645 dotnum = (expected_connections / 50) + 1;
647 fprintf(stdout, "Peer connection progress: [");
654 peers_left = num_peers; /* Reset counter */
655 if (GNUNET_TESTING_create_topology (pg, topology, blacklist_topology, blacklist_transports) != GNUNET_SYSERR)
658 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
659 "Topology set up, now starting peers!\n");
660 fprintf(stdout, "Daemon start progress [");
662 GNUNET_TESTING_daemons_continue_startup(pg);
666 GNUNET_SCHEDULER_cancel (sched, die_task);
667 die_task = GNUNET_SCHEDULER_add_now (sched,
668 &end_badly, "from create topology (bad return)");
670 GNUNET_SCHEDULER_cancel (sched, die_task);
671 die_task = GNUNET_SCHEDULER_add_delayed (sched,
673 &end_badly, "from continue startup (timeout)");
678 peers_started_callback (void *cls,
679 const struct GNUNET_PeerIdentity *id,
680 const struct GNUNET_CONFIGURATION_Handle *cfg,
681 struct GNUNET_TESTING_Daemon *d, const char *emsg)
685 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to start daemon with error: `%s'\n",
689 GNUNET_assert (id != NULL);
691 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n",
692 (num_peers - peers_left) + 1, num_peers);
695 if ((num_peers - peers_left) % modnum == 0)
697 if (num_peers - peers_left == 0)
698 fprintf (stdout, "0%%");
700 fprintf (stdout, "%d%%",
701 (int) (((float) (num_peers - peers_left) /
705 else if ((num_peers - peers_left) % dotnum == 0)
707 fprintf (stdout, ".");
715 fprintf(stdout, "100%%]\n");
718 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
719 "All %d daemons started, now connecting peers!\n",
722 GNUNET_SCHEDULER_cancel (sched, die_task);
723 /* Set up task in case topology creation doesn't finish
724 * within a reasonable amount of time */
725 die_task = GNUNET_SCHEDULER_add_delayed (sched,
726 GNUNET_TIME_relative_multiply
727 (GNUNET_TIME_UNIT_MINUTES, 8),
728 &end_badly, "from peers_started_callback");
729 #if DELAY_FOR_LOGGING
730 fprintf(stdout, "Connecting topology in 10 seconds\n");
732 GNUNET_SCHEDULER_add_delayed (sched,
733 GNUNET_TIME_relative_multiply
734 (GNUNET_TIME_UNIT_SECONDS, 10),
735 &connect_topology, NULL);
744 * Callback indicating that the hostkey was created for a peer.
747 * @param id the peer identity
748 * @param d the daemon handle (pretty useless at this point, remove?)
749 * @param emsg non-null on failure
751 void hostkey_callback (void *cls,
752 const struct GNUNET_PeerIdentity *id,
753 struct GNUNET_TESTING_Daemon *d,
758 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Hostkey callback received error: %s\n", emsg);
762 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
763 "Hostkey (%d/%d) created for peer `%s'\n",
764 num_peers - peers_left, num_peers, GNUNET_i2s(id));
768 if ((num_peers - peers_left) % modnum == 0)
770 if (num_peers - peers_left == 0)
771 fprintf (stdout, "0%%");
773 fprintf (stdout, "%d%%",
774 (int) (((float) (num_peers - peers_left) /
778 else if ((num_peers - peers_left) % dotnum == 0)
780 fprintf (stdout, ".");
788 fprintf(stdout, "100%%]\n");
789 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
790 "All %d hostkeys created, now creating topology!\n",
793 GNUNET_SCHEDULER_cancel (sched, die_task);
794 /* Set up task in case topology creation doesn't finish
795 * within a reasonable amount of time */
796 die_task = GNUNET_SCHEDULER_add_delayed (sched,
798 &end_badly, "from create_topology");
799 GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL);
806 struct GNUNET_SCHEDULER_Handle *s,
808 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
811 char * connect_topology_str;
812 char * blacklist_topology_str;
813 char * connect_topology_option_str;
814 char * connect_topology_option_modifier_string;
818 dotOutFile = fopen (dotOutFileName, "w");
819 if (dotOutFile != NULL)
821 fprintf (dotOutFile, "strict graph G {\n");
825 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
826 "Starting daemons based on config file %s\n", cfgfile);
829 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory))
836 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology",
837 &topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&topology, topology_str)))
839 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
840 "Invalid topology `%s' given for section %s option %s\n", topology_str, "TESTING", "TOPOLOGY");
841 topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */
845 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "connect_topology",
846 &connect_topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&connection_topology, connect_topology_str)))
848 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
849 "Invalid connect topology `%s' given for section %s option %s\n", connect_topology_str, "TESTING", "CONNECT_TOPOLOGY");
851 GNUNET_free_non_null(connect_topology_str);
853 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "connect_topology_option",
854 &connect_topology_option_str)) && (GNUNET_NO == GNUNET_TESTING_topology_option_get(&connect_topology_option, connect_topology_option_str)))
856 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
857 "Invalid connect topology option `%s' given for section %s option %s\n", connect_topology_option_str, "TESTING", "CONNECT_TOPOLOGY_OPTION");
858 connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */
860 GNUNET_free_non_null(connect_topology_option_str);
862 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "connect_topology_option_modifier",
863 &connect_topology_option_modifier_string))
865 if (sscanf(connect_topology_option_modifier_string, "%lf", &connect_topology_option_modifier) != 1)
867 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
868 _("Invalid value `%s' for option `%s' in section `%s': expected float\n"),
869 connect_topology_option_modifier_string,
870 "connect_topology_option_modifier",
873 GNUNET_free (connect_topology_option_modifier_string);
876 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "blacklist_transports",
877 &blacklist_transports))
878 blacklist_transports = NULL;
881 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "blacklist_topology",
882 &blacklist_topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&blacklist_topology, blacklist_topology_str)))
884 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
885 "Invalid topology `%s' given for section %s option %s\n", topology_str, "TESTING", "BLACKLIST_TOPOLOGY");
887 GNUNET_free_non_null(topology_str);
888 GNUNET_free_non_null(blacklist_topology_str);
891 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
893 num_peers = DEFAULT_NUM_PEERS;
897 peers_left = num_peers;
898 modnum = num_peers / 4;
899 dotnum = (num_peers / 50) + 1;
901 fprintf (stdout, "Hostkey generation progress: \[");
903 /* Set up a task to end testing if peer start fails */
904 die_task = GNUNET_SCHEDULER_add_delayed (sched,
905 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers),
906 &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!");
908 pg = GNUNET_TESTING_daemons_start (sched, cfg,
909 peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL,
910 &topology_callback, NULL, NULL);
918 char *config_file_name;
919 GNUNET_asprintf(&binary_name, "test-testing-topology-%s", topology_string);
920 GNUNET_asprintf(&config_file_name, "test_testing_data_topology_%s.conf", topology_string);
922 char *const argv[] = {binary_name,
930 struct GNUNET_GETOPT_CommandLineOption options[] = {
931 GNUNET_GETOPT_OPTION_END
933 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
934 argv, binary_name, "nohelp",
936 if (ret != GNUNET_OK)
938 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "`test-testing-topology-%s': Failed with error code %d\n", topology_string, ret);
940 GNUNET_free(binary_name);
941 GNUNET_free(config_file_name);
946 main (int argc, char *argv[])
949 char *binary_start_pos;
950 char *our_binary_name;
952 binary_start_pos = rindex(argv[0], '/');
953 topology_string = strstr (binary_start_pos,
955 GNUNET_assert (topology_string != NULL);
957 topology_string = strstr (topology_string, "_");
958 GNUNET_assert (topology_string != NULL);
961 GNUNET_asprintf(&our_binary_name, "test-testing-topology_%s", topology_string);
962 GNUNET_asprintf(&dotOutFileName, "topology_%s.dot", topology_string);
964 GNUNET_log_setup (our_binary_name,
974 * Need to remove base directory, subdirectories taken care
975 * of by the testing framework.
977 if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK)
979 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to remove testing directory %s\n", test_directory);
981 GNUNET_free(our_binary_name);
985 /* end of test_testing_topology.c */