aboutsummaryrefslogtreecommitdiff
path: root/src/testing/test_testing_group_remote.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-04-28 13:59:11 +0000
committerNathan S. Evans <evans@in.tum.de>2010-04-28 13:59:11 +0000
commit43365f0c4f03ffa75b5018e3a7899fc338b40b29 (patch)
treef0133659e1e95c1ee13d97ac5c8659ab5966823a /src/testing/test_testing_group_remote.c
parent2213e374c96c97d9682073e2c3e6ed5a6700d554 (diff)
downloadgnunet-43365f0c4f03ffa75b5018e3a7899fc338b40b29.tar.gz
gnunet-43365f0c4f03ffa75b5018e3a7899fc338b40b29.zip
minor testing changes
Diffstat (limited to 'src/testing/test_testing_group_remote.c')
-rw-r--r--src/testing/test_testing_group_remote.c139
1 files changed, 139 insertions, 0 deletions
diff --git a/src/testing/test_testing_group_remote.c b/src/testing/test_testing_group_remote.c
new file mode 100644
index 000000000..c1bd2c8a6
--- /dev/null
+++ b/src/testing/test_testing_group_remote.c
@@ -0,0 +1,139 @@
1/*
2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19*/
20/**
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.
25 */
26#include "platform.h"
27#include "gnunet_testing_lib.h"
28
29#define VERBOSE GNUNET_YES
30
31
32/**
33 * How long until we give up on connecting the peers?
34 */
35#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
36
37#define DEFAULT_NUM_PEERS 8;
38
39static int ok;
40
41static int peers_left;
42
43static struct GNUNET_TESTING_PeerGroup *pg;
44
45static struct GNUNET_SCHEDULER_Handle *sched;
46
47static unsigned long long num_peers;
48
49static char *hostnames;
50
51
52static void
53my_cb (void *cls,
54 const struct GNUNET_PeerIdentity *id,
55 const struct GNUNET_CONFIGURATION_Handle *cfg,
56 struct GNUNET_TESTING_Daemon *d, const char *emsg)
57{
58 GNUNET_assert (id != NULL);
59 peers_left--;
60 if (peers_left == 0)
61 {
62 GNUNET_TESTING_daemons_stop (pg);
63 ok = 0;
64 }
65}
66
67
68static void
69run (void *cls,
70 struct GNUNET_SCHEDULER_Handle *s,
71 char *const *args,
72 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
73{
74 sched = s;
75 ok = 1;
76#if VERBOSE
77 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n");
78#endif
79
80 if (GNUNET_SYSERR ==
81 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
82 &num_peers))
83 num_peers = DEFAULT_NUM_PEERS;
84
85 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hosts",
86 &hostnames);
87
88 peers_left = num_peers;
89 pg = GNUNET_TESTING_daemons_start (sched, cfg,
90 peers_left,
91 &my_cb, NULL, NULL, NULL, hostnames);
92 GNUNET_assert (pg != NULL);
93}
94
95static int
96check ()
97{
98 char *const argv[] = { "test-testing",
99 "-c",
100 "test_testing_data_remote.conf",
101#if VERBOSE
102 "-L", "DEBUG",
103#endif
104 NULL
105 };
106 struct GNUNET_GETOPT_CommandLineOption options[] = {
107 GNUNET_GETOPT_OPTION_END
108 };
109 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
110 argv, "test-testing-group", "nohelp",
111 options, &run, &ok);
112 return ok;
113}
114
115int
116main (int argc, char *argv[])
117{
118 int ret;
119
120 GNUNET_log_setup ("test-testing-group",
121#if VERBOSE
122 "DEBUG",
123#else
124 "WARNING",
125#endif
126 NULL);
127 ret = check ();
128 /**
129 * Still need to remove the base testing directory here,
130 * because group starts will create subdirectories under this
131 * main dir. However, we no longer need to sleep, as the
132 * shutdown sequence won't return until everything is cleaned
133 * up.
134 */
135 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
136 return ret;
137}
138
139/* end of test_testing_group.c */