aboutsummaryrefslogtreecommitdiff
path: root/src/ats/perf_ats.c
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 /src/ats/perf_ats.c
parentc61d3be2409ff04f763fbd5729c959171fdf8ba7 (diff)
downloadgnunet-8668628b998f2f40e8466d4d6d92faf1617abe08.tar.gz
gnunet-8668628b998f2f40e8466d4d6d92faf1617abe08.zip
add testbed
disable all connections in conf
Diffstat (limited to 'src/ats/perf_ats.c')
-rw-r--r--src/ats/perf_ats.c92
1 files changed, 72 insertions, 20 deletions
diff --git a/src/ats/perf_ats.c b/src/ats/perf_ats.c
index 5072c30a5..c131025bd 100644
--- a/src/ats/perf_ats.c
+++ b/src/ats/perf_ats.c
@@ -25,19 +25,71 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testbed_service.h"
28 29
30#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
29#define TESTNAME_PREFIX "perf_ats_" 31#define TESTNAME_PREFIX "perf_ats_"
30 32
31static int ret; 33
34/**
35 * Shutdown task
36 */
37static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
38
39static int result;
32static char *solver; 40static char *solver;
33static char *preference; 41static char *preference;
34 42
43/**
44 * Shutdown nicely
45 *
46 * @param cls NULL
47 * @param tc the task context
48 */
35static void 49static void
36check (void *cls, char *const *args, const char *cfgfile, 50do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
37 const struct GNUNET_CONFIGURATION_Handle *cfg) 51{
52 shutdown_task = GNUNET_SCHEDULER_NO_TASK;
53
54 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n"));
55
56
57 GNUNET_SCHEDULER_shutdown();
58}
59
60/**
61 * Controller event callback
62 *
63 * @param cls NULL
64 * @param event the controller event
65 */
66static void
67controller_event_cb (void *cls,
68 const struct GNUNET_TESTBED_EventInformation *event)
69{
70
71}
72
73/**
74 * Signature of a main function for a testcase.
75 *
76 * @param cls closure
77 * @param num_peers number of peers in 'peers'
78 * @param peers_ handle to peers run in the testbed
79 * @param links_succeeded the number of overlay link connection attempts that
80 * succeeded
81 * @param links_failed the number of overlay link connection attempts that
82 * failed
83 */
84static void
85test_master (void *cls, unsigned int num_peers,
86 struct GNUNET_TESTBED_Peer **peers_,
87 unsigned int links_succeeded,
88 unsigned int links_failed)
38{ 89{
39 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Benchmarking solver `%s' on preference `%s'\n"), solver, preference); 90 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Benchmarking solver `%s' on preference `%s'\n"), solver, preference);
40 ret = 0; 91
92 shutdown_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &do_shutdown, NULL);
41} 93}
42 94
43 95
@@ -46,13 +98,10 @@ main (int argc, char *argv[])
46{ 98{
47 char *tmp; 99 char *tmp;
48 char *tmp_sep; 100 char *tmp_sep;
101 char *test_name;
49 char *conf_name; 102 char *conf_name;
50 103
51 ret = 1; 104 result = 1;
52
53 static struct GNUNET_GETOPT_CommandLineOption options[] = {
54 GNUNET_GETOPT_OPTION_END
55 };
56 105
57 /* figure out testname */ 106 /* figure out testname */
58 tmp = strstr (argv[0], TESTNAME_PREFIX); 107 tmp = strstr (argv[0], TESTNAME_PREFIX);
@@ -74,22 +123,25 @@ main (int argc, char *argv[])
74 preference = GNUNET_strdup(tmp_sep + 1); 123 preference = GNUNET_strdup(tmp_sep + 1);
75 124
76 GNUNET_asprintf(&conf_name, "%s%s_%s.conf", TESTNAME_PREFIX, solver, preference); 125 GNUNET_asprintf(&conf_name, "%s%s_%s.conf", TESTNAME_PREFIX, solver, preference);
77 126 GNUNET_asprintf(&test_name, "%s%s_%s", TESTNAME_PREFIX, solver, preference);
78 char *argv2[] = { "perf_ats", 127
79 "-c", 128 /* Start topology */
80 conf_name, 129 uint64_t event_mask;
81 "-L", "WARNING", 130 result = GNUNET_SYSERR;
82 NULL 131 event_mask = 0;
83 }; 132 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
84 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, 133 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
85 "perf_ats", "nohelp", options, 134 (void) GNUNET_TESTBED_test_run (test_name,
86 &check, NULL); 135 conf_name, 5,
136 event_mask, &controller_event_cb, NULL,
137 &test_master, NULL);
87 138
88 GNUNET_free (solver); 139 GNUNET_free (solver);
89 GNUNET_free (preference); 140 GNUNET_free (preference);
90 GNUNET_free (conf_name); 141 GNUNET_free (conf_name);
142 GNUNET_free (test_name);
91 143
92 return ret; 144 return result;
93} 145}
94 146
95/* end of file perf_ats.c */ 147/* end of file perf_ats.c */