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 2, 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"
28 #define VERBOSE GNUNET_YES
31 * How long until we fail the whole testcase?
33 #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
36 * How long until we give up on starting the peers?
38 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 500)
40 #define SECONDS_PER_PEER_START 45
42 #define DEFAULT_NUM_PEERS 4
44 #define MAX_OUTSTANDING_CONNECTIONS 300
46 static float fail_percentage = 0.05;
50 static unsigned long long num_peers;
52 static unsigned int total_connections;
54 static unsigned int failed_connections;
56 static unsigned int total_server_connections;
58 static unsigned int total_messages_received;
60 static unsigned int expected_messages;
62 static unsigned int expected_connections;
64 static unsigned long long peers_left;
66 static struct GNUNET_TESTING_PeerGroup *pg;
68 static struct GNUNET_SCHEDULER_Handle *sched;
70 const struct GNUNET_CONFIGURATION_Handle *main_cfg;
72 GNUNET_SCHEDULER_TaskIdentifier die_task;
74 static char *dotOutFileName;
76 static FILE *dotOutFile;
78 static char *topology_string;
80 static char *blacklist_transports;
82 static int transmit_ready_scheduled;
84 static int transmit_ready_failed;
86 static int transmit_ready_called;
88 static unsigned int modnum;
90 static unsigned int dotnum;
92 static enum GNUNET_TESTING_Topology topology;
94 static enum GNUNET_TESTING_Topology blacklist_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* Don't do any blacklisting */
96 static enum GNUNET_TESTING_Topology connection_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* NONE actually means connect all allowed peers */
98 static enum GNUNET_TESTING_TopologyOption connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL;
100 static double connect_topology_option_modifier = 0.0;
102 static char *test_directory;
106 struct GNUNET_TestMessage
109 * Header of the message
111 struct GNUNET_MessageHeader header;
114 * Unique identifier for this message.
119 struct TestMessageContext
121 /* This is a linked list */
122 struct TestMessageContext *next;
124 /* Handle to the sending peer core */
125 struct GNUNET_CORE_Handle *peer1handle;
127 /* Handle to the receiving peer core */
128 struct GNUNET_CORE_Handle *peer2handle;
130 /* Handle to the sending peer daemon */
131 struct GNUNET_TESTING_Daemon *peer1;
133 /* Handle to the receiving peer daemon */
134 struct GNUNET_TESTING_Daemon *peer2;
136 /* Identifier for this message, so we don't disconnect other peers! */
139 /* Task for disconnecting cores, allow task to be cancelled on shutdown */
140 GNUNET_SCHEDULER_TaskIdentifier disconnect_task;
144 static struct TestMessageContext *test_messages;
147 * Check whether peers successfully shut down.
149 void shutdown_callback (void *cls,
155 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
156 "Shutdown of peers failed!\n");
164 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
165 "All peers successfully shut down!\n");
173 GNUNET_assert (pg != NULL);
174 struct TestMessageContext *pos;
175 struct TestMessageContext *free_pos;
177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
178 "Called finish testing, stopping daemons.\n");
185 if (pos->peer1handle != NULL)
187 GNUNET_CORE_disconnect(pos->peer1handle);
188 pos->peer1handle = NULL;
190 if (pos->peer2handle != NULL)
192 GNUNET_CORE_disconnect(pos->peer2handle);
193 pos->peer2handle = NULL;
197 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
199 GNUNET_SCHEDULER_cancel(sched, free_pos->disconnect_task);
201 GNUNET_free(free_pos);
204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
205 "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, transmit_ready_called);
209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
210 "Calling daemons_stop\n");
212 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
214 if (dotOutFile != NULL)
216 fprintf(dotOutFile, "}");
225 disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
227 struct TestMessageContext *pos = cls;
229 /* Disconnect from the respective cores */
231 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
232 "Disconnecting from peer 1 `%4s'\n", GNUNET_i2s (&pos->peer1->id));
234 if (pos->peer1handle != NULL)
235 GNUNET_CORE_disconnect(pos->peer1handle);
237 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
238 "Disconnecting from peer 2 `%4s'\n", GNUNET_i2s (&pos->peer2->id));
240 if (pos->peer2handle != NULL)
241 GNUNET_CORE_disconnect(pos->peer2handle);
242 /* Set handles to NULL so test case can be ended properly */
243 pos->peer1handle = NULL;
244 pos->peer2handle = NULL;
245 pos->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
246 /* Decrement total connections so new can be established */
247 total_server_connections -= 2;
251 process_mtype (void *cls,
252 const struct GNUNET_PeerIdentity *peer,
253 const struct GNUNET_MessageHeader *message,
254 struct GNUNET_TIME_Relative latency,
257 struct TestMessageContext *pos = cls;
258 struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *)message;
259 if (pos->uid != ntohl(msg->uid))
263 if ((total_messages_received) % modnum == 0)
265 if (total_messages_received == 0)
266 fprintf (stdout, "0%%");
268 fprintf (stdout, "%d%%",
269 (int) (((float) total_messages_received /
270 expected_messages) * 100));
273 else if (total_messages_received % dotnum == 0)
275 fprintf (stdout, ".");
280 total_messages_received++;
282 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
283 "Received message from `%4s', type %d.\n", GNUNET_i2s (peer), ntohs(message->type));
284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
285 "Total messages received %d, expected %d.\n", total_messages_received, expected_messages);
288 if (total_messages_received == expected_messages)
291 fprintf(stdout, "100%%]\n");
293 GNUNET_SCHEDULER_cancel (sched, die_task);
294 GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL);
298 pos->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &disconnect_cores, pos);
305 end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
308 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
309 "End badly was called (%s)... stopping daemons.\n", msg);
310 struct TestMessageContext *pos;
311 struct TestMessageContext *free_pos;
316 if (pos->peer1handle != NULL)
318 GNUNET_CORE_disconnect(pos->peer1handle);
319 pos->peer1handle = NULL;
321 if (pos->peer2handle != NULL)
323 GNUNET_CORE_disconnect(pos->peer2handle);
324 pos->peer2handle = NULL;
328 GNUNET_free(free_pos);
333 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
334 ok = 7331; /* Opposite of leet */
337 ok = 401; /* Never got peers started */
339 if (dotOutFile != NULL)
341 fprintf(dotOutFile, "}");
347 transmit_ready (void *cls, size_t size, void *buf)
349 struct GNUNET_TestMessage *m;
350 struct TestMessageContext *pos = cls;
352 GNUNET_assert (buf != NULL);
353 m = (struct GNUNET_TestMessage *) buf;
354 m->header.type = htons (MTYPE);
355 m->header.size = htons (sizeof (struct GNUNET_TestMessage));
356 m->uid = htonl(pos->uid);
357 transmit_ready_called++;
359 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
360 "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);
362 return sizeof (struct GNUNET_TestMessage);
366 static struct GNUNET_CORE_MessageHandler no_handlers[] = {
370 static struct GNUNET_CORE_MessageHandler handlers[] = {
371 {&process_mtype, MTYPE, sizeof (struct GNUNET_TestMessage)},
376 init_notify_peer2 (void *cls,
377 struct GNUNET_CORE_Handle *server,
378 const struct GNUNET_PeerIdentity *my_identity,
379 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
381 struct TestMessageContext *pos = cls;
384 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
385 "Core connection to `%4s' established, scheduling message send\n",
386 GNUNET_i2s (my_identity));
388 total_server_connections++;
390 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle,
394 sizeof (struct GNUNET_TestMessage),
395 &transmit_ready, pos))
397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
398 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
399 GNUNET_i2s (&pos->peer2->id));
400 transmit_ready_failed++;
404 transmit_ready_scheduled++;
410 init_notify_peer1 (void *cls,
411 struct GNUNET_CORE_Handle *server,
412 const struct GNUNET_PeerIdentity *my_identity,
413 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
415 struct TestMessageContext *pos = cls;
416 total_server_connections++;
419 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
420 "Core connection to `%4s' established, setting up handles\n",
421 GNUNET_i2s (my_identity));
425 * Connect to the receiving peer
427 pos->peer2handle = GNUNET_CORE_connect (sched,
435 GNUNET_YES, NULL, GNUNET_YES, handlers);
441 send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
443 struct TestMessageContext *pos = cls;
445 if ((tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) || (cls == NULL))
448 if (die_task == GNUNET_SCHEDULER_NO_TASK)
450 die_task = GNUNET_SCHEDULER_add_delayed (sched,
452 &end_badly, "from create topology (timeout)");
455 if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS)
457 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
458 &send_test_messages, pos);
459 return; /* Otherwise we'll double schedule messages here! */
463 * Connect to the sending peer
465 pos->peer1handle = GNUNET_CORE_connect (sched,
473 GNUNET_NO, NULL, GNUNET_NO, no_handlers);
475 GNUNET_assert(pos->peer1handle != NULL);
477 if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS)
479 GNUNET_SCHEDULER_add_now (sched,
480 &send_test_messages, pos->next);
484 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
485 &send_test_messages, pos->next);
491 topology_callback (void *cls,
492 const struct GNUNET_PeerIdentity *first,
493 const struct GNUNET_PeerIdentity *second,
495 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
496 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
497 struct GNUNET_TESTING_Daemon *first_daemon,
498 struct GNUNET_TESTING_Daemon *second_daemon,
501 struct TestMessageContext *temp_context;
505 if ((total_connections) % modnum == 0)
507 if (total_connections == 0)
508 fprintf (stdout, "0%%");
510 fprintf (stdout, "%d%%",
511 (int) (((float) total_connections /
512 expected_connections) * 100));
515 else if (total_connections % dotnum == 0)
517 fprintf (stdout, ".");
523 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s\n",
524 first_daemon->shortname,
525 second_daemon->shortname);
527 temp_context = GNUNET_malloc(sizeof(struct TestMessageContext));
528 temp_context->peer1 = first_daemon;
529 temp_context->peer2 = second_daemon;
530 temp_context->next = test_messages;
531 temp_context->uid = total_connections;
532 temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
533 test_messages = temp_context;
536 if (dotOutFile != NULL)
537 fprintf(dotOutFile, "\tn%s -- n%s;\n", first_daemon->shortname, second_daemon->shortname);
542 failed_connections++;
543 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error :\n%s\n",
544 first_daemon->shortname,
545 second_daemon->shortname, emsg);
549 if (total_connections == expected_connections)
552 fprintf(stdout, "100%%]\n");
555 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
556 "Created %d total connections, which is our target number! Calling send messages.\n",
559 modnum = expected_messages / 4;
560 dotnum = (expected_messages / 50) + 1;
562 fprintf(stdout, "Test message progress: [");
564 GNUNET_SCHEDULER_cancel (sched, die_task);
565 die_task = GNUNET_SCHEDULER_NO_TASK;
566 GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages);
568 else if (total_connections + failed_connections == expected_connections)
570 if (failed_connections < (unsigned int)(fail_percentage * total_connections))
572 GNUNET_SCHEDULER_cancel (sched, die_task);
573 die_task = GNUNET_SCHEDULER_NO_TASK;
574 GNUNET_SCHEDULER_add_now (sched, &send_test_messages, test_messages);
578 GNUNET_SCHEDULER_cancel (sched, die_task);
579 die_task = GNUNET_SCHEDULER_add_now (sched,
580 &end_badly, "from topology_callback (too many failed connections)");
586 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
587 "Have %d total connections, %d failed connections, Want %d (at least %d)\n",
588 total_connections, failed_connections, expected_connections, expected_connections - (unsigned int)(fail_percentage * expected_connections));
596 expected_connections = -1;
597 if ((pg != NULL) && (peers_left == 0))
599 expected_connections = GNUNET_TESTING_connect_topology (pg, connection_topology, connect_topology_option, connect_topology_option_modifier);
601 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
602 "Have %d expected connections\n", expected_connections);
606 GNUNET_SCHEDULER_cancel (sched, die_task);
607 if (expected_connections == GNUNET_SYSERR)
609 die_task = GNUNET_SCHEDULER_add_now (sched,
610 &end_badly, "from connect topology (bad return)");
613 die_task = GNUNET_SCHEDULER_add_delayed (sched,
615 &end_badly, "from connect topology (timeout)");
616 modnum = expected_connections / 4;
617 dotnum = (expected_connections / 50) + 1;
619 fprintf(stdout, "Peer connection progress: [");
626 peers_left = num_peers; /* Reset counter */
627 if (GNUNET_TESTING_create_topology (pg, topology, blacklist_topology, blacklist_transports) != GNUNET_SYSERR)
630 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
631 "Topology set up, now starting peers!\n");
633 fprintf(stdout, "Daemon start progress [");
634 GNUNET_TESTING_daemons_continue_startup(pg);
638 GNUNET_SCHEDULER_cancel (sched, die_task);
639 die_task = GNUNET_SCHEDULER_add_now (sched,
640 &end_badly, "from create topology (bad return)");
642 GNUNET_SCHEDULER_cancel (sched, die_task);
643 die_task = GNUNET_SCHEDULER_add_delayed (sched,
645 &end_badly, "from continue startup (timeout)");
650 peers_started_callback (void *cls,
651 const struct GNUNET_PeerIdentity *id,
652 const struct GNUNET_CONFIGURATION_Handle *cfg,
653 struct GNUNET_TESTING_Daemon *d, const char *emsg)
657 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to start daemon with error: `%s'\n",
661 GNUNET_assert (id != NULL);
663 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n",
664 (num_peers - peers_left) + 1, num_peers);
667 if ((num_peers - peers_left) % modnum == 0)
669 if (num_peers - peers_left == 0)
670 fprintf (stdout, "0%%");
672 fprintf (stdout, "%d%%",
673 (int) (((float) (num_peers - peers_left) /
677 else if ((num_peers - peers_left) % dotnum == 0)
679 fprintf (stdout, ".");
687 fprintf(stdout, "100%%]\n");
690 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
691 "All %d daemons started, now connecting peers!\n",
694 GNUNET_SCHEDULER_cancel (sched, die_task);
695 /* Set up task in case topology creation doesn't finish
696 * within a reasonable amount of time */
697 die_task = GNUNET_SCHEDULER_add_delayed (sched,
698 GNUNET_TIME_relative_multiply
699 (GNUNET_TIME_UNIT_MINUTES, 5),
700 &end_badly, "from peers_started_callback");
708 * Callback indicating that the hostkey was created for a peer.
711 * @param id the peer identity
712 * @param d the daemon handle (pretty useless at this point, remove?)
713 * @param emsg non-null on failure
715 void hostkey_callback (void *cls,
716 const struct GNUNET_PeerIdentity *id,
717 struct GNUNET_TESTING_Daemon *d,
722 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Hostkey callback received error: %s\n", emsg);
726 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
727 "Hostkey (%d/%d) created for peer `%s'\n",
728 num_peers - peers_left, num_peers, GNUNET_i2s(id));
732 if ((num_peers - peers_left) % modnum == 0)
734 if (num_peers - peers_left == 0)
735 fprintf (stdout, "0%%");
737 fprintf (stdout, "%d%%",
738 (int) (((float) (num_peers - peers_left) /
742 else if ((num_peers - peers_left) % dotnum == 0)
744 fprintf (stdout, ".");
752 fprintf(stdout, "100%%]\n");
753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
754 "All %d hostkeys created, now creating topology!\n",
757 GNUNET_SCHEDULER_cancel (sched, die_task);
758 /* Set up task in case topology creation doesn't finish
759 * within a reasonable amount of time */
760 die_task = GNUNET_SCHEDULER_add_delayed (sched,
762 &end_badly, "from create_topology");
763 GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL);
770 struct GNUNET_SCHEDULER_Handle *s,
772 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
775 char * connect_topology_str;
776 char * blacklist_topology_str;
777 char * connect_topology_option_str;
778 char * connect_topology_option_modifier_string;
782 dotOutFile = fopen (dotOutFileName, "w");
783 if (dotOutFile != NULL)
785 fprintf (dotOutFile, "strict graph G {\n");
789 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
790 "Starting daemons based on config file %s\n", cfgfile);
793 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory))
800 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology",
801 &topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&topology, topology_str)))
803 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
804 "Invalid topology `%s' given for section %s option %s\n", topology_str, "TESTING", "TOPOLOGY");
805 topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */
809 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "connect_topology",
810 &connect_topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&connection_topology, connect_topology_str)))
812 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
813 "Invalid connect topology `%s' given for section %s option %s\n", connect_topology_str, "TESTING", "CONNECT_TOPOLOGY");
815 GNUNET_free_non_null(connect_topology_str);
817 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "connect_topology_option",
818 &connect_topology_option_str)) && (GNUNET_NO == GNUNET_TESTING_topology_option_get(&connect_topology_option, connect_topology_option_str)))
820 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
821 "Invalid connect topology option `%s' given for section %s option %s\n", connect_topology_option_str, "TESTING", "CONNECT_TOPOLOGY_OPTION");
822 connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */
824 GNUNET_free_non_null(connect_topology_option_str);
826 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "connect_topology_option_modifier",
827 &connect_topology_option_modifier_string))
829 if (sscanf(connect_topology_option_modifier_string, "%lf", &connect_topology_option_modifier) != 1)
831 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
832 _("Invalid value `%s' for option `%s' in section `%s': expected float\n"),
833 connect_topology_option_modifier_string,
834 "connect_topology_option_modifier",
837 GNUNET_free (connect_topology_option_modifier_string);
840 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "blacklist_transports",
841 &blacklist_transports))
842 blacklist_transports = NULL;
845 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "blacklist_topology",
846 &blacklist_topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&blacklist_topology, blacklist_topology_str)))
848 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
849 "Invalid topology `%s' given for section %s option %s\n", topology_str, "TESTING", "BLACKLIST_TOPOLOGY");
851 GNUNET_free_non_null(topology_str);
852 GNUNET_free_non_null(blacklist_topology_str);
855 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
857 num_peers = DEFAULT_NUM_PEERS;
861 peers_left = num_peers;
862 modnum = num_peers / 4;
863 dotnum = (num_peers / 50) + 1;
864 fprintf (stdout, "Hostkey generation progress: \[");
865 /* Set up a task to end testing if peer start fails */
866 die_task = GNUNET_SCHEDULER_add_delayed (sched,
867 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers),
868 &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!");
870 pg = GNUNET_TESTING_daemons_start (sched, cfg,
871 peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL,
872 &topology_callback, NULL, NULL);
880 char *config_file_name;
881 GNUNET_asprintf(&binary_name, "test-testing-topology-%s", topology_string);
882 GNUNET_asprintf(&config_file_name, "test_testing_data_topology_%s.conf", topology_string);
884 char *const argv[] = {binary_name,
892 struct GNUNET_GETOPT_CommandLineOption options[] = {
893 GNUNET_GETOPT_OPTION_END
895 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
896 argv, binary_name, "nohelp",
898 if (ret != GNUNET_OK)
900 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "`test-testing-topology-%s': Failed with error code %d\n", topology_string, ret);
902 GNUNET_free(binary_name);
903 GNUNET_free(config_file_name);
908 main (int argc, char *argv[])
911 char *binary_start_pos;
912 char *our_binary_name;
914 binary_start_pos = rindex(argv[0], '/');
915 topology_string = strstr (binary_start_pos,
917 GNUNET_assert (topology_string != NULL);
919 topology_string = strstr (topology_string, "_");
920 GNUNET_assert (topology_string != NULL);
923 GNUNET_asprintf(&our_binary_name, "test-testing-topology_%s", topology_string);
924 GNUNET_asprintf(&dotOutFileName, "topology_%s.dot", topology_string);
926 GNUNET_log_setup (our_binary_name,
936 * Need to remove base directory, subdirectories taken care
937 * of by the testing framework.
939 if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK)
941 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to remove testing directory %s\n", test_directory);
943 GNUNET_free(our_binary_name);
947 /* end of test_testing_topology.c */