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)
- 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 b8e00f90ca..823ddaa836 100644
--- a/src/testbed/Makefile.am
+++ b/src/testbed/Makefile.am
@@ -19,6 +19,7 @@ pkgcfg_DATA = \
if HAVE_SQLITE
underlay_daemon = gnunet-daemon-testbed-underlay
generate_underlay = generate-underlay-topology
+ underlay_testcases = test_testbed_underlay
endif
libexec_PROGRAMS = \
@@ -177,7 +178,8 @@ check_PROGRAMS = \
test_testbed_api_testbed_run_waitforever \
test_testbed_api_statistics \
gnunet-service-test-barriers \
- test_testbed_api_barriers
+ test_testbed_api_barriers \
+ $(underlay_testcases)
if ENABLE_TEST_RUN
TESTS = \
@@ -394,6 +396,12 @@ gnunet_service_test_barriers_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
libgnunettestbed.la
+test_testbed_underlay_SOURCES = \
+ test_testbed_underlay.c
+test_testbed_underlay_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ libgnunettestbed.la
+
EXTRA_DIST = \
test_testbed_api.conf \
test_testbed_api_test_timeout.conf \
@@ -411,4 +419,6 @@ EXTRA_DIST = \
test_testbed_api_barriers.conf.in \
overlay_topology.txt \
sample_hosts.txt \
- sample.job
+ sample.job \
+ test_testbed_underlay.conf.in \
+ test-underlay.sqlite
diff --git a/src/testbed/test-underlay.sqlite b/src/testbed/test-underlay.sqlite
new file mode 100644
index 0000000000..46f48d9dbf
--- /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 0000000000..6b66a5f7a2
--- /dev/null
+++ b/src/testbed/test_testbed_underlay.c
@@ -0,0 +1,141 @@
+/*
+ This file is part of GNUnet
+ (C) 2008--2013 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file testbed/test_testbed_underlay.c
+ * @brief testcase binary for testing testbed underlay restrictions
+ * @author Sree Harsha Totakura <sreeharsha@totakura.in>
+ */
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_testbed_service.h"
+
+
+/**
+ * Number of peers we start in this test case
+ */
+#define NUM_PEERS 3
+
+/**
+ * Result of this test case
+ */
+static int result;
+
+static struct GNUNET_TESTBED_Operation *op;
+
+
+/**
+ * Callback to be called when an operation is completed
+ *
+ * @param cls the callback closure from functions generating an operation
+ * @param op the operation that has been finished
+ * @param emsg error message in case the operation has failed; will be NULL if
+ * operation has executed successfully.
+ */
+static void
+overlay_connect_status (void *cls,
+ struct GNUNET_TESTBED_Operation *op,
+ const char *emsg)
+{
+ GNUNET_TESTBED_operation_done (op);
+ op = NULL;
+ if (NULL == emsg)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Peers 0 and 2 should not get connected\n");
+ else
+ result = GNUNET_OK;
+ GNUNET_SCHEDULER_shutdown ();
+}
+
+
+
+/**
+ * Signature of a main function for a testcase.
+ *
+ * @param cls closure
+ * @param h the run handle
+ * @param num_peers number of peers in 'peers'
+ * @param peers_ handle to peers run in the testbed
+ * @param links_succeeded the number of overlay link connection attempts that
+ * succeeded
+ * @param links_failed the number of overlay link connection attempts that
+ * failed
+ */
+static void
+test_master (void *cls,
+ struct GNUNET_TESTBED_RunHandle *h,
+ unsigned int num_peers,
+ struct GNUNET_TESTBED_Peer **peers_,
+ unsigned int links_succeeded,
+ unsigned int links_failed)
+{
+ GNUNET_assert (NULL == cls);
+ if (NULL == peers_)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failing test due to timeout\n");
+ return;
+ }
+ GNUNET_assert (NUM_PEERS == num_peers);
+ getchar();
+ op = GNUNET_TESTBED_overlay_connect (NULL,
+ &overlay_connect_status,
+ NULL,
+ peers_[0],
+ peers_[2]);
+}
+
+
+/**
+ * Main function
+ */
+int
+main (int argc, char **argv)
+{
+ struct GNUNET_CONFIGURATION_Handle *cfg;
+ char pwd[PATH_MAX];
+ char *dbfile;
+ uint64_t event_mask;
+
+ result = GNUNET_SYSERR;
+ event_mask = 0;
+ cfg = GNUNET_CONFIGURATION_create ();
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONFIGURATION_parse (cfg,
+ "test_testbed_underlay.conf.in"));
+ if (NULL == getcwd (pwd, PATH_MAX))
+ return 1;
+ GNUNET_assert (0 < GNUNET_asprintf (&dbfile, "%s/%s", pwd,
+ "test-underlay.sqlite"));
+ GNUNET_CONFIGURATION_set_value_string (cfg, "TESTBED-UNDERLAY","DBFILE", dbfile);
+ GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_write
+ (cfg, "test_testbed_underlay.conf"));
+ GNUNET_CONFIGURATION_destroy (cfg);
+ cfg = NULL;
+ GNUNET_free (dbfile);
+ dbfile = NULL;
+ (void) GNUNET_TESTBED_test_run ("test_testbed_underlay",
+ "test_testbed_underlay.conf", NUM_PEERS,
+ event_mask, NULL, NULL,
+ &test_master, NULL);
+ (void) unlink ("test_testbed_underlay.conf");
+ if (GNUNET_OK != result)
+ return 1;
+ return 0;
+}
diff --git a/src/testbed/test_testbed_underlay.conf.in b/src/testbed/test_testbed_underlay.conf.in
new file mode 100644
index 0000000000..647360ec14
--- /dev/null
+++ b/src/testbed/test_testbed_underlay.conf.in
@@ -0,0 +1,14 @@
+@INLINE@ test_testbed_api_template.conf
+
+[testbed]
+OVERLAY_TOPOLOGY = LINE
+
+[testbed-underlay]
+AUTOSTART = NO
+DBFILE = /will/be/overwritten/by/testcase
+
+[dv]
+AUTOSTART = NO
+
+[arm]
+DEFAULTSERVICES = core transport testbed-underlay
diff --git a/src/testbed/testbed.conf.in b/src/testbed/testbed.conf.in
index 79334c4cd4..132480af08 100644
--- a/src/testbed/testbed.conf.in
+++ b/src/testbed/testbed.conf.in
@@ -100,3 +100,13 @@ HOSTNAME = localhost
UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-testbed-barrier.sock
UNIX_MATCH_UID = YES
UNIX_MATCH_GID = YES
+
+
+# This section is related to configuring underlay restrictions to simulate
+# connectivity restrictions of NAT boxes
+[testbed-underlay]
+AUTOSTART = NO
+BINARY = gnunet-daemon-testbed-underlay
+# The sqlite3 database file containing information about what underlay
+# restrictions to apply
+# DBFILE = \ No newline at end of file