X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ftestbed%2Ftest_testbed_api_3peers_3controllers.c;h=4e67ef152cf7c86ba361b9efe371794528232d27;hb=7a5a724a6f96baf80d2226326124aa01c58ad3fe;hp=206944ae8f0f67290a5787e2b7b15db92658ccfc;hpb=6035da499e4311aefda6f1c6ba1acef9cf3ded7e;p=oweals%2Fgnunet.git diff --git a/src/testbed/test_testbed_api_3peers_3controllers.c b/src/testbed/test_testbed_api_3peers_3controllers.c index 206944ae8..4e67ef152 100644 --- a/src/testbed/test_testbed_api_3peers_3controllers.c +++ b/src/testbed/test_testbed_api_3peers_3controllers.c @@ -1,21 +1,19 @@ /* This file is part of GNUnet - (C) 2008--2012 Christian Grothoff (and other contributing authors) + Copyright (C) 2008--2013 GNUnet e.V. - GNUnet is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3, or (at your - option) any later version. + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . */ /** @@ -31,7 +29,7 @@ * A * / \ * / \ - * B === C + * B === C * A is the master controller and B, C are slave controllers. B links to C * laterally. * Peers are mapped to controllers in the following relations: @@ -44,7 +42,7 @@ #include "platform.h" #include "gnunet_util_lib.h" -#include "gnunet_testing_lib-new.h" +#include "gnunet_testing_lib.h" #include "gnunet_testbed_service.h" @@ -143,15 +141,20 @@ static struct GNUNET_CONFIGURATION_Handle *cfg2; */ static struct GNUNET_TESTBED_Operation *common_operation; +/** + * The handle for whether a host is habitable or not + */ +struct GNUNET_TESTBED_HostHabitableCheckHandle *hc_handle; + /** * Abort task identifier */ -static GNUNET_SCHEDULER_TaskIdentifier abort_task; +static struct GNUNET_SCHEDULER_Task * abort_task; /** * Delayed connect job identifier */ -static GNUNET_SCHEDULER_TaskIdentifier delayed_connect_task; +static struct GNUNET_SCHEDULER_Task * delayed_connect_task; /** * Different stages in testing @@ -232,7 +235,12 @@ enum Stage /** * Final success stage */ - SUCCESS + SUCCESS, + + /** + * Optional stage for marking test to be skipped + */ + SKIP }; /** @@ -244,14 +252,17 @@ static enum Stage result; * Shutdown nicely * * @param cls NULL - * @param tc the task context */ static void -do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +do_shutdown (void *cls) { - if (GNUNET_SCHEDULER_NO_TASK != abort_task) + if (NULL != abort_task) GNUNET_SCHEDULER_cancel (abort_task); - GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == delayed_connect_task); + if (NULL != hc_handle) + GNUNET_TESTBED_is_host_habitable_cancel (hc_handle); + GNUNET_assert (NULL == delayed_connect_task); + if (NULL != common_operation) + GNUNET_TESTBED_operation_done (common_operation); if (NULL != reg_handle) GNUNET_TESTBED_cancel_registration (reg_handle); if (NULL != controller1) @@ -274,15 +285,27 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * abort task to run on test timed out * * @param cls NULL - * @param tc the task context */ static void -do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +do_abort (void *cls) { LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n"); - abort_task = GNUNET_SCHEDULER_NO_TASK; - GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == delayed_connect_task); - do_shutdown (cls, tc); + abort_task = NULL; + if (NULL != delayed_connect_task) + { + GNUNET_SCHEDULER_cancel (delayed_connect_task); + delayed_connect_task = NULL; + } + do_shutdown (cls); +} + + +static void +abort_test () +{ + if (NULL != abort_task) + GNUNET_SCHEDULER_cancel (abort_task); + abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); } @@ -294,7 +317,7 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param emsg error message in case the operation has failed; will be NULL if * operation has executed successfully. */ -static void +static void op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg); @@ -302,15 +325,20 @@ op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg); * task for delaying a connect * * @param cls NULL - * @param tc the task context */ static void -do_delayed_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +do_delayed_connect (void *cls) { - delayed_connect_task = GNUNET_SCHEDULER_NO_TASK; - GNUNET_assert (NULL == common_operation); - common_operation = GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, - peer1.peer, peer2.peer); + delayed_connect_task = NULL; + if (NULL != common_operation) + { + GNUNET_break (0); + abort_test (); + return; + } + common_operation = + GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer1.peer, + peer2.peer); } @@ -322,47 +350,33 @@ do_delayed_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param emsg error message in case the operation has failed; will be NULL if * operation has executed successfully. */ -static void +static void op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) { - GNUNET_assert (common_operation == op); - switch(result) + if (common_operation != op) + { + GNUNET_break (0); + abort_test (); + return; + } + + switch (result) { case PEER3_STARTED: - GNUNET_assert (NULL == peer1.operation); - GNUNET_assert (NULL == peer2.operation); - GNUNET_assert (NULL != common_operation); - GNUNET_TESTBED_operation_done (common_operation); - common_operation = NULL; - result = PEERS_1_2_CONNECTED; - LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); - common_operation = - GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer2.peer, - peer3.peer); - break; - case PEERS_1_2_CONNECTED: - GNUNET_assert (NULL != common_operation); - GNUNET_TESTBED_operation_done (common_operation); - common_operation = NULL; - result = PEERS_2_3_CONNECTED; - delayed_connect_task = - GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3), - &do_delayed_connect, NULL); - break; case PEERS_2_3_CONNECTED: - GNUNET_assert (NULL == peer1.operation); - GNUNET_assert (NULL == peer2.operation); - GNUNET_assert (NULL != common_operation); - GNUNET_TESTBED_operation_done (common_operation); - common_operation = NULL; - result = PEERS_CONNECTED_2; - LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected again\n"); - peer1.operation = GNUNET_TESTBED_peer_stop (peer1.peer, NULL, NULL); - peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer, NULL, NULL); - peer3.operation = GNUNET_TESTBED_peer_stop (peer3.peer, NULL, NULL); + case PEERS_1_2_CONNECTED: break; default: - GNUNET_assert (0); + GNUNET_break (0); + abort_test (); + return; + } + if ((NULL != peer1.operation) || (NULL != peer2.operation) || + (NULL != peer3.operation)) + { + GNUNET_break (0); + abort_test (); + return; } } @@ -382,51 +396,49 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) switch (result) { case CONTROLLER1_UP: - GNUNET_assert (NULL != peer1.operation); - GNUNET_assert (NULL != peer); - GNUNET_assert (NULL == peer1.peer); + if ((NULL == peer1.operation) || (NULL == peer) || (NULL != peer1.peer)) + { + GNUNET_break (0); + abort_test (); + return; + } peer1.peer = peer; GNUNET_TESTBED_operation_done (peer1.operation); result = PEER1_CREATED; peer1.operation = GNUNET_TESTBED_peer_start (NULL, peer, NULL, NULL); break; case CONTROLLER2_UP: - GNUNET_assert (NULL != peer2.operation); - GNUNET_assert (NULL != peer); - GNUNET_assert (NULL == peer2.peer); + if ((NULL == peer2.operation) || (NULL == peer) || (NULL != peer2.peer)) + { + GNUNET_break (0); + abort_test (); + return; + } peer2.peer = peer; GNUNET_TESTBED_operation_done (peer2.operation); result = PEER2_CREATED; peer2.operation = GNUNET_TESTBED_peer_start (NULL, peer, NULL, NULL); break; case CONTROLLER3_UP: - GNUNET_assert (NULL != peer3.operation); - GNUNET_assert (NULL != peer); - GNUNET_assert (NULL == peer3.peer); + if ((NULL == peer3.operation) || (NULL == peer) || (NULL != peer3.peer)) + { + GNUNET_break (0); + abort_test (); + return; + } peer3.peer = peer; GNUNET_TESTBED_operation_done (peer3.operation); result = PEER3_CREATED; peer3.operation = GNUNET_TESTBED_peer_start (NULL, peer, NULL, NULL); break; default: - GNUNET_assert (0); - } + GNUNET_break (0); + abort_test (); + return; + } } -/** - * Callback to signal successfull startup of the controller process - * - * @param cls the closure from GNUNET_TESTBED_controller_start() - * @param cfg the configuration with which the controller has been started; - * NULL if status is not GNUNET_OK - * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, - * GNUNET_TESTBED_controller_stop() shouldn't be called in this case - */ -static void -status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int status); - - /** * Signature of the event handler function called by the * respective event controller. @@ -440,32 +452,46 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) switch (event->type) { case GNUNET_TESTBED_ET_OPERATION_FINISHED: - GNUNET_assert (NULL == event->details.operation_finished.op_cls); - GNUNET_assert (NULL == event->details.operation_finished.emsg); + if ((NULL != event->op_cls) || + (NULL != event->details.operation_finished.emsg)) + { + GNUNET_break (0); + abort_test (); + return; + } switch (result) - { + { case PEERS_STOPPED: - GNUNET_assert (NULL == event->details.operation_finished.generic); - if (event->details.operation_finished.operation == peer1.operation) + if (NULL != event->details.operation_finished.generic) + { + GNUNET_break (0); + abort_test (); + return; + } + if (event->op == peer1.operation) { GNUNET_TESTBED_operation_done (peer1.operation); peer1.operation = NULL; peer1.peer = NULL; } - else if (event->details.operation_finished.operation == peer2.operation) + else if (event->op == peer2.operation) { GNUNET_TESTBED_operation_done (peer2.operation); peer2.operation = NULL; peer2.peer = NULL; } - else if (event->details.operation_finished.operation == peer3.operation) + else if (event->op == peer3.operation) { GNUNET_TESTBED_operation_done (peer3.operation); peer3.operation = NULL; peer3.peer = NULL; } else - GNUNET_assert (0); + { + GNUNET_break (0); + abort_test (); + return; + } if ((NULL == peer1.peer) && (NULL == peer2.peer) && (NULL == peer3.peer)) { result = SUCCESS; @@ -473,58 +499,105 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) } break; case PEER1_STARTED: - GNUNET_assert (NULL == event->details.operation_finished.generic); - GNUNET_assert (NULL != common_operation); + if ((NULL != event->details.operation_finished.generic) || + (NULL == common_operation)) + { + GNUNET_break (0); + abort_test (); + return; + } GNUNET_TESTBED_operation_done (common_operation); common_operation = NULL; result = CONTROLLER2_UP; peer2.operation = GNUNET_TESTBED_peer_create (controller1, neighbour1, cfg, &peer_create_cb, NULL); - GNUNET_assert (NULL != peer2.operation); + if (NULL == peer2.operation) + { + GNUNET_break (0); + abort_test (); + return; + } break; case PEER2_STARTED: - GNUNET_assert (NULL == event->details.operation_finished.generic); - GNUNET_assert (NULL != common_operation); + if ((NULL != event->details.operation_finished.generic) || + (NULL == common_operation)) + { + GNUNET_break (0); + abort_test (); + return; + } GNUNET_TESTBED_operation_done (common_operation); common_operation = NULL; result = CONTROLLER3_UP; peer3.operation = GNUNET_TESTBED_peer_create (controller1, neighbour2, cfg, &peer_create_cb, NULL); - GNUNET_assert (NULL != peer3.operation); + if (NULL == peer3.operation) + { + GNUNET_break (0); + abort_test (); + return; + } break; default: - GNUNET_assert (0); + GNUNET_break (0); + abort_test (); + return; } break; - case GNUNET_TESTBED_ET_PEER_START: + case GNUNET_TESTBED_ET_PEER_START: switch (result) { case PEER1_CREATED: - GNUNET_assert (event->details.peer_start.host == host); + if (event->details.peer_start.host != host) + { + GNUNET_break (0); + abort_test (); + return; + } peer1.is_running = GNUNET_YES; GNUNET_TESTBED_operation_done (peer1.operation); peer1.operation = NULL; result = PEER1_STARTED; common_operation = - GNUNET_TESTBED_controller_link (NULL, controller1, neighbour1, NULL, cfg, - GNUNET_YES); + GNUNET_TESTBED_controller_link (NULL, controller1, neighbour1, NULL, + GNUNET_YES); break; case PEER2_CREATED: - GNUNET_assert (event->details.peer_start.host == neighbour1); + if (event->details.peer_start.host != neighbour1) + { + GNUNET_break (0); + abort_test (); + return; + } peer2.is_running = GNUNET_YES; GNUNET_TESTBED_operation_done (peer2.operation); peer2.operation = NULL; result = PEER2_STARTED; - GNUNET_assert (NULL == common_operation); + if (NULL != common_operation) + { + GNUNET_break (0); + abort_test (); + return; + } common_operation = - GNUNET_TESTBED_controller_link (NULL, controller1, neighbour2, NULL, cfg, + GNUNET_TESTBED_controller_link (NULL, controller1, neighbour2, NULL, GNUNET_YES); - GNUNET_assert (NULL != common_operation); + if (NULL == common_operation) + { + GNUNET_break (0); + abort_test (); + return; + } break; case PEER3_CREATED: - GNUNET_assert (event->details.peer_start.host == neighbour2); + if (event->details.peer_start.host != neighbour2) + { + GNUNET_break (0); + abort_test (); + return; + } peer3.is_running = GNUNET_YES; GNUNET_TESTBED_operation_done (peer3.operation); peer3.operation = NULL; @@ -534,11 +607,18 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) peer1.peer); break; default: - GNUNET_assert (0); - } + GNUNET_break (0); + abort_test (); + return; + } break; case GNUNET_TESTBED_ET_PEER_STOP: - GNUNET_assert (PEERS_CONNECTED_2 == result); + if (PEERS_CONNECTED_2 != result) + { + GNUNET_break (0); + abort_test (); + return; + } if (event->details.peer_stop.peer == peer1.peer) { peer1.is_running = GNUNET_NO; @@ -555,9 +635,12 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) GNUNET_TESTBED_operation_done (peer3.operation); } else - GNUNET_assert (0); - if ((GNUNET_NO == peer1.is_running) && - (GNUNET_NO == peer2.is_running) && + { + GNUNET_break (0); + abort_test (); + return; + } + if ((GNUNET_NO == peer1.is_running) && (GNUNET_NO == peer2.is_running) && (GNUNET_NO == peer3.is_running)) { result = PEERS_STOPPED; @@ -567,33 +650,73 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) } break; case GNUNET_TESTBED_ET_CONNECT: - GNUNET_assert (NULL == peer1.operation); - GNUNET_assert (NULL == peer2.operation); - GNUNET_assert (NULL == peer3.operation); + if ((NULL != peer1.operation) || (NULL != peer2.operation) || + (NULL != peer3.operation) || (NULL == common_operation)) + { + GNUNET_break (0); + abort_test (); + return; + } switch (result) { case PEER3_STARTED: - GNUNET_assert (NULL != common_operation); - GNUNET_assert ((event->details.peer_connect.peer1 == peer2.peer) && - (event->details.peer_connect.peer2 == peer1.peer)); + if ((event->details.peer_connect.peer1 != peer2.peer) || + (event->details.peer_connect.peer2 != peer1.peer)) + { + GNUNET_break (0); + abort_test (); + return; + } + GNUNET_TESTBED_operation_done (common_operation); + common_operation = NULL; + result = PEERS_1_2_CONNECTED; + LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); + common_operation = + GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer2.peer, + peer3.peer); break; - case PEERS_2_3_CONNECTED: - GNUNET_assert (NULL != common_operation); - GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) && - (event->details.peer_connect.peer2 == peer2.peer)); + case PEERS_1_2_CONNECTED: + if ((event->details.peer_connect.peer1 != peer2.peer) || + (event->details.peer_connect.peer2 != peer3.peer)) + { + GNUNET_break (0); + abort_test (); + return; + } + GNUNET_TESTBED_operation_done (common_operation); + common_operation = NULL; + result = PEERS_2_3_CONNECTED; + delayed_connect_task = + GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3), &do_delayed_connect, + NULL); break; - case PEERS_1_2_CONNECTED: - GNUNET_assert (NULL != common_operation); - GNUNET_assert ((event->details.peer_connect.peer1 == peer2.peer) && - (event->details.peer_connect.peer2 == peer3.peer)); + case PEERS_2_3_CONNECTED: + if ((event->details.peer_connect.peer1 != peer1.peer) || + (event->details.peer_connect.peer2 != peer2.peer)) + { + GNUNET_break (0); + abort_test (); + return; + } + GNUNET_TESTBED_operation_done (common_operation); + common_operation = NULL; + result = PEERS_CONNECTED_2; + LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected again\n"); + peer1.operation = GNUNET_TESTBED_peer_stop (NULL, peer1.peer, NULL, NULL); + peer2.operation = GNUNET_TESTBED_peer_stop (NULL, peer2.peer, NULL, NULL); + peer3.operation = GNUNET_TESTBED_peer_stop (NULL, peer3.peer, NULL, NULL); break; default: - GNUNET_assert (0); + GNUNET_break (0); + abort_test (); + return; } break; default: - GNUNET_assert (0); - }; + GNUNET_break (0); + abort_test (); + return; + } } @@ -609,19 +732,39 @@ registration_comp (void *cls, const char *emsg) reg_handle = NULL; if (cls == neighbour1) { - neighbour2 = GNUNET_TESTBED_host_create ("127.0.0.1", NULL, 0); - GNUNET_assert (NULL != neighbour2); + neighbour2 = GNUNET_TESTBED_host_create ("127.0.0.1", NULL, cfg, 0); + if (NULL == neighbour2) + { + GNUNET_break (0); + abort_test (); + return; + } reg_handle = - GNUNET_TESTBED_register_host (controller1, neighbour2, ®istration_comp, - neighbour2); - GNUNET_assert (NULL != reg_handle); + GNUNET_TESTBED_register_host (controller1, neighbour2, + ®istration_comp, neighbour2); + if (NULL == reg_handle) + { + GNUNET_break (0); + abort_test (); + return; + } + return; + } + if (cls != neighbour2) + { + GNUNET_break (0); + abort_test (); return; } - GNUNET_assert (cls == neighbour2); peer1.operation = GNUNET_TESTBED_peer_create (controller1, host, cfg, &peer_create_cb, &peer1); - GNUNET_assert (NULL != peer1.operation); + if (NULL == peer1.operation) + { + GNUNET_break (0); + abort_test (); + return; + } } @@ -635,11 +778,18 @@ registration_comp (void *cls, const char *emsg) * GNUNET_TESTBED_controller_stop() shouldn't be called in this case */ static void -status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int status) +status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, + int status) { uint64_t event_mask; - - GNUNET_assert (GNUNET_OK == status); + + if (GNUNET_OK != status) + { + GNUNET_break (0); + cp1 = NULL; + abort_test (); + return; + } event_mask = 0; event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START); event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); @@ -649,20 +799,70 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int stat { case INIT: controller1 = - GNUNET_TESTBED_controller_connect (config, host, event_mask, &controller_cb, - NULL); - GNUNET_assert (NULL != controller1); + GNUNET_TESTBED_controller_connect (host, event_mask, + &controller_cb, NULL); + if (NULL == controller1) + { + GNUNET_break (0); + abort_test (); + return; + } result = CONTROLLER1_UP; - neighbour1 = GNUNET_TESTBED_host_create ("127.0.0.1", NULL, 0); - GNUNET_assert (NULL != neighbour1); + neighbour1 = GNUNET_TESTBED_host_create ("127.0.0.1", NULL, cfg, 0); + if (NULL == neighbour1) + { + GNUNET_break (0); + abort_test (); + return; + } reg_handle = - GNUNET_TESTBED_register_host (controller1, neighbour1, ®istration_comp, - neighbour1); - GNUNET_assert (NULL != reg_handle); + GNUNET_TESTBED_register_host (controller1, neighbour1, + ®istration_comp, neighbour1); + if (NULL == reg_handle) + { + GNUNET_break (0); + abort_test (); + return; + } break; default: - GNUNET_assert (0); - } + GNUNET_break (0); + abort_test (); + return; + } +} + + +/** + * Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to + * inform whether the given host is habitable or not. The Handle returned by + * GNUNET_TESTBED_is_host_habitable() is invalid after this callback is called + * + * @param cls NULL + * @param host the host whose status is being reported; will be NULL if the host + * given to GNUNET_TESTBED_is_host_habitable() is NULL + * @param status #GNUNET_YES if it is habitable; #GNUNET_NO if not + */ +static void +host_habitable_cb (void *cls, + const struct GNUNET_TESTBED_Host *_host, + int status) +{ + hc_handle = NULL; + if (GNUNET_NO == status) + { + (void) PRINTF ("%s", + "Unable to run the test as this system is not configured " + "to use password less SSH logins to localhost.\n" + "Skipping test\n"); + GNUNET_SCHEDULER_cancel (abort_task); + abort_task = NULL; + GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); + result = SKIP; + return; + } + cp1 = + GNUNET_TESTBED_controller_start ("127.0.0.1", host, status_cb, NULL); } @@ -678,11 +878,28 @@ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config) { - host = GNUNET_TESTBED_host_create (NULL, NULL, 0); - GNUNET_assert (NULL != host); cfg = GNUNET_CONFIGURATION_dup (config); - cp1 = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, - NULL); + host = GNUNET_TESTBED_host_create (NULL, NULL, cfg, 0); + if (NULL == host) + { + GNUNET_break (0); + abort_test (); + return; + } + if (NULL == + (hc_handle = + GNUNET_TESTBED_is_host_habitable (host, config, &host_habitable_cb, + NULL))) + { + GNUNET_TESTBED_host_destroy (host); + host = NULL; + (void) PRINTF ("%s", + "Unable to run the test as this system is not configured " + "to use password less SSH logins to localhost.\n" + "Skipping test\n"); + result = SKIP; + return; + } abort_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3), &do_abort, @@ -690,46 +907,6 @@ run (void *cls, char *const *args, const char *cfgfile, } -/** - * Function to check if - * 1. Password-less SSH logins to given ip work - * 2. gnunet-helper-testbed is found on the PATH on the remote side - * - * @param host_str numeric representation of the host's ip - * @return GNUNET_YES if password-less SSH login to the given host works; - * GNUNET_NO if not - */ -static int -check_ssh (char *host_str) -{ - char *const remote_args[] = { - "ssh", "-o", "BatchMode=yes", "-o", "CheckHostIP=no", - "-o", "NoHostAuthenticationForLocalhost=yes", "-q", - host_str, "which", "gnunet-helper-testbed", NULL - }; - // FIXME: the above no longer works with libexec/-installation! - struct GNUNET_OS_Process *auxp; - enum GNUNET_OS_ProcessStatusType type; - unsigned long code; - int ret; - - auxp = - GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, - NULL, "ssh", remote_args); - GNUNET_assert (NULL != auxp); - do - { - ret = GNUNET_OS_process_status (auxp, &type, &code); - GNUNET_assert (GNUNET_SYSERR != ret); - (void) usleep (300); - } - while (GNUNET_NO == ret); - (void) GNUNET_OS_process_wait (auxp); - GNUNET_OS_process_destroy (auxp); - return (0 != code) ? GNUNET_NO : GNUNET_YES; -} - - /** * Main function */ @@ -737,31 +914,30 @@ int main (int argc, char **argv) { char *const argv2[] = { "test_testbed_api_3peers_3controllers", - "-c", "test_testbed_api.conf", - NULL + "-c", "test_testbed_api.conf", + NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; int ret; - if (GNUNET_YES != check_ssh ("127.0.0.1")) - goto error_exit; result = INIT; ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, "test_testbed_api_3peers_3controllers", "nohelp", options, &run, NULL); - if ((GNUNET_OK != ret) || (SUCCESS != result)) + if (GNUNET_OK != ret) return 1; - return 0; - - error_exit: - (void) PRINTF ("%s", - "Unable to run the test as this system is not configured " - "to use password less SSH logins to localhost.\n" - "Marking test as successful\n"); - return 0; + switch (result) + { + case SUCCESS: + return 0; + case SKIP: + return 77; /* Mark test as skipped */ + default: + return 1; + } } /* end of test_testbed_api_3peers_3controllers.c */