diff options
Diffstat (limited to 'src/testbed/test_testbed_api_2peers_1controller.c')
-rw-r--r-- | src/testbed/test_testbed_api_2peers_1controller.c | 391 |
1 files changed, 197 insertions, 194 deletions
diff --git a/src/testbed/test_testbed_api_2peers_1controller.c b/src/testbed/test_testbed_api_2peers_1controller.c index 23d9823f5..de56ec88a 100644 --- a/src/testbed/test_testbed_api_2peers_1controller.c +++ b/src/testbed/test_testbed_api_2peers_1controller.c | |||
@@ -35,18 +35,19 @@ | |||
35 | * Generic logging shortcut | 35 | * Generic logging shortcut |
36 | */ | 36 | */ |
37 | #define LOG(kind, ...) \ | 37 | #define LOG(kind, ...) \ |
38 | GNUNET_log(kind, __VA_ARGS__) | 38 | GNUNET_log (kind, __VA_ARGS__) |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Relative time seconds shorthand | 41 | * Relative time seconds shorthand |
42 | */ | 42 | */ |
43 | #define TIME_REL_SECS(sec) \ | 43 | #define TIME_REL_SECS(sec) \ |
44 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, sec) | 44 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec) |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Peer context | 47 | * Peer context |
48 | */ | 48 | */ |
49 | struct PeerContext { | 49 | struct PeerContext |
50 | { | ||
50 | /** | 51 | /** |
51 | * The peer handle | 52 | * The peer handle |
52 | */ | 53 | */ |
@@ -111,17 +112,18 @@ static struct GNUNET_TESTBED_Operation *common_operation; | |||
111 | /** | 112 | /** |
112 | * Abort task identifier | 113 | * Abort task identifier |
113 | */ | 114 | */ |
114 | static struct GNUNET_SCHEDULER_Task * abort_task; | 115 | static struct GNUNET_SCHEDULER_Task *abort_task; |
115 | 116 | ||
116 | /** | 117 | /** |
117 | * Delayed connect job identifier | 118 | * Delayed connect job identifier |
118 | */ | 119 | */ |
119 | static struct GNUNET_SCHEDULER_Task * delayed_connect_task; | 120 | static struct GNUNET_SCHEDULER_Task *delayed_connect_task; |
120 | 121 | ||
121 | /** | 122 | /** |
122 | * Different stages in testing | 123 | * Different stages in testing |
123 | */ | 124 | */ |
124 | enum Stage { | 125 | enum Stage |
126 | { | ||
125 | /** | 127 | /** |
126 | * Initial stage | 128 | * Initial stage |
127 | */ | 129 | */ |
@@ -168,15 +170,15 @@ static enum Stage result; | |||
168 | * shortcut to exit during failure | 170 | * shortcut to exit during failure |
169 | */ | 171 | */ |
170 | #define FAIL_TEST(cond) do { \ | 172 | #define FAIL_TEST(cond) do { \ |
171 | if (!(cond)) { \ | 173 | if (! (cond)) { \ |
172 | GNUNET_break(0); \ | 174 | GNUNET_break (0); \ |
173 | if (NULL != abort_task) \ | 175 | if (NULL != abort_task) \ |
174 | GNUNET_SCHEDULER_cancel (abort_task); \ | 176 | GNUNET_SCHEDULER_cancel (abort_task); \ |
175 | abort_task = NULL; \ | 177 | abort_task = NULL; \ |
176 | GNUNET_SCHEDULER_add_now(do_shutdown, NULL); \ | 178 | GNUNET_SCHEDULER_add_now (do_shutdown, NULL); \ |
177 | return; \ | 179 | return; \ |
178 | } \ | 180 | } \ |
179 | } while (0) | 181 | } while (0) |
180 | 182 | ||
181 | 183 | ||
182 | /** | 184 | /** |
@@ -185,20 +187,20 @@ static enum Stage result; | |||
185 | * @param cls NULL | 187 | * @param cls NULL |
186 | */ | 188 | */ |
187 | static void | 189 | static void |
188 | do_shutdown(void *cls) | 190 | do_shutdown (void *cls) |
189 | { | 191 | { |
190 | if (NULL != abort_task) | 192 | if (NULL != abort_task) |
191 | GNUNET_SCHEDULER_cancel(abort_task); | 193 | GNUNET_SCHEDULER_cancel (abort_task); |
192 | if (NULL != delayed_connect_task) | 194 | if (NULL != delayed_connect_task) |
193 | GNUNET_SCHEDULER_cancel(delayed_connect_task); | 195 | GNUNET_SCHEDULER_cancel (delayed_connect_task); |
194 | if (NULL != reg_handle) | 196 | if (NULL != reg_handle) |
195 | GNUNET_TESTBED_cancel_registration(reg_handle); | 197 | GNUNET_TESTBED_cancel_registration (reg_handle); |
196 | GNUNET_TESTBED_controller_disconnect(controller); | 198 | GNUNET_TESTBED_controller_disconnect (controller); |
197 | GNUNET_CONFIGURATION_destroy(cfg); | 199 | GNUNET_CONFIGURATION_destroy (cfg); |
198 | if (NULL != cp) | 200 | if (NULL != cp) |
199 | GNUNET_TESTBED_controller_stop(cp); | 201 | GNUNET_TESTBED_controller_stop (cp); |
200 | GNUNET_TESTBED_host_destroy(neighbour); | 202 | GNUNET_TESTBED_host_destroy (neighbour); |
201 | GNUNET_TESTBED_host_destroy(host); | 203 | GNUNET_TESTBED_host_destroy (host); |
202 | } | 204 | } |
203 | 205 | ||
204 | 206 | ||
@@ -208,11 +210,11 @@ do_shutdown(void *cls) | |||
208 | * @param cls NULL | 210 | * @param cls NULL |
209 | */ | 211 | */ |
210 | static void | 212 | static void |
211 | do_abort(void *cls) | 213 | do_abort (void *cls) |
212 | { | 214 | { |
213 | LOG(GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n"); | 215 | LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n"); |
214 | abort_task = NULL; | 216 | abort_task = NULL; |
215 | do_shutdown(cls); | 217 | do_shutdown (cls); |
216 | } | 218 | } |
217 | 219 | ||
218 | 220 | ||
@@ -225,7 +227,7 @@ do_abort(void *cls) | |||
225 | * operation has executed successfully. | 227 | * operation has executed successfully. |
226 | */ | 228 | */ |
227 | static void | 229 | static void |
228 | op_comp_cb(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg); | 230 | op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg); |
229 | 231 | ||
230 | 232 | ||
231 | /** | 233 | /** |
@@ -234,13 +236,13 @@ op_comp_cb(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg); | |||
234 | * @param cls NULL | 236 | * @param cls NULL |
235 | */ | 237 | */ |
236 | static void | 238 | static void |
237 | do_delayed_connect(void *cls) | 239 | do_delayed_connect (void *cls) |
238 | { | 240 | { |
239 | delayed_connect_task = NULL; | 241 | delayed_connect_task = NULL; |
240 | FAIL_TEST(NULL == common_operation); | 242 | FAIL_TEST (NULL == common_operation); |
241 | common_operation = | 243 | common_operation = |
242 | GNUNET_TESTBED_overlay_connect(NULL, &op_comp_cb, NULL, peer1.peer, | 244 | GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer1.peer, |
243 | peer2.peer); | 245 | peer2.peer); |
244 | } | 246 | } |
245 | 247 | ||
246 | 248 | ||
@@ -253,26 +255,26 @@ do_delayed_connect(void *cls) | |||
253 | * operation has executed successfully. | 255 | * operation has executed successfully. |
254 | */ | 256 | */ |
255 | static void | 257 | static void |
256 | op_comp_cb(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | 258 | op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) |
257 | { | 259 | { |
258 | FAIL_TEST(common_operation == op); | 260 | FAIL_TEST (common_operation == op); |
259 | switch (result) | 261 | switch (result) |
260 | { | 262 | { |
261 | case PEERS_STARTED: | 263 | case PEERS_STARTED: |
262 | FAIL_TEST(NULL == peer1.operation); | 264 | FAIL_TEST (NULL == peer1.operation); |
263 | FAIL_TEST(NULL == peer2.operation); | 265 | FAIL_TEST (NULL == peer2.operation); |
264 | FAIL_TEST(NULL != common_operation); | 266 | FAIL_TEST (NULL != common_operation); |
265 | break; | 267 | break; |
266 | 268 | ||
267 | case PEERS_CONNECTED: | 269 | case PEERS_CONNECTED: |
268 | FAIL_TEST(NULL == peer1.operation); | 270 | FAIL_TEST (NULL == peer1.operation); |
269 | FAIL_TEST(NULL == peer2.operation); | 271 | FAIL_TEST (NULL == peer2.operation); |
270 | FAIL_TEST(NULL != common_operation); | 272 | FAIL_TEST (NULL != common_operation); |
271 | break; | 273 | break; |
272 | 274 | ||
273 | default: | 275 | default: |
274 | FAIL_TEST(0); | 276 | FAIL_TEST (0); |
275 | } | 277 | } |
276 | } | 278 | } |
277 | 279 | ||
278 | 280 | ||
@@ -284,120 +286,120 @@ op_comp_cb(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | |||
284 | * @param event information about the event | 286 | * @param event information about the event |
285 | */ | 287 | */ |
286 | static void | 288 | static void |
287 | controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | 289 | controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) |
288 | { | 290 | { |
289 | switch (event->type) | 291 | switch (event->type) |
292 | { | ||
293 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: /* Will be reached when we destroy peers */ | ||
294 | FAIL_TEST (PEERS_STOPPED == result); | ||
295 | FAIL_TEST (NULL == event->op_cls); | ||
296 | FAIL_TEST (NULL == event->details.operation_finished.emsg); | ||
297 | FAIL_TEST (NULL == event->details.operation_finished.generic); | ||
298 | if (event->op == peer1.operation) | ||
290 | { | 299 | { |
291 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: /* Will be reached when we destroy peers */ | 300 | GNUNET_TESTBED_operation_done (peer1.operation); |
292 | FAIL_TEST(PEERS_STOPPED == result); | 301 | peer1.operation = NULL; |
293 | FAIL_TEST(NULL == event->op_cls); | 302 | peer1.peer = NULL; |
294 | FAIL_TEST(NULL == event->details.operation_finished.emsg); | 303 | } |
295 | FAIL_TEST(NULL == event->details.operation_finished.generic); | 304 | else if (event->op == peer2.operation) |
296 | if (event->op == peer1.operation) | 305 | { |
297 | { | 306 | GNUNET_TESTBED_operation_done (peer2.operation); |
298 | GNUNET_TESTBED_operation_done(peer1.operation); | 307 | peer2.operation = NULL; |
299 | peer1.operation = NULL; | 308 | peer2.peer = NULL; |
300 | peer1.peer = NULL; | 309 | } |
301 | } | 310 | else |
302 | else if (event->op == peer2.operation) | 311 | FAIL_TEST (0); |
303 | { | 312 | if ((NULL == peer1.peer) && (NULL == peer2.peer)) |
304 | GNUNET_TESTBED_operation_done(peer2.operation); | 313 | { |
305 | peer2.operation = NULL; | 314 | result = SUCCESS; |
306 | peer2.peer = NULL; | 315 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
307 | } | 316 | } |
308 | else | 317 | break; |
309 | FAIL_TEST(0); | ||
310 | if ((NULL == peer1.peer) && (NULL == peer2.peer)) | ||
311 | { | ||
312 | result = SUCCESS; | ||
313 | GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); | ||
314 | } | ||
315 | break; | ||
316 | 318 | ||
317 | case GNUNET_TESTBED_ET_PEER_START: | 319 | case GNUNET_TESTBED_ET_PEER_START: |
318 | FAIL_TEST(INIT == result); | 320 | FAIL_TEST (INIT == result); |
319 | FAIL_TEST(event->details.peer_start.host == host); | 321 | FAIL_TEST (event->details.peer_start.host == host); |
320 | if (event->details.peer_start.peer == peer1.peer) | 322 | if (event->details.peer_start.peer == peer1.peer) |
321 | { | 323 | { |
322 | peer1.is_running = GNUNET_YES; | 324 | peer1.is_running = GNUNET_YES; |
323 | GNUNET_TESTBED_operation_done(peer1.operation); | 325 | GNUNET_TESTBED_operation_done (peer1.operation); |
324 | peer1.operation = NULL; | 326 | peer1.operation = NULL; |
325 | } | 327 | } |
326 | else if (event->details.peer_start.peer == peer2.peer) | 328 | else if (event->details.peer_start.peer == peer2.peer) |
327 | { | 329 | { |
328 | peer2.is_running = GNUNET_YES; | 330 | peer2.is_running = GNUNET_YES; |
329 | GNUNET_TESTBED_operation_done(peer2.operation); | 331 | GNUNET_TESTBED_operation_done (peer2.operation); |
330 | peer2.operation = NULL; | 332 | peer2.operation = NULL; |
331 | } | 333 | } |
332 | else | 334 | else |
333 | FAIL_TEST(0); | 335 | FAIL_TEST (0); |
334 | if ((GNUNET_YES == peer1.is_running) && (GNUNET_YES == peer2.is_running)) | 336 | if ((GNUNET_YES == peer1.is_running) && (GNUNET_YES == peer2.is_running)) |
335 | { | 337 | { |
336 | result = PEERS_STARTED; | 338 | result = PEERS_STARTED; |
337 | common_operation = | 339 | common_operation = |
338 | GNUNET_TESTBED_overlay_connect(NULL, &op_comp_cb, NULL, peer1.peer, | 340 | GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer1.peer, |
339 | peer2.peer); | 341 | peer2.peer); |
340 | } | 342 | } |
341 | break; | 343 | break; |
342 | 344 | ||
343 | case GNUNET_TESTBED_ET_PEER_STOP: | 345 | case GNUNET_TESTBED_ET_PEER_STOP: |
344 | FAIL_TEST(PEERS_CONNECTED_2 == result); | 346 | FAIL_TEST (PEERS_CONNECTED_2 == result); |
345 | if (event->details.peer_stop.peer == peer1.peer) | 347 | if (event->details.peer_stop.peer == peer1.peer) |
346 | { | 348 | { |
347 | peer1.is_running = GNUNET_NO; | 349 | peer1.is_running = GNUNET_NO; |
348 | GNUNET_TESTBED_operation_done(peer1.operation); | 350 | GNUNET_TESTBED_operation_done (peer1.operation); |
349 | peer1.operation = GNUNET_TESTBED_peer_destroy(peer1.peer); | 351 | peer1.operation = GNUNET_TESTBED_peer_destroy (peer1.peer); |
350 | } | 352 | } |
351 | else if (event->details.peer_stop.peer == peer2.peer) | 353 | else if (event->details.peer_stop.peer == peer2.peer) |
352 | { | 354 | { |
353 | peer2.is_running = GNUNET_NO; | 355 | peer2.is_running = GNUNET_NO; |
354 | GNUNET_TESTBED_operation_done(peer2.operation); | 356 | GNUNET_TESTBED_operation_done (peer2.operation); |
355 | peer2.operation = GNUNET_TESTBED_peer_destroy(peer2.peer); | 357 | peer2.operation = GNUNET_TESTBED_peer_destroy (peer2.peer); |
356 | } | 358 | } |
357 | else | 359 | else |
358 | FAIL_TEST(0); | 360 | FAIL_TEST (0); |
359 | if ((GNUNET_NO == peer1.is_running) && (GNUNET_NO == peer2.is_running)) | 361 | if ((GNUNET_NO == peer1.is_running) && (GNUNET_NO == peer2.is_running)) |
360 | result = PEERS_STOPPED; | 362 | result = PEERS_STOPPED; |
363 | break; | ||
364 | |||
365 | case GNUNET_TESTBED_ET_CONNECT: | ||
366 | switch (result) | ||
367 | { | ||
368 | case PEERS_STARTED: | ||
369 | FAIL_TEST (NULL == peer1.operation); | ||
370 | FAIL_TEST (NULL == peer2.operation); | ||
371 | FAIL_TEST (NULL != common_operation); | ||
372 | FAIL_TEST ((event->details.peer_connect.peer1 == peer1.peer) && | ||
373 | (event->details.peer_connect.peer2 == peer2.peer)); | ||
374 | GNUNET_TESTBED_operation_done (common_operation); | ||
375 | common_operation = NULL; | ||
376 | result = PEERS_CONNECTED; | ||
377 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); | ||
378 | delayed_connect_task = | ||
379 | GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3), &do_delayed_connect, | ||
380 | NULL); | ||
361 | break; | 381 | break; |
362 | 382 | ||
363 | case GNUNET_TESTBED_ET_CONNECT: | 383 | case PEERS_CONNECTED: |
364 | switch (result) | 384 | FAIL_TEST (NULL == peer1.operation); |
365 | { | 385 | FAIL_TEST (NULL == peer2.operation); |
366 | case PEERS_STARTED: | 386 | FAIL_TEST (NULL != common_operation); |
367 | FAIL_TEST(NULL == peer1.operation); | 387 | GNUNET_TESTBED_operation_done (common_operation); |
368 | FAIL_TEST(NULL == peer2.operation); | 388 | common_operation = NULL; |
369 | FAIL_TEST(NULL != common_operation); | 389 | result = PEERS_CONNECTED_2; |
370 | FAIL_TEST((event->details.peer_connect.peer1 == peer1.peer) && | 390 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected again\n"); |
371 | (event->details.peer_connect.peer2 == peer2.peer)); | 391 | peer1.operation = GNUNET_TESTBED_peer_stop (NULL, peer1.peer, NULL, NULL); |
372 | GNUNET_TESTBED_operation_done(common_operation); | 392 | peer2.operation = GNUNET_TESTBED_peer_stop (NULL, peer2.peer, NULL, NULL); |
373 | common_operation = NULL; | ||
374 | result = PEERS_CONNECTED; | ||
375 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); | ||
376 | delayed_connect_task = | ||
377 | GNUNET_SCHEDULER_add_delayed(TIME_REL_SECS(3), &do_delayed_connect, | ||
378 | NULL); | ||
379 | break; | ||
380 | |||
381 | case PEERS_CONNECTED: | ||
382 | FAIL_TEST(NULL == peer1.operation); | ||
383 | FAIL_TEST(NULL == peer2.operation); | ||
384 | FAIL_TEST(NULL != common_operation); | ||
385 | GNUNET_TESTBED_operation_done(common_operation); | ||
386 | common_operation = NULL; | ||
387 | result = PEERS_CONNECTED_2; | ||
388 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Peers connected again\n"); | ||
389 | peer1.operation = GNUNET_TESTBED_peer_stop(NULL, peer1.peer, NULL, NULL); | ||
390 | peer2.operation = GNUNET_TESTBED_peer_stop(NULL, peer2.peer, NULL, NULL); | ||
391 | break; | ||
392 | |||
393 | default: | ||
394 | FAIL_TEST(0); | ||
395 | } | ||
396 | break; | 393 | break; |
397 | 394 | ||
398 | default: | 395 | default: |
399 | FAIL_TEST(0); | 396 | FAIL_TEST (0); |
400 | } | 397 | } |
398 | break; | ||
399 | |||
400 | default: | ||
401 | FAIL_TEST (0); | ||
402 | } | ||
401 | ; | 403 | ; |
402 | } | 404 | } |
403 | 405 | ||
@@ -412,16 +414,16 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
412 | * @param emsg NULL if peer is not NULL; else MAY contain the error description | 414 | * @param emsg NULL if peer is not NULL; else MAY contain the error description |
413 | */ | 415 | */ |
414 | static void | 416 | static void |
415 | peer_create_cb(void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | 417 | peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) |
416 | { | 418 | { |
417 | struct PeerContext *pc = cls; | 419 | struct PeerContext *pc = cls; |
418 | 420 | ||
419 | FAIL_TEST(NULL != pc->operation); | 421 | FAIL_TEST (NULL != pc->operation); |
420 | FAIL_TEST(NULL != peer); | 422 | FAIL_TEST (NULL != peer); |
421 | FAIL_TEST(NULL == pc->peer); | 423 | FAIL_TEST (NULL == pc->peer); |
422 | pc->peer = peer; | 424 | pc->peer = peer; |
423 | GNUNET_TESTBED_operation_done(pc->operation); | 425 | GNUNET_TESTBED_operation_done (pc->operation); |
424 | pc->operation = GNUNET_TESTBED_peer_start(NULL, pc->peer, NULL, NULL); | 426 | pc->operation = GNUNET_TESTBED_peer_start (NULL, pc->peer, NULL, NULL); |
425 | } | 427 | } |
426 | 428 | ||
427 | 429 | ||
@@ -432,18 +434,18 @@ peer_create_cb(void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | |||
432 | * @param emsg the error message; NULL if host registration is successful | 434 | * @param emsg the error message; NULL if host registration is successful |
433 | */ | 435 | */ |
434 | static void | 436 | static void |
435 | registration_comp(void *cls, const char *emsg) | 437 | registration_comp (void *cls, const char *emsg) |
436 | { | 438 | { |
437 | FAIL_TEST(cls == neighbour); | 439 | FAIL_TEST (cls == neighbour); |
438 | reg_handle = NULL; | 440 | reg_handle = NULL; |
439 | peer1.operation = | 441 | peer1.operation = |
440 | GNUNET_TESTBED_peer_create(controller, host, cfg, &peer_create_cb, | 442 | GNUNET_TESTBED_peer_create (controller, host, cfg, &peer_create_cb, |
441 | &peer1); | 443 | &peer1); |
442 | peer2.operation = | 444 | peer2.operation = |
443 | GNUNET_TESTBED_peer_create(controller, host, cfg, &peer_create_cb, | 445 | GNUNET_TESTBED_peer_create (controller, host, cfg, &peer_create_cb, |
444 | &peer2); | 446 | &peer2); |
445 | FAIL_TEST(NULL != peer1.operation); | 447 | FAIL_TEST (NULL != peer1.operation); |
446 | FAIL_TEST(NULL != peer2.operation); | 448 | FAIL_TEST (NULL != peer2.operation); |
447 | } | 449 | } |
448 | 450 | ||
449 | 451 | ||
@@ -457,30 +459,31 @@ registration_comp(void *cls, const char *emsg) | |||
457 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case | 459 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case |
458 | */ | 460 | */ |
459 | static void | 461 | static void |
460 | status_cb(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg_, int status) | 462 | status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg_, int |
463 | status) | ||
461 | { | 464 | { |
462 | uint64_t event_mask; | 465 | uint64_t event_mask; |
463 | 466 | ||
464 | if (GNUNET_OK != status) | 467 | if (GNUNET_OK != status) |
465 | { | 468 | { |
466 | cp = NULL; | 469 | cp = NULL; |
467 | FAIL_TEST(0); | 470 | FAIL_TEST (0); |
468 | } | 471 | } |
469 | event_mask = 0; | 472 | event_mask = 0; |
470 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START); | 473 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START); |
471 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); | 474 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); |
472 | event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT); | 475 | event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT); |
473 | event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED); | 476 | event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED); |
474 | controller = | 477 | controller = |
475 | GNUNET_TESTBED_controller_connect(host, event_mask, &controller_cb, | 478 | GNUNET_TESTBED_controller_connect (host, event_mask, &controller_cb, |
476 | NULL); | 479 | NULL); |
477 | FAIL_TEST(NULL != controller); | 480 | FAIL_TEST (NULL != controller); |
478 | neighbour = GNUNET_TESTBED_host_create("localhost", NULL, cfg, 0); | 481 | neighbour = GNUNET_TESTBED_host_create ("localhost", NULL, cfg, 0); |
479 | FAIL_TEST(NULL != neighbour); | 482 | FAIL_TEST (NULL != neighbour); |
480 | reg_handle = | 483 | reg_handle = |
481 | GNUNET_TESTBED_register_host(controller, neighbour, ®istration_comp, | 484 | GNUNET_TESTBED_register_host (controller, neighbour, ®istration_comp, |
482 | neighbour); | 485 | neighbour); |
483 | FAIL_TEST(NULL != reg_handle); | 486 | FAIL_TEST (NULL != reg_handle); |
484 | } | 487 | } |
485 | 488 | ||
486 | 489 | ||
@@ -494,18 +497,18 @@ status_cb(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg_, int status) | |||
494 | * @param cfg the configuration file handle | 497 | * @param cfg the configuration file handle |
495 | */ | 498 | */ |
496 | static void | 499 | static void |
497 | run(void *cls, char *const *args, const char *cfgfile, | 500 | run (void *cls, char *const *args, const char *cfgfile, |
498 | const struct GNUNET_CONFIGURATION_Handle *config) | 501 | const struct GNUNET_CONFIGURATION_Handle *config) |
499 | { | 502 | { |
500 | cfg = GNUNET_CONFIGURATION_dup(config); | 503 | cfg = GNUNET_CONFIGURATION_dup (config); |
501 | host = GNUNET_TESTBED_host_create(NULL, NULL, cfg, 0); | 504 | host = GNUNET_TESTBED_host_create (NULL, NULL, cfg, 0); |
502 | FAIL_TEST(NULL != host); | 505 | FAIL_TEST (NULL != host); |
503 | cp = GNUNET_TESTBED_controller_start("127.0.0.1", host, status_cb, | 506 | cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, status_cb, |
504 | NULL); | 507 | NULL); |
505 | abort_task = | 508 | abort_task = |
506 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply | 509 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
507 | (GNUNET_TIME_UNIT_MINUTES, 3), &do_abort, | 510 | (GNUNET_TIME_UNIT_MINUTES, 3), &do_abort, |
508 | NULL); | 511 | NULL); |
509 | } | 512 | } |
510 | 513 | ||
511 | 514 | ||
@@ -513,7 +516,7 @@ run(void *cls, char *const *args, const char *cfgfile, | |||
513 | * Main function | 516 | * Main function |
514 | */ | 517 | */ |
515 | int | 518 | int |
516 | main(int argc, char **argv) | 519 | main (int argc, char **argv) |
517 | { | 520 | { |
518 | int ret; | 521 | int ret; |
519 | 522 | ||
@@ -526,9 +529,9 @@ main(int argc, char **argv) | |||
526 | 529 | ||
527 | result = INIT; | 530 | result = INIT; |
528 | ret = | 531 | ret = |
529 | GNUNET_PROGRAM_run((sizeof(argv2) / sizeof(char *)) - 1, argv2, | 532 | GNUNET_PROGRAM_run ((sizeof(argv2) / sizeof(char *)) - 1, argv2, |
530 | "test_testbed_api_2peers_1controller", "nohelp", | 533 | "test_testbed_api_2peers_1controller", "nohelp", |
531 | options, &run, NULL); | 534 | options, &run, NULL); |
532 | if ((GNUNET_OK != ret) || (SUCCESS != result)) | 535 | if ((GNUNET_OK != ret) || (SUCCESS != result)) |
533 | return 1; | 536 | return 1; |
534 | return 0; | 537 | return 0; |