/*
This file is part of GNUnet.
Copyright (C) 2009, 2014 GNUnet e.V.
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
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 .
*/
/**
* @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)
{
GNUNET_ARM_disconnect (arm);
arm = NULL;
}
static void
arm_stop_cb (void *cls,
enum GNUNET_ARM_RequestStatus status,
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