aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2014-01-08 15:02:20 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2014-01-08 15:02:20 +0000
commitce8e0739623ee25d2a29a75f393027a42bbe4d4f (patch)
treee7e81cdd5acda711d738706b9a1ff141b819b2cd /src/testbed
parent8b69aded04512e71f742c2ee60be174af18a8759 (diff)
downloadgnunet-ce8e0739623ee25d2a29a75f393027a42bbe4d4f.tar.gz
gnunet-ce8e0739623ee25d2a29a75f393027a42bbe4d4f.zip
- testbed underlay testcase
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/Makefile.am14
-rw-r--r--src/testbed/test-underlay.sqlitebin0 -> 3072 bytes
-rw-r--r--src/testbed/test_testbed_underlay.c141
-rw-r--r--src/testbed/test_testbed_underlay.conf.in14
-rw-r--r--src/testbed/testbed.conf.in10
5 files changed, 177 insertions, 2 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am
index b8e00f90c..823ddaa83 100644
--- a/src/testbed/Makefile.am
+++ b/src/testbed/Makefile.am
@@ -19,6 +19,7 @@ pkgcfg_DATA = \
19if HAVE_SQLITE 19if HAVE_SQLITE
20 underlay_daemon = gnunet-daemon-testbed-underlay 20 underlay_daemon = gnunet-daemon-testbed-underlay
21 generate_underlay = generate-underlay-topology 21 generate_underlay = generate-underlay-topology
22 underlay_testcases = test_testbed_underlay
22endif 23endif
23 24
24libexec_PROGRAMS = \ 25libexec_PROGRAMS = \
@@ -177,7 +178,8 @@ check_PROGRAMS = \
177 test_testbed_api_testbed_run_waitforever \ 178 test_testbed_api_testbed_run_waitforever \
178 test_testbed_api_statistics \ 179 test_testbed_api_statistics \
179 gnunet-service-test-barriers \ 180 gnunet-service-test-barriers \
180 test_testbed_api_barriers 181 test_testbed_api_barriers \
182 $(underlay_testcases)
181 183
182if ENABLE_TEST_RUN 184if ENABLE_TEST_RUN
183 TESTS = \ 185 TESTS = \
@@ -394,6 +396,12 @@ gnunet_service_test_barriers_LDADD = \
394 $(top_builddir)/src/util/libgnunetutil.la \ 396 $(top_builddir)/src/util/libgnunetutil.la \
395 libgnunettestbed.la 397 libgnunettestbed.la
396 398
399test_testbed_underlay_SOURCES = \
400 test_testbed_underlay.c
401test_testbed_underlay_LDADD = \
402 $(top_builddir)/src/util/libgnunetutil.la \
403 libgnunettestbed.la
404
397EXTRA_DIST = \ 405EXTRA_DIST = \
398 test_testbed_api.conf \ 406 test_testbed_api.conf \
399 test_testbed_api_test_timeout.conf \ 407 test_testbed_api_test_timeout.conf \
@@ -411,4 +419,6 @@ EXTRA_DIST = \
411 test_testbed_api_barriers.conf.in \ 419 test_testbed_api_barriers.conf.in \
412 overlay_topology.txt \ 420 overlay_topology.txt \
413 sample_hosts.txt \ 421 sample_hosts.txt \
414 sample.job 422 sample.job \
423 test_testbed_underlay.conf.in \
424 test-underlay.sqlite
diff --git a/src/testbed/test-underlay.sqlite b/src/testbed/test-underlay.sqlite
new file mode 100644
index 000000000..46f48d9db
--- /dev/null
+++ b/src/testbed/test-underlay.sqlite
Binary files differ
diff --git a/src/testbed/test_testbed_underlay.c b/src/testbed/test_testbed_underlay.c
new file mode 100644
index 000000000..6b66a5f7a
--- /dev/null
+++ b/src/testbed/test_testbed_underlay.c
@@ -0,0 +1,141 @@
1/*
2 This file is part of GNUnet
3 (C) 2008--2013 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 3, 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/**
22 * @file testbed/test_testbed_underlay.c
23 * @brief testcase binary for testing testbed underlay restrictions
24 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
25 */
26
27#include "platform.h"
28#include "gnunet_util_lib.h"
29#include "gnunet_testbed_service.h"
30
31
32/**
33 * Number of peers we start in this test case
34 */
35#define NUM_PEERS 3
36
37/**
38 * Result of this test case
39 */
40static int result;
41
42static struct GNUNET_TESTBED_Operation *op;
43
44
45/**
46 * Callback to be called when an operation is completed
47 *
48 * @param cls the callback closure from functions generating an operation
49 * @param op the operation that has been finished
50 * @param emsg error message in case the operation has failed; will be NULL if
51 * operation has executed successfully.
52 */
53static void
54overlay_connect_status (void *cls,
55 struct GNUNET_TESTBED_Operation *op,
56 const char *emsg)
57{
58 GNUNET_TESTBED_operation_done (op);
59 op = NULL;
60 if (NULL == emsg)
61 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Peers 0 and 2 should not get connected\n");
62 else
63 result = GNUNET_OK;
64 GNUNET_SCHEDULER_shutdown ();
65}
66
67
68
69/**
70 * Signature of a main function for a testcase.
71 *
72 * @param cls closure
73 * @param h the run handle
74 * @param num_peers number of peers in 'peers'
75 * @param peers_ handle to peers run in the testbed
76 * @param links_succeeded the number of overlay link connection attempts that
77 * succeeded
78 * @param links_failed the number of overlay link connection attempts that
79 * failed
80 */
81static void
82test_master (void *cls,
83 struct GNUNET_TESTBED_RunHandle *h,
84 unsigned int num_peers,
85 struct GNUNET_TESTBED_Peer **peers_,
86 unsigned int links_succeeded,
87 unsigned int links_failed)
88{
89 GNUNET_assert (NULL == cls);
90 if (NULL == peers_)
91 {
92 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failing test due to timeout\n");
93 return;
94 }
95 GNUNET_assert (NUM_PEERS == num_peers);
96 getchar();
97 op = GNUNET_TESTBED_overlay_connect (NULL,
98 &overlay_connect_status,
99 NULL,
100 peers_[0],
101 peers_[2]);
102}
103
104
105/**
106 * Main function
107 */
108int
109main (int argc, char **argv)
110{
111 struct GNUNET_CONFIGURATION_Handle *cfg;
112 char pwd[PATH_MAX];
113 char *dbfile;
114 uint64_t event_mask;
115
116 result = GNUNET_SYSERR;
117 event_mask = 0;
118 cfg = GNUNET_CONFIGURATION_create ();
119 GNUNET_assert (GNUNET_YES ==
120 GNUNET_CONFIGURATION_parse (cfg,
121 "test_testbed_underlay.conf.in"));
122 if (NULL == getcwd (pwd, PATH_MAX))
123 return 1;
124 GNUNET_assert (0 < GNUNET_asprintf (&dbfile, "%s/%s", pwd,
125 "test-underlay.sqlite"));
126 GNUNET_CONFIGURATION_set_value_string (cfg, "TESTBED-UNDERLAY","DBFILE", dbfile);
127 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_write
128 (cfg, "test_testbed_underlay.conf"));
129 GNUNET_CONFIGURATION_destroy (cfg);
130 cfg = NULL;
131 GNUNET_free (dbfile);
132 dbfile = NULL;
133 (void) GNUNET_TESTBED_test_run ("test_testbed_underlay",
134 "test_testbed_underlay.conf", NUM_PEERS,
135 event_mask, NULL, NULL,
136 &test_master, NULL);
137 (void) unlink ("test_testbed_underlay.conf");
138 if (GNUNET_OK != result)
139 return 1;
140 return 0;
141}
diff --git a/src/testbed/test_testbed_underlay.conf.in b/src/testbed/test_testbed_underlay.conf.in
new file mode 100644
index 000000000..647360ec1
--- /dev/null
+++ b/src/testbed/test_testbed_underlay.conf.in
@@ -0,0 +1,14 @@
1@INLINE@ test_testbed_api_template.conf
2
3[testbed]
4OVERLAY_TOPOLOGY = LINE
5
6[testbed-underlay]
7AUTOSTART = NO
8DBFILE = /will/be/overwritten/by/testcase
9
10[dv]
11AUTOSTART = NO
12
13[arm]
14DEFAULTSERVICES = core transport testbed-underlay
diff --git a/src/testbed/testbed.conf.in b/src/testbed/testbed.conf.in
index 79334c4cd..132480af0 100644
--- a/src/testbed/testbed.conf.in
+++ b/src/testbed/testbed.conf.in
@@ -100,3 +100,13 @@ HOSTNAME = localhost
100UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-testbed-barrier.sock 100UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-testbed-barrier.sock
101UNIX_MATCH_UID = YES 101UNIX_MATCH_UID = YES
102UNIX_MATCH_GID = YES 102UNIX_MATCH_GID = YES
103
104
105# This section is related to configuring underlay restrictions to simulate
106# connectivity restrictions of NAT boxes
107[testbed-underlay]
108AUTOSTART = NO
109BINARY = gnunet-daemon-testbed-underlay
110# The sqlite3 database file containing information about what underlay
111# restrictions to apply
112# DBFILE = \ No newline at end of file