/* This file is part of GNUnet. Copyright (C) 2009, 2014 Christian Grothoff (and other contributing authors) 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file arm/test_gnunet_service_arm.c * @brief testcase for gnunet-service-arm.c; tests ARM by making it start the resolver * @author Safey * @author Christian Grothoff */ #include "platform.h" #include "gnunet_arm_service.h" #include "gnunet_resolver_service.h" #include "gnunet_os_lib.h" #include "gnunet_program_lib.h" /** * Timeout for starting services, very short because of the strange way start works * (by checking if running before starting, so really this time is always waited on * startup (annoying)). */ #define START_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 50) #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) static int ret = 1; static int resolved_ok; static int asked_for_a_list; static struct GNUNET_ARM_Handle *arm; static void trigger_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_ARM_disconnect_and_free (arm); arm = NULL; } static void arm_stop_cb (void *cls, enum GNUNET_ARM_RequestStatus status, const char *servicename, enum GNUNET_ARM_Result result) { GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED); if (result != GNUNET_ARM_RESULT_STOPPED) { GNUNET_break (0); ret = 4; } GNUNET_SCHEDULER_add_now (&trigger_disconnect, NULL); } static void service_list (void *cls, enum GNUNET_ARM_RequestStatus rs, unsigned int count, const char *const*list) { unsigned int i; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u services are are currently running\n", count); if (GNUNET_ARM_REQUEST_SENT_OK != rs) goto stop_arm; for (i=0;i