aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-08-05 14:26:28 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-08-05 14:26:28 +0000
commit8668628b998f2f40e8466d4d6d92faf1617abe08 (patch)
tree95629051cac46451e827ee073e606b6b0a2d60f0
parentc61d3be2409ff04f763fbd5729c959171fdf8ba7 (diff)
add testbed
disable all connections in conf
-rw-r--r--src/ats/Makefile.am7
-rw-r--r--src/ats/perf_ats.c92
-rw-r--r--src/ats/perf_ats_simplistic_bandwidth.conf9
-rw-r--r--src/ats/perf_ats_simplistic_delay.conf8
4 files changed, 93 insertions, 23 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am
index 40450d7f08..63593f7c09 100644
--- a/src/ats/Makefile.am
+++ b/src/ats/Makefile.am
@@ -252,14 +252,15 @@ perf_ats_simplistic_bandwidth_SOURCES = \
perf_ats.c
perf_ats_simplistic_bandwidth_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/ats/libgnunetats.la
+ $(top_builddir)/src/ats/libgnunetats.la \
+ $(top_builddir)/src/testbed/libgnunettestbed.la
perf_ats_simplistic_delay_SOURCES = \
perf_ats.c
perf_ats_simplistic_delay_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/ats/libgnunetats.la
-
+ $(top_builddir)/src/ats/libgnunetats.la \
+ $(top_builddir)/src/testbed/libgnunettestbed.la
EXTRA_DIST = \
ats.h \
diff --git a/src/ats/perf_ats.c b/src/ats/perf_ats.c
index 5072c30a54..c131025bd9 100644
--- a/src/ats/perf_ats.c
+++ b/src/ats/perf_ats.c
@@ -25,19 +25,71 @@
*/
#include "platform.h"
#include "gnunet_util_lib.h"
+#include "gnunet_testbed_service.h"
+#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
#define TESTNAME_PREFIX "perf_ats_"
-static int ret;
+
+/**
+ * Shutdown task
+ */
+static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
+
+static int result;
static char *solver;
static char *preference;
+/**
+ * Shutdown nicely
+ *
+ * @param cls NULL
+ * @param tc the task context
+ */
static void
-check (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ shutdown_task = GNUNET_SCHEDULER_NO_TASK;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n"));
+
+
+ GNUNET_SCHEDULER_shutdown();
+}
+
+/**
+ * Controller event callback
+ *
+ * @param cls NULL
+ * @param event the controller event
+ */
+static void
+controller_event_cb (void *cls,
+ const struct GNUNET_TESTBED_EventInformation *event)
+{
+
+}
+
+/**
+ * Signature of a main function for a testcase.
+ *
+ * @param cls closure
+ * @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, unsigned int num_peers,
+ struct GNUNET_TESTBED_Peer **peers_,
+ unsigned int links_succeeded,
+ unsigned int links_failed)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Benchmarking solver `%s' on preference `%s'\n"), solver, preference);
- ret = 0;
+
+ shutdown_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &do_shutdown, NULL);
}
@@ -46,13 +98,10 @@ main (int argc, char *argv[])
{
char *tmp;
char *tmp_sep;
+ char *test_name;
char *conf_name;
- ret = 1;
-
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
+ result = 1;
/* figure out testname */
tmp = strstr (argv[0], TESTNAME_PREFIX);
@@ -74,22 +123,25 @@ main (int argc, char *argv[])
preference = GNUNET_strdup(tmp_sep + 1);
GNUNET_asprintf(&conf_name, "%s%s_%s.conf", TESTNAME_PREFIX, solver, preference);
-
- char *argv2[] = { "perf_ats",
- "-c",
- conf_name,
- "-L", "WARNING",
- NULL
- };
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "perf_ats", "nohelp", options,
- &check, NULL);
+ GNUNET_asprintf(&test_name, "%s%s_%s", TESTNAME_PREFIX, solver, preference);
+
+ /* Start topology */
+ uint64_t event_mask;
+ result = GNUNET_SYSERR;
+ event_mask = 0;
+ event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
+ event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
+ (void) GNUNET_TESTBED_test_run (test_name,
+ conf_name, 5,
+ event_mask, &controller_event_cb, NULL,
+ &test_master, NULL);
GNUNET_free (solver);
GNUNET_free (preference);
GNUNET_free (conf_name);
+ GNUNET_free (test_name);
- return ret;
+ return result;
}
/* end of file perf_ats.c */
diff --git a/src/ats/perf_ats_simplistic_bandwidth.conf b/src/ats/perf_ats_simplistic_bandwidth.conf
index e69de29bb2..4d13e54447 100644
--- a/src/ats/perf_ats_simplistic_bandwidth.conf
+++ b/src/ats/perf_ats_simplistic_bandwidth.conf
@@ -0,0 +1,9 @@
+[hostlist]
+SERVERS =
+
+[transport-udp]
+BROADCAST = NO
+
+[peerinfo]
+USE_INCLUDED_HELLOS = NO
+
diff --git a/src/ats/perf_ats_simplistic_delay.conf b/src/ats/perf_ats_simplistic_delay.conf
index e69de29bb2..a5127d25fb 100644
--- a/src/ats/perf_ats_simplistic_delay.conf
+++ b/src/ats/perf_ats_simplistic_delay.conf
@@ -0,0 +1,8 @@
+[hostlist]
+SERVERS =
+
+[transport-udp]
+BROADCAST = NO
+
+[peerinfo]
+USE_INCLUDED_HELLOS = NO