aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/test_testbed_api_controllerlink.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-27 16:15:33 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-27 16:15:33 +0000
commitf27f46409ec33cef42379006d561d33a2ae44682 (patch)
tree0d32d879b31feb0d9aa0d19e44b41a2146cb1973 /src/testbed/test_testbed_api_controllerlink.c
parent3a4870624812ac4286624d3946981cac6aef4e67 (diff)
downloadgnunet-f27f46409ec33cef42379006d561d33a2ae44682.tar.gz
gnunet-f27f46409ec33cef42379006d561d33a2ae44682.zip
convert testbed_api to MQ (not perfect, but working)
Diffstat (limited to 'src/testbed/test_testbed_api_controllerlink.c')
-rw-r--r--src/testbed/test_testbed_api_controllerlink.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/testbed/test_testbed_api_controllerlink.c b/src/testbed/test_testbed_api_controllerlink.c
index fd876a07f..699a18215 100644
--- a/src/testbed/test_testbed_api_controllerlink.c
+++ b/src/testbed/test_testbed_api_controllerlink.c
@@ -244,7 +244,7 @@ static struct GNUNET_CONFIGURATION_Handle *cfg3;
244/** 244/**
245 * Abort task 245 * Abort task
246 */ 246 */
247static struct GNUNET_SCHEDULER_Task * abort_task; 247static struct GNUNET_SCHEDULER_Task *abort_task;
248 248
249/** 249/**
250 * Operation handle for linking controllers 250 * Operation handle for linking controllers
@@ -274,17 +274,17 @@ static struct GNUNET_TESTBED_Peer *master_peer;
274/** 274/**
275 * The handle for whether a host is habitable or not 275 * The handle for whether a host is habitable or not
276 */ 276 */
277struct GNUNET_TESTBED_HostHabitableCheckHandle *hc_handle; 277static struct GNUNET_TESTBED_HostHabitableCheckHandle *hc_handle;
278 278
279/** 279/**
280 * The task handle for the delay task 280 * The task handle for the delay task
281 */ 281 */
282struct GNUNET_SCHEDULER_Task * delay_task_id; 282static struct GNUNET_SCHEDULER_Task *delay_task_id;
283 283
284/** 284/**
285 * Event mask 285 * Event mask
286 */ 286 */
287uint64_t event_mask; 287static uint64_t event_mask;
288 288
289/** 289/**
290 * Global testing status 290 * Global testing status
@@ -300,7 +300,7 @@ static enum Stage result;
300 if (NULL != abort_task) \ 300 if (NULL != abort_task) \
301 GNUNET_SCHEDULER_cancel (abort_task); \ 301 GNUNET_SCHEDULER_cancel (abort_task); \
302 abort_task = NULL; \ 302 abort_task = NULL; \
303 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); \ 303 GNUNET_SCHEDULER_shutdown (); \
304 return; \ 304 return; \
305 } \ 305 } \
306 } while (0) 306 } while (0)
@@ -323,6 +323,11 @@ do_shutdown (void *cls)
323 } 323 }
324 if (NULL != hc_handle) 324 if (NULL != hc_handle)
325 GNUNET_TESTBED_is_host_habitable_cancel (hc_handle); 325 GNUNET_TESTBED_is_host_habitable_cancel (hc_handle);
326 if (NULL != op)
327 {
328 GNUNET_TESTBED_operation_done (op);
329 op = NULL;
330 }
326 if (NULL != mc) 331 if (NULL != mc)
327 GNUNET_TESTBED_controller_disconnect (mc); 332 GNUNET_TESTBED_controller_disconnect (mc);
328 if (NULL != cp) 333 if (NULL != cp)
@@ -352,9 +357,11 @@ do_shutdown (void *cls)
352static void 357static void
353do_abort (void *cls) 358do_abort (void *cls)
354{ 359{
355 LOG (GNUNET_ERROR_TYPE_WARNING, "Aborting\n"); 360 LOG (GNUNET_ERROR_TYPE_WARNING,
361 "Aborting in stage %d\n",
362 result);
356 abort_task = NULL; 363 abort_task = NULL;
357 do_shutdown (cls); 364 GNUNET_SCHEDULER_shutdown ();
358} 365}
359 366
360 367
@@ -423,7 +430,9 @@ delay_task (void *cls)
423 * @param emsg NULL if peer is not NULL; else MAY contain the error description 430 * @param emsg NULL if peer is not NULL; else MAY contain the error description
424 */ 431 */
425static void 432static void
426peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) 433peer_create_cb (void *cls,
434 struct GNUNET_TESTBED_Peer *peer,
435 const char *emsg)
427{ 436{
428 FAIL_TEST (NULL != peer); 437 FAIL_TEST (NULL != peer);
429 FAIL_TEST (NULL == emsg); 438 FAIL_TEST (NULL == emsg);
@@ -445,12 +454,13 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
445 result = SLAVE2_PEER_CREATE_SUCCESS; 454 result = SLAVE2_PEER_CREATE_SUCCESS;
446 slave2_peer = peer; 455 slave2_peer = peer;
447 GNUNET_TESTBED_operation_done (op); 456 GNUNET_TESTBED_operation_done (op);
457 op = NULL;
448 delay_task_id = 458 delay_task_id =
449 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 459 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
450 (GNUNET_TIME_UNIT_SECONDS, 1), 460 (GNUNET_TIME_UNIT_SECONDS, 1),
451 &delay_task, 461 &delay_task,
452 NULL); 462 NULL);
453 break; 463 return;
454 case SLAVE3_STARTED: 464 case SLAVE3_STARTED:
455 result = SLAVE3_PEER_CREATE_SUCCESS; 465 result = SLAVE3_PEER_CREATE_SUCCESS;
456 slave3_peer = peer; 466 slave3_peer = peer;
@@ -490,7 +500,8 @@ check_operation_success (const struct GNUNET_TESTBED_EventInformation *event)
490 * @param event information about the event 500 * @param event information about the event
491 */ 501 */
492static void 502static void
493controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) 503controller_cb (void *cls,
504 const struct GNUNET_TESTBED_EventInformation *event)
494{ 505{
495 switch (result) 506 switch (result)
496 { 507 {
@@ -516,6 +527,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
516 FAIL_TEST (event->details.peer_start.host == host); 527 FAIL_TEST (event->details.peer_start.host == host);
517 FAIL_TEST (event->details.peer_start.peer == master_peer); 528 FAIL_TEST (event->details.peer_start.peer == master_peer);
518 GNUNET_TESTBED_operation_done (op); 529 GNUNET_TESTBED_operation_done (op);
530 op = NULL;
519 result = MASTER_PEER_START_SUCCESS; 531 result = MASTER_PEER_START_SUCCESS;
520 slave = GNUNET_TESTBED_host_create_with_id (1, "127.0.0.1", NULL, cfg, 0); 532 slave = GNUNET_TESTBED_host_create_with_id (1, "127.0.0.1", NULL, cfg, 0);
521 FAIL_TEST (NULL != slave); 533 FAIL_TEST (NULL != slave);
@@ -622,7 +634,6 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
622 case SLAVE3_REGISTERED: 634 case SLAVE3_REGISTERED:
623 check_operation_success (event); 635 check_operation_success (event);
624 GNUNET_TESTBED_operation_done (op); 636 GNUNET_TESTBED_operation_done (op);
625 op = NULL;
626 result = SLAVE3_STARTED; 637 result = SLAVE3_STARTED;
627 op = GNUNET_TESTBED_peer_create (mc, slave3, cfg, peer_create_cb, NULL); 638 op = GNUNET_TESTBED_peer_create (mc, slave3, cfg, peer_create_cb, NULL);
628 FAIL_TEST (NULL != op); 639 FAIL_TEST (NULL != op);
@@ -642,9 +653,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
642 result = SUCCESS; 653 result = SUCCESS;
643 GNUNET_TESTBED_operation_done (op); 654 GNUNET_TESTBED_operation_done (op);
644 op = NULL; 655 op = NULL;
645 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 656 GNUNET_SCHEDULER_shutdown ();
646 &do_shutdown,
647 NULL);
648 break; 657 break;
649 default: 658 default:
650 FAIL_TEST (0); 659 FAIL_TEST (0);
@@ -740,10 +749,11 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
740 * @param cls NULL 749 * @param cls NULL
741 * @param host the host whose status is being reported; will be NULL if the host 750 * @param host the host whose status is being reported; will be NULL if the host
742 * given to GNUNET_TESTBED_is_host_habitable() is NULL 751 * given to GNUNET_TESTBED_is_host_habitable() is NULL
743 * @param status GNUNET_YES if it is habitable; GNUNET_NO if not 752 * @param status #GNUNET_YES if it is habitable; #GNUNET_NO if not
744 */ 753 */
745static void 754static void
746host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host, 755host_habitable_cb (void *cls,
756 const struct GNUNET_TESTBED_Host *_host,
747 int status) 757 int status)
748{ 758{
749 hc_handle = NULL; 759 hc_handle = NULL;
@@ -755,7 +765,7 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host,
755 "Skipping test\n"); 765 "Skipping test\n");
756 GNUNET_SCHEDULER_cancel (abort_task); 766 GNUNET_SCHEDULER_cancel (abort_task);
757 abort_task = NULL; 767 abort_task = NULL;
758 (void) GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 768 GNUNET_SCHEDULER_shutdown ();
759 result = SKIP; 769 result = SKIP;
760 return; 770 return;
761 } 771 }
@@ -799,6 +809,8 @@ run (void *cls, char *const *args, const char *cfgfile,
799 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 809 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
800 (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort, 810 (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort,
801 NULL); 811 NULL);
812 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
813 NULL);
802} 814}
803 815
804 816