aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/test_testbed_api_controllerlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/test_testbed_api_controllerlink.c')
-rw-r--r--src/testbed/test_testbed_api_controllerlink.c66
1 files changed, 35 insertions, 31 deletions
diff --git a/src/testbed/test_testbed_api_controllerlink.c b/src/testbed/test_testbed_api_controllerlink.c
index 10235b884..eadc6c9ff 100644
--- a/src/testbed/test_testbed_api_controllerlink.c
+++ b/src/testbed/test_testbed_api_controllerlink.c
@@ -28,12 +28,12 @@
28/** 28/**
29 * The controller architecture we try to achieve in this test case: 29 * The controller architecture we try to achieve in this test case:
30 * 30 *
31 * Master Controller 31 * Master Controller
32 * // \\ 32 * // \\
33 * // \\ 33 * // \\
34 * Slave Controller 1---------Slave Controller 3 34 * Slave Controller 1---------Slave Controller 3
35 * || 35 * ||
36 * || 36 * ||
37 * Slave Controller 2 37 * Slave Controller 2
38 */ 38 */
39 39
@@ -64,7 +64,7 @@ enum Stage
64 * Initial stage 64 * Initial stage
65 */ 65 */
66 INIT, 66 INIT,
67 67
68 /** 68 /**
69 * Master controller has started 69 * Master controller has started
70 */ 70 */
@@ -314,8 +314,8 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
314/** 314/**
315 * Calls abort now 315 * Calls abort now
316 * 316 *
317 * @param 317 * @param
318 * @return 318 * @return
319 */ 319 */
320static void 320static void
321do_abort_now (void *cls) 321do_abort_now (void *cls)
@@ -376,7 +376,7 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
376 case SLAVE1_LINK_SUCCESS: 376 case SLAVE1_LINK_SUCCESS:
377 result = SLAVE1_PEER_CREATE_SUCCESS; 377 result = SLAVE1_PEER_CREATE_SUCCESS;
378 slave1_peer = peer; 378 slave1_peer = peer;
379 GNUNET_TESTBED_operation_done (op); 379 GNUNET_TESTBED_operation_done (op);
380 op = GNUNET_TESTBED_peer_start (NULL, slave1_peer, NULL, NULL); 380 op = GNUNET_TESTBED_peer_start (NULL, slave1_peer, NULL, NULL);
381 break; 381 break;
382 case SLAVE2_LINK_SUCCESS: 382 case SLAVE2_LINK_SUCCESS:
@@ -448,7 +448,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
448 check_operation_success (event); 448 check_operation_success (event);
449 GNUNET_TESTBED_operation_done (op); 449 GNUNET_TESTBED_operation_done (op);
450 result = SLAVE2_LINK_SUCCESS; 450 result = SLAVE2_LINK_SUCCESS;
451 op = GNUNET_TESTBED_peer_create (mc, slave2, cfg, peer_create_cb, NULL); 451 op = GNUNET_TESTBED_peer_create (mc, slave2, cfg, peer_create_cb, NULL);
452 GNUNET_assert (NULL != op); 452 GNUNET_assert (NULL != op);
453 break; 453 break;
454 case MASTER_PEER_CREATE_SUCCESS: 454 case MASTER_PEER_CREATE_SUCCESS:
@@ -469,7 +469,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
469 GNUNET_TESTBED_operation_done (op); 469 GNUNET_TESTBED_operation_done (op);
470 result = SLAVE1_PEER_START_SUCCESS; 470 result = SLAVE1_PEER_START_SUCCESS;
471 op = GNUNET_TESTBED_controller_link (NULL, mc, slave2, slave, cfg, 471 op = GNUNET_TESTBED_controller_link (NULL, mc, slave2, slave, cfg,
472 GNUNET_YES); 472 GNUNET_YES);
473 break; 473 break;
474 case SLAVE2_PEER_CREATE_SUCCESS: 474 case SLAVE2_PEER_CREATE_SUCCESS:
475 GNUNET_assert (GNUNET_TESTBED_ET_PEER_STOP == event->type); 475 GNUNET_assert (GNUNET_TESTBED_ET_PEER_STOP == event->type);
@@ -529,7 +529,7 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
529 op = NULL; 529 op = NULL;
530 result = SLAVE3_STARTED; 530 result = SLAVE3_STARTED;
531 op = GNUNET_TESTBED_get_slave_config (NULL, mc, slave3); 531 op = GNUNET_TESTBED_get_slave_config (NULL, mc, slave3);
532 GNUNET_assert (NULL != op); 532 GNUNET_assert (NULL != op);
533 break; 533 break;
534 case SLAVE3_STARTED: 534 case SLAVE3_STARTED:
535 GNUNET_assert (NULL != event); 535 GNUNET_assert (NULL != event);
@@ -540,22 +540,23 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
540 cfg3 = GNUNET_CONFIGURATION_dup (event->details.operation_finished.generic); 540 cfg3 = GNUNET_CONFIGURATION_dup (event->details.operation_finished.generic);
541 GNUNET_TESTBED_operation_done (op); 541 GNUNET_TESTBED_operation_done (op);
542 result = SLAVE3_GET_CONFIG_SUCCESS; 542 result = SLAVE3_GET_CONFIG_SUCCESS;
543 op = GNUNET_TESTBED_controller_link (NULL, mc, slave3, slave, cfg3, GNUNET_NO); 543 op = GNUNET_TESTBED_controller_link (NULL, mc, slave3, slave, cfg3,
544 GNUNET_NO);
544 break; 545 break;
545 case SLAVE3_GET_CONFIG_SUCCESS: 546 case SLAVE3_GET_CONFIG_SUCCESS:
546 result = SLAVE3_LINK_SUCCESS; 547 result = SLAVE3_LINK_SUCCESS;
547 GNUNET_TESTBED_operation_done (op); 548 GNUNET_TESTBED_operation_done (op);
548 op = GNUNET_TESTBED_peer_destroy (master_peer); 549 op = GNUNET_TESTBED_peer_destroy (master_peer);
549 break; 550 break;
550 case SLAVE3_LINK_SUCCESS: 551 case SLAVE3_LINK_SUCCESS:
551 check_operation_success (event); 552 check_operation_success (event);
552 result = SUCCESS; 553 result = SUCCESS;
553 GNUNET_TESTBED_operation_done (op); 554 GNUNET_TESTBED_operation_done (op);
554 op = NULL; 555 op = NULL;
555 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 556 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
556 (GNUNET_TIME_UNIT_SECONDS, 3), 557 (GNUNET_TIME_UNIT_SECONDS, 3), &do_shutdown,
557 &do_shutdown, NULL); 558 NULL);
558 break; 559 break;
559 default: 560 default:
560 GNUNET_assert (0); 561 GNUNET_assert (0);
561 } 562 }
@@ -588,7 +589,8 @@ registration_cont (void *cls, const char *emsg)
588 GNUNET_assert (NULL != mc); 589 GNUNET_assert (NULL != mc);
589 result = SLAVE2_REGISTERED; 590 result = SLAVE2_REGISTERED;
590 GNUNET_assert (NULL != cfg); 591 GNUNET_assert (NULL != cfg);
591 op = GNUNET_TESTBED_controller_link (NULL, mc, slave, NULL, cfg, GNUNET_YES); 592 op = GNUNET_TESTBED_controller_link (NULL, mc, slave, NULL, cfg,
593 GNUNET_YES);
592 GNUNET_assert (NULL != op); 594 GNUNET_assert (NULL != op);
593 break; 595 break;
594 case SLAVE2_PEER_DESTROY_SUCCESS: 596 case SLAVE2_PEER_DESTROY_SUCCESS:
@@ -596,7 +598,8 @@ registration_cont (void *cls, const char *emsg)
596 GNUNET_assert (NULL != mc); 598 GNUNET_assert (NULL != mc);
597 GNUNET_assert (NULL == op); 599 GNUNET_assert (NULL == op);
598 result = SLAVE3_REGISTERED; 600 result = SLAVE3_REGISTERED;
599 op = GNUNET_TESTBED_controller_link (NULL, mc, slave3, NULL, cfg, GNUNET_YES); 601 op = GNUNET_TESTBED_controller_link (NULL, mc, slave3, NULL, cfg,
602 GNUNET_YES);
600 GNUNET_assert (NULL != op); 603 GNUNET_assert (NULL != op);
601 break; 604 break;
602 default: 605 default:
@@ -634,7 +637,7 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
634 op = GNUNET_TESTBED_peer_create (mc, host, cfg, peer_create_cb, NULL); 637 op = GNUNET_TESTBED_peer_create (mc, host, cfg, peer_create_cb, NULL);
635 GNUNET_assert (NULL != op); 638 GNUNET_assert (NULL != op);
636 break; 639 break;
637 default: 640 default:
638 GNUNET_break (0); 641 GNUNET_break (0);
639 cp = NULL; 642 cp = NULL;
640 do_abort_now (NULL); 643 do_abort_now (NULL);
@@ -652,8 +655,9 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
652 * given to GNUNET_TESTBED_is_host_habitable() is NULL 655 * given to GNUNET_TESTBED_is_host_habitable() is NULL
653 * @param status GNUNET_YES if it is habitable; GNUNET_NO if not 656 * @param status GNUNET_YES if it is habitable; GNUNET_NO if not
654 */ 657 */
655static void 658static void
656host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host, int status) 659host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host,
660 int status)
657{ 661{
658 hc_handle = NULL; 662 hc_handle = NULL;
659 if (GNUNET_NO == status) 663 if (GNUNET_NO == status)
@@ -669,7 +673,7 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *_host, int statu
669 return; 673 return;
670 } 674 }
671 cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, 675 cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb,
672 NULL); 676 NULL);
673} 677}
674 678
675 679
@@ -687,9 +691,10 @@ run (void *cls, char *const *args, const char *cfgfile,
687{ 691{
688 host = GNUNET_TESTBED_host_create (NULL, NULL, 0); 692 host = GNUNET_TESTBED_host_create (NULL, NULL, 0);
689 GNUNET_assert (NULL != host); 693 GNUNET_assert (NULL != host);
690 if (NULL == (hc_handle = GNUNET_TESTBED_is_host_habitable (host, config, 694 if (NULL ==
691 &host_habitable_cb, 695 (hc_handle =
692 NULL))) 696 GNUNET_TESTBED_is_host_habitable (host, config, &host_habitable_cb,
697 NULL)))
693 { 698 {
694 GNUNET_TESTBED_host_destroy (host); 699 GNUNET_TESTBED_host_destroy (host);
695 host = NULL; 700 host = NULL;
@@ -700,7 +705,7 @@ run (void *cls, char *const *args, const char *cfgfile,
700 result = SKIP; 705 result = SKIP;
701 return; 706 return;
702 } 707 }
703 cfg = GNUNET_CONFIGURATION_dup (config); 708 cfg = GNUNET_CONFIGURATION_dup (config);
704 abort_task = 709 abort_task =
705 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 710 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
706 (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort, 711 (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort,
@@ -742,4 +747,3 @@ main (int argc, char **argv)
742} 747}
743 748
744/* end of test_testbed_api_controllerlink.c */ 749/* end of test_testbed_api_controllerlink.c */
745