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_group_remote.c
22 * @brief testcase for testing remote and local starting and connecting
23 * of hosts from the testing library. The test_testing_data_remote.conf
24 * file should be modified if this testcase is intended to be used.
27 #include "gnunet_testing_lib.h"
29 #define VERBOSE GNUNET_YES
33 * How long until we give up on connecting the peers?
35 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
37 #define DEFAULT_NUM_PEERS 8;
41 static int peers_left;
43 static int peers_failed;
45 static struct GNUNET_TESTING_PeerGroup *pg;
47 static struct GNUNET_SCHEDULER_Handle *sched;
49 static unsigned long long num_peers;
51 static char *hostnames;
54 * Check whether peers successfully shut down.
56 void shutdown_callback (void *cls,
62 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
63 "Shutdown of peers failed!\n");
71 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
72 "All peers successfully shut down!\n");
80 const struct GNUNET_PeerIdentity *id,
81 const struct GNUNET_CONFIGURATION_Handle *cfg,
82 struct GNUNET_TESTING_Daemon *d, const char *emsg)
92 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
95 else if (peers_failed == peers_left)
97 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Too many peers failed, ending test!\n");
98 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
105 struct GNUNET_SCHEDULER_Handle *s,
107 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
112 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n");
116 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
118 num_peers = DEFAULT_NUM_PEERS;
120 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hosts",
123 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "No hosts specified, running all tests on localhost\n");
127 peers_left = num_peers;
128 pg = GNUNET_TESTING_daemons_start (sched,
139 GNUNET_assert (pg != NULL);
145 char *const argv[] = { "test-testing",
147 "test_testing_data_remote.conf",
153 struct GNUNET_GETOPT_CommandLineOption options[] = {
154 GNUNET_GETOPT_OPTION_END
156 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
157 argv, "test-testing-group", "nohelp",
163 main (int argc, char *argv[])
167 GNUNET_log_setup ("test-testing-group",
176 * Still need to remove the base testing directory here,
177 * because group starts will create subdirectories under this
178 * main dir. However, we no longer need to sleep, as the
179 * shutdown sequence won't return until everything is cleaned
182 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
186 /* end of test_testing_group.c */