aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-11-01 21:12:56 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-11-01 21:12:56 +0000
commit55966806a86ad5f28be24407648e0e707e8fef80 (patch)
treeafa04daf3e127d274bff5f06630a4140d6cd7307 /src/testbed
parent13361222d8b8d47611d67c240ae2329cdc999a7e (diff)
downloadgnunet-55966806a86ad5f28be24407648e0e707e8fef80.tar.gz
gnunet-55966806a86ad5f28be24407648e0e707e8fef80.zip
topology option support for GNUNET_TESTBED_run() via configuration
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/Makefile.am28
-rw-r--r--src/testbed/test_testbed_api.conf1
-rw-r--r--src/testbed/test_testbed_api_testbed_run.c29
-rw-r--r--src/testbed/test_testbed_api_testbed_run_topologyclique.conf80
-rw-r--r--src/testbed/test_testbed_api_testbed_run_topologyline.conf80
-rw-r--r--src/testbed/test_testbed_api_testbed_run_topologyrandom.conf81
-rw-r--r--src/testbed/testbed_api_testbed.c165
7 files changed, 446 insertions, 18 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am
index 6e76b0862..38985c82e 100644
--- a/src/testbed/Makefile.am
+++ b/src/testbed/Makefile.am
@@ -90,7 +90,10 @@ check_PROGRAMS = \
90 test_testbed_api_test \ 90 test_testbed_api_test \
91 test_gnunet_helper_testbed \ 91 test_gnunet_helper_testbed \
92 test_testbed_api_topology \ 92 test_testbed_api_topology \
93 test_testbed_api_topology_clique 93 test_testbed_api_topology_clique \
94 test_testbed_api_testbed_run_topologyrandom \
95 test_testbed_api_testbed_run_topologyline \
96 test_testbed_api_testbed_run_topologyclique
94 97
95if ENABLE_TEST_RUN 98if ENABLE_TEST_RUN
96 TESTS = \ 99 TESTS = \
@@ -104,7 +107,10 @@ if ENABLE_TEST_RUN
104 test_testbed_api_testbed_run \ 107 test_testbed_api_testbed_run \
105 test_testbed_api_test \ 108 test_testbed_api_test \
106 test_testbed_api_topology \ 109 test_testbed_api_topology \
107 test_testbed_api_topology_clique 110 test_testbed_api_topology_clique \
111 test_testbed_api_testbed_run_topologyrandom \
112 test_testbed_api_testbed_run_topologyline \
113 test_testbed_api_testbed_run_topologyclique
108endif 114endif
109 115
110test_testbed_api_hosts_SOURCES = \ 116test_testbed_api_hosts_SOURCES = \
@@ -178,6 +184,24 @@ test_gnunet_helper_testbed_LDADD = \
178 libgnunettestbed.la \ 184 libgnunettestbed.la \
179 -lz 185 -lz
180 186
187test_testbed_api_testbed_run_topologyrandom_SOURCES = \
188 test_testbed_api_testbed_run.c
189test_testbed_api_testbed_run_topologyrandom_LDADD = \
190 $(top_builddir)/src/util/libgnunetutil.la \
191 libgnunettestbed.la
192
193test_testbed_api_testbed_run_topologyline_SOURCES = \
194 test_testbed_api_testbed_run.c
195test_testbed_api_testbed_run_topologyline_LDADD = \
196 $(top_builddir)/src/util/libgnunetutil.la \
197 libgnunettestbed.la
198
199test_testbed_api_testbed_run_topologyclique_SOURCES = \
200 test_testbed_api_testbed_run.c
201test_testbed_api_testbed_run_topologyclique_LDADD = \
202 $(top_builddir)/src/util/libgnunetutil.la \
203 libgnunettestbed.la
204
181 205
182EXTRA_DIST = \ 206EXTRA_DIST = \
183 test_testbed_api.conf 207 test_testbed_api.conf
diff --git a/src/testbed/test_testbed_api.conf b/src/testbed/test_testbed_api.conf
index c094edee7..17fdba862 100644
--- a/src/testbed/test_testbed_api.conf
+++ b/src/testbed/test_testbed_api.conf
@@ -5,6 +5,7 @@ ACCEPT_FROM = 127.0.0.1;
5HOSTNAME = localhost 5HOSTNAME = localhost
6NEIGHBOUR_LIMIT = 100 6NEIGHBOUR_LIMIT = 100
7MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS = 10 7MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS = 10
8TOPOLOGY = RANDOM
8#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args 9#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
9 10
10[fs] 11[fs]
diff --git a/src/testbed/test_testbed_api_testbed_run.c b/src/testbed/test_testbed_api_testbed_run.c
index 16fdc1e2f..d39cae804 100644
--- a/src/testbed/test_testbed_api_testbed_run.c
+++ b/src/testbed/test_testbed_api_testbed_run.c
@@ -152,13 +152,11 @@ run (void *cls, char *const *args, const char *cfgfile,
152 event_mask = 0; 152 event_mask = 0;
153 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); 153 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
154 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); 154 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
155 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
156 event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);
157 GNUNET_TESTBED_run (NULL, config, NUM_PEERS, event_mask, &controller_event_cb, 155 GNUNET_TESTBED_run (NULL, config, NUM_PEERS, event_mask, &controller_event_cb,
158 NULL, &master_task, NULL); 156 NULL, &master_task, NULL);
159 abort_task = 157 abort_task =
160 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 158 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
161 (GNUNET_TIME_UNIT_SECONDS, 5), &do_abort, 159 (GNUNET_TIME_UNIT_SECONDS, 60), &do_abort,
162 NULL); 160 NULL);
163} 161}
164 162
@@ -169,22 +167,39 @@ run (void *cls, char *const *args, const char *cfgfile,
169int 167int
170main (int argc, char **argv) 168main (int argc, char **argv)
171{ 169{
172 int ret; 170 char *argv2[] = {
173
174 char *const argv2[] = {
175 "test_testbed_api_testbed_run", 171 "test_testbed_api_testbed_run",
176 "-c", "test_testbed_api.conf", 172 "-c", NULL,
177 NULL 173 NULL
178 }; 174 };
179 struct GNUNET_GETOPT_CommandLineOption options[] = { 175 struct GNUNET_GETOPT_CommandLineOption options[] = {
180 GNUNET_GETOPT_OPTION_END 176 GNUNET_GETOPT_OPTION_END
181 }; 177 };
178 char *testname;
179 char *config_filename;
180 int ret;
182 181
182 testname = rindex (argv[0], (int) '_');
183 testname++;
184 if (NULL == testname)
185 {
186 GNUNET_break (0);
187 return 1;
188 }
189 if (0 != strcmp ("run", testname))
190 {
191 GNUNET_asprintf (&config_filename,
192 "test_testbed_api_testbed_run_%s.conf", testname);
193 }
194 else
195 config_filename = GNUNET_strdup ("test_testbed_api.conf");
196 argv2[2] = config_filename;
183 result = GNUNET_SYSERR; 197 result = GNUNET_SYSERR;
184 ret = 198 ret =
185 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, 199 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
186 "test_testbed_api_testbed_run", "nohelp", options, 200 "test_testbed_api_testbed_run", "nohelp", options,
187 &run, NULL); 201 &run, NULL);
202 GNUNET_free (config_filename);
188 if ((GNUNET_OK != ret) || (GNUNET_OK != result)) 203 if ((GNUNET_OK != ret) || (GNUNET_OK != result))
189 return 1; 204 return 1;
190 return 0; 205 return 0;
diff --git a/src/testbed/test_testbed_api_testbed_run_topologyclique.conf b/src/testbed/test_testbed_api_testbed_run_topologyclique.conf
new file mode 100644
index 000000000..37fc7342d
--- /dev/null
+++ b/src/testbed/test_testbed_api_testbed_run_topologyclique.conf
@@ -0,0 +1,80 @@
1[testbed]
2AUTOSTART = NO
3PORT = 12113
4ACCEPT_FROM = 127.0.0.1;
5HOSTNAME = localhost
6NEIGHBOUR_LIMIT = 100
7MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS = 10
8OVERLAY_TOPOLOGY = CLIQUE
9#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
10
11[fs]
12AUTOSTART = NO
13
14[resolver]
15AUTOSTART = NO
16
17[mesh]
18AUTOSTART = NO
19
20[dht]
21AUTOSTART = NO
22
23[block]
24plugins = dht test
25
26[dhtcache]
27QUOTA = 1 MB
28DATABASE = sqlite
29
30[transport]
31PLUGINS = tcp
32DEBUG = NO
33ACCEPT_FROM6 = ::1;
34ACCEPT_FROM = 127.0.0.1;
35NEIGHBOUR_LIMIT = 50
36PORT = 12365
37
38[ats]
39WAN_QUOTA_OUT = 3932160
40WAN_QUOTA_IN = 3932160
41
42[core]
43PORT = 12092
44AUTOSTART = YES
45
46[arm]
47DEFAULTSERVICES = core transport
48PORT = 12366
49DEBUG = NO
50
51[transport-tcp]
52TIMEOUT = 300 s
53PORT = 12368
54
55[TESTING]
56NUM_PEERS = 5
57WEAKRANDOM = YES
58DEBUG = YES
59HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat
60MAX_CONCURRENT_SSH = 10
61USE_PROGRESSBARS = YES
62PEERGROUP_TIMEOUT = 2400 s
63
64[gnunetd]
65HOSTKEY = $SERVICEHOME/.hostkey
66
67[PATHS]
68SERVICEHOME = /tmp/test-testbed/
69
70[dns]
71AUTOSTART = NO
72
73[nse]
74AUTOSTART = NO
75
76[vpn]
77AUTOSTART = NO
78
79[nat]
80RETURN_LOCAL_ADDRESSES = YES
diff --git a/src/testbed/test_testbed_api_testbed_run_topologyline.conf b/src/testbed/test_testbed_api_testbed_run_topologyline.conf
new file mode 100644
index 000000000..2958f765c
--- /dev/null
+++ b/src/testbed/test_testbed_api_testbed_run_topologyline.conf
@@ -0,0 +1,80 @@
1[testbed]
2AUTOSTART = NO
3PORT = 12113
4ACCEPT_FROM = 127.0.0.1;
5HOSTNAME = localhost
6NEIGHBOUR_LIMIT = 100
7MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS = 10
8OVERLAY_TOPOLOGY = LINE
9#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
10
11[fs]
12AUTOSTART = NO
13
14[resolver]
15AUTOSTART = NO
16
17[mesh]
18AUTOSTART = NO
19
20[dht]
21AUTOSTART = NO
22
23[block]
24plugins = dht test
25
26[dhtcache]
27QUOTA = 1 MB
28DATABASE = sqlite
29
30[transport]
31PLUGINS = tcp
32DEBUG = NO
33ACCEPT_FROM6 = ::1;
34ACCEPT_FROM = 127.0.0.1;
35NEIGHBOUR_LIMIT = 50
36PORT = 12365
37
38[ats]
39WAN_QUOTA_OUT = 3932160
40WAN_QUOTA_IN = 3932160
41
42[core]
43PORT = 12092
44AUTOSTART = YES
45
46[arm]
47DEFAULTSERVICES = core transport
48PORT = 12366
49DEBUG = NO
50
51[transport-tcp]
52TIMEOUT = 300 s
53PORT = 12368
54
55[TESTING]
56NUM_PEERS = 5
57WEAKRANDOM = YES
58DEBUG = YES
59HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat
60MAX_CONCURRENT_SSH = 10
61USE_PROGRESSBARS = YES
62PEERGROUP_TIMEOUT = 2400 s
63
64[gnunetd]
65HOSTKEY = $SERVICEHOME/.hostkey
66
67[PATHS]
68SERVICEHOME = /tmp/test-testbed/
69
70[dns]
71AUTOSTART = NO
72
73[nse]
74AUTOSTART = NO
75
76[vpn]
77AUTOSTART = NO
78
79[nat]
80RETURN_LOCAL_ADDRESSES = YES
diff --git a/src/testbed/test_testbed_api_testbed_run_topologyrandom.conf b/src/testbed/test_testbed_api_testbed_run_topologyrandom.conf
new file mode 100644
index 000000000..3c7980682
--- /dev/null
+++ b/src/testbed/test_testbed_api_testbed_run_topologyrandom.conf
@@ -0,0 +1,81 @@
1[testbed]
2AUTOSTART = NO
3PORT = 12113
4ACCEPT_FROM = 127.0.0.1;
5HOSTNAME = localhost
6NEIGHBOUR_LIMIT = 100
7MAX_PARALLEL_OVERLAY_CONNECT_OPERATIONS = 10
8OVERLAY_TOPOLOGY = RANDOM
9OVERLAY_RANDOM_LINKS = 5
10#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
11
12[fs]
13AUTOSTART = NO
14
15[resolver]
16AUTOSTART = NO
17
18[mesh]
19AUTOSTART = NO
20
21[dht]
22AUTOSTART = NO
23
24[block]
25plugins = dht test
26
27[dhtcache]
28QUOTA = 1 MB
29DATABASE = sqlite
30
31[transport]
32PLUGINS = tcp
33DEBUG = NO
34ACCEPT_FROM6 = ::1;
35ACCEPT_FROM = 127.0.0.1;
36NEIGHBOUR_LIMIT = 50
37PORT = 12365
38
39[ats]
40WAN_QUOTA_OUT = 3932160
41WAN_QUOTA_IN = 3932160
42
43[core]
44PORT = 12092
45AUTOSTART = YES
46
47[arm]
48DEFAULTSERVICES = core transport
49PORT = 12366
50DEBUG = NO
51
52[transport-tcp]
53TIMEOUT = 300 s
54PORT = 12368
55
56[TESTING]
57NUM_PEERS = 5
58WEAKRANDOM = YES
59DEBUG = YES
60HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat
61MAX_CONCURRENT_SSH = 10
62USE_PROGRESSBARS = YES
63PEERGROUP_TIMEOUT = 2400 s
64
65[gnunetd]
66HOSTKEY = $SERVICEHOME/.hostkey
67
68[PATHS]
69SERVICEHOME = /tmp/test-testbed/
70
71[dns]
72AUTOSTART = NO
73
74[nse]
75AUTOSTART = NO
76
77[vpn]
78AUTOSTART = NO
79
80[nat]
81RETURN_LOCAL_ADDRESSES = YES
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index a8f12f361..0987d9eb5 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -87,9 +87,11 @@ enum State
87 RC_INIT = 0, 87 RC_INIT = 0,
88 88
89 /** 89 /**
90 * Peers have been started 90 * The testbed run is ready and the master callback can be called now. At this
91 * time the peers are all started and if a topology is provided in the
92 * configuration the topology would have been attempted
91 */ 93 */
92 RC_PEERS_STARTED, 94 RC_READY,
93 95
94 /** 96 /**
95 * Peers are stopped 97 * Peers are stopped
@@ -159,6 +161,12 @@ struct RunContext
159 struct GNUNET_TESTBED_Peer **peers; 161 struct GNUNET_TESTBED_Peer **peers;
160 162
161 /** 163 /**
164 * The topology generation operation. Will be null if no topology is set in
165 * the configuration
166 */
167 struct GNUNET_TESTBED_Operation *topology_operation;
168
169 /**
162 * The event mask for the controller 170 * The event mask for the controller
163 */ 171 */
164 uint64_t event_mask; 172 uint64_t event_mask;
@@ -169,6 +177,11 @@ struct RunContext
169 enum State state; 177 enum State state;
170 178
171 /** 179 /**
180 * The topology which has to be achieved with the peers started in this context
181 */
182 enum GNUNET_TESTBED_TopologyOption topology;
183
184 /**
172 * Current peer count for an operation; Set this to 0 and increment for each 185 * Current peer count for an operation; Set this to 0 and increment for each
173 * successful operation on a peer 186 * successful operation on a peer
174 */ 187 */
@@ -179,6 +192,17 @@ struct RunContext
179 */ 192 */
180 unsigned int num_peers; 193 unsigned int num_peers;
181 194
195 /**
196 * counter to count overlay connect attempts. This counter includes both
197 * successful and failed overlay connects
198 */
199 unsigned int oc_count;
200
201 /**
202 * Expected overlay connects. Should be zero if no topology is relavant
203 */
204 unsigned int num_oc;
205
182}; 206};
183 207
184 208
@@ -281,6 +305,28 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
281 305
282 306
283/** 307/**
308 * Task to call master task
309 *
310 * @param cls the run context
311 * @param tc the task context
312 */
313static void
314call_master (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
315{
316 struct RunContext *rc = cls;
317
318 if (NULL != rc->topology_operation)
319 {
320 GNUNET_TESTBED_operation_done (rc->topology_operation);
321 rc->topology_operation = NULL;
322 }
323 if (NULL != rc->master)
324 GNUNET_SCHEDULER_add_continuation (rc->master, rc->master_cls,
325 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
326}
327
328
329/**
284 * Signature of the event handler function called by the 330 * Signature of the event handler function called by the
285 * respective event controller. 331 * respective event controller.
286 * 332 *
@@ -294,7 +340,25 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
294 struct DLLOperation *dll_op; 340 struct DLLOperation *dll_op;
295 unsigned int peer_id; 341 unsigned int peer_id;
296 342
297 343 if (NULL != rc->topology_operation)
344 {
345 switch (event->type)
346 {
347 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
348 case GNUNET_TESTBED_ET_CONNECT:
349 rc->oc_count++;
350 break;
351 default:
352 GNUNET_assert (0);
353 }
354 if (rc->oc_count == rc->num_oc)
355 {
356 rc->state = RC_READY;
357 GNUNET_SCHEDULER_add_continuation (&call_master, rc,
358 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
359 }
360 return;
361 }
298 if ((RC_INIT != rc->state) && 362 if ((RC_INIT != rc->state) &&
299 ((GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type) || 363 ((GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type) ||
300 (GNUNET_TESTBED_ET_PEER_STOP == event->type))) 364 (GNUNET_TESTBED_ET_PEER_STOP == event->type)))
@@ -318,7 +382,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
318 return; 382 return;
319 switch (rc->state) 383 switch (rc->state)
320 { 384 {
321 case RC_PEERS_STARTED: 385 case RC_READY:
322 rc->state = RC_PEERS_STOPPED; 386 rc->state = RC_PEERS_STOPPED;
323 rc->peer_count = 0; 387 rc->peer_count = 0;
324 for (peer_id = 0; peer_id < rc->num_peers; peer_id++) 388 for (peer_id = 0; peer_id < rc->num_peers; peer_id++)
@@ -359,10 +423,32 @@ call_cc:
359 if (rc->peer_count < rc->num_peers) 423 if (rc->peer_count < rc->num_peers)
360 return; 424 return;
361 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers started successfully\n"); 425 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers started successfully\n");
362 rc->state = RC_PEERS_STARTED; 426 if (GNUNET_TESTBED_TOPOLOGY_OPTION_END != rc->topology)
363 if (NULL != rc->master) 427 {
364 GNUNET_SCHEDULER_add_continuation (rc->master, rc->master_cls, 428 if (GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI == rc->topology)
365 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 429 rc->topology_operation =
430 GNUNET_TESTBED_overlay_configure_topology (dll_op,
431 rc->num_peers,
432 rc->peers,
433 rc->topology,
434 rc->num_oc,
435 GNUNET_TESTBED_TOPOLOGY_OPTION_END);
436 else
437 rc->topology_operation =
438 GNUNET_TESTBED_overlay_configure_topology (dll_op,
439 rc->num_peers,
440 rc->peers,
441 rc->topology,
442 GNUNET_TESTBED_TOPOLOGY_OPTION_END);
443 if (NULL == rc->topology_operation)
444 LOG (GNUNET_ERROR_TYPE_WARNING,
445 "Not generating topology. Check number of peers\n");
446 else
447 return;
448 }
449 rc->state = RC_READY;
450 GNUNET_SCHEDULER_add_continuation (&call_master, rc,
451 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
366} 452}
367 453
368 454
@@ -393,6 +479,8 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
393 event_mask = rc->event_mask; 479 event_mask = rc->event_mask;
394 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); 480 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
395 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); 481 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
482 if (rc->topology < GNUNET_TESTBED_TOPOLOGY_OPTION_END)
483 event_mask |= GNUNET_TESTBED_ET_CONNECT;
396 rc->c = 484 rc->c =
397 GNUNET_TESTBED_controller_connect (cfg, rc->h, event_mask, &event_cb, rc); 485 GNUNET_TESTBED_controller_connect (cfg, rc->h, event_mask, &event_cb, rc);
398 rc->peers = 486 rc->peers =
@@ -427,6 +515,13 @@ shutdown_run_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
427 { 515 {
428 if (NULL != rc->peers) 516 if (NULL != rc->peers)
429 { 517 {
518 if (NULL != rc->topology_operation)
519 {
520 GNUNET_TESTBED_operation_done (rc->topology_operation);
521 rc->topology_operation = NULL;
522 }
523 if (RC_INIT == rc->state)
524 rc->state = RC_READY; /* Even though we haven't called the master callback */
430 rc->peer_count = 0; 525 rc->peer_count = 0;
431 /* Check if some peers are stopped */ 526 /* Check if some peers are stopped */
432 for (peer = 0; peer < rc->num_peers; peer++) 527 for (peer = 0; peer < rc->num_peers; peer++)
@@ -506,6 +601,8 @@ GNUNET_TESTBED_run (const char *host_filename,
506 GNUNET_SCHEDULER_Task master, void *master_cls) 601 GNUNET_SCHEDULER_Task master, void *master_cls)
507{ 602{
508 struct RunContext *rc; 603 struct RunContext *rc;
604 char *topology;
605 unsigned long long random_links;
509 606
510 GNUNET_break (NULL == host_filename); /* Currently we do not support host 607 GNUNET_break (NULL == host_filename); /* Currently we do not support host
511 * files */ 608 * files */
@@ -527,6 +624,49 @@ GNUNET_TESTBED_run (const char *host_filename,
527 rc->master = master; 624 rc->master = master;
528 rc->master_cls = master_cls; 625 rc->master_cls = master_cls;
529 rc->state = RC_INIT; 626 rc->state = RC_INIT;
627 rc->topology = GNUNET_TESTBED_TOPOLOGY_OPTION_END;
628 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, "testbed",
629 "OVERLAY_TOPOLOGY",
630 &topology))
631 {
632 if (0 == strcmp (topology, "RANDOM"))
633 {
634 rc->topology = GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI;
635 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
636 "OVERLAY_RANDOM_LINKS",
637 &random_links))
638 {
639 /* OVERLAY option RANDOM requires OVERLAY_RANDOM_LINKS option to */
640 /* be set to the number of random links to be established */
641 GNUNET_break (0);
642 GNUNET_free (rc);
643 GNUNET_free (topology);
644 return;
645 }
646 if (random_links > UINT32_MAX)
647 {
648 GNUNET_break (0); /* Too big number */
649 GNUNET_free (rc);
650 GNUNET_free (topology);
651 return;
652 }
653 rc->num_oc = (unsigned int) random_links;
654 }
655 else if (0 == strcasecmp (topology, "CLIQUE"))
656 {
657 rc->topology = GNUNET_TESTBED_TOPOLOGY_CLIQUE;
658 rc->num_oc = num_peers * (num_peers - 1);
659 }
660 else if (0 == strcasecmp (topology, "LINE"))
661 {
662 rc->topology = GNUNET_TESTBED_TOPOLOGY_LINE;
663 rc->num_oc = num_peers - 1;
664 }
665 else
666 LOG (GNUNET_ERROR_TYPE_WARNING,
667 "Unknown topology %s given in configuration\n", topology);
668 GNUNET_free (topology);
669 }
530 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 670 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
531 &shutdown_run_task, rc); 671 &shutdown_run_task, rc);
532} 672}
@@ -558,6 +698,7 @@ GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller,
558 enum GNUNET_TESTBED_TopologyOption underlay_topology, 698 enum GNUNET_TESTBED_TopologyOption underlay_topology,
559 va_list va) 699 va_list va)
560{ 700{
701 GNUNET_assert (underlay_topology < GNUNET_TESTBED_TOPOLOGY_OPTION_END);
561 GNUNET_break (0); 702 GNUNET_break (0);
562 return NULL; 703 return NULL;
563} 704}
@@ -588,7 +729,13 @@ GNUNET_TESTBED_create (struct GNUNET_TESTBED_Controller *controller,
588 enum GNUNET_TESTBED_TopologyOption underlay_topology, 729 enum GNUNET_TESTBED_TopologyOption underlay_topology,
589 ...) 730 ...)
590{ 731{
591 GNUNET_break (0); 732 struct GNUNET_TESTBED_Testbed *testbed;
733 va_list vargs;
734
735 va_start (vargs, underlay_topology);
736 testbed = GNUNET_TESTBED_create_va (controller, num_hosts, hosts, num_peers,
737 peer_cfg, underlay_topology, vargs);
738 va_end (vargs);
592 return NULL; 739 return NULL;
593} 740}
594 741