- fix use of uninitialized memory
[oweals/gnunet.git] / src / arm / test_arm_api.c
index 271746e6b503289a8a7540e4a5f5731f595c4c91..33ab11f05a1446ae38ef9fb43ac571958668bca0 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2009, 2011 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009, 2011 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
 
      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.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
 */
 /**
  * @file arm/test_arm_api.c
  * @brief testcase for arm_api.c
  */
 #include "platform.h"
-#include "gnunet_common.h"
+#include "gnunet_util_lib.h"
 #include "gnunet_arm_service.h"
-#include "gnunet_client_lib.h"
-#include "gnunet_configuration_lib.h"
-#include "gnunet_getopt_lib.h"
-#include "gnunet_program_lib.h"
 #include "gnunet_resolver_service.h"
 
 #define LOG(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
@@ -47,19 +43,25 @@ static int ok = 1;
 static int phase = 0;
 
 static void
-arm_stop_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestStatus status, const char *servicename, enum GNUNET_ARM_Result result)
+arm_stop_cb (void *cls,
+            enum GNUNET_ARM_RequestStatus status,
+            const char *servicename,
+            enum GNUNET_ARM_Result result)
 {
   /* (6), a stop request should be sent to ARM successfully */
   /* ARM should report that it is stopping */
   GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
-  GNUNET_break (result == GNUNET_ARM_RESULT_STOPPING);
+  GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED);
   GNUNET_break (phase == 6);
   phase++;
   LOG ("Sent 'STOP' request for arm to ARM %s\n", (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully");
 }
 
+
 static void
-resolver_stop_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestStatus status, const char *servicename, enum GNUNET_ARM_Result result)
+resolver_stop_cb (void *cls,
+                 enum GNUNET_ARM_RequestStatus status,
+                 const char *servicename, enum GNUNET_ARM_Result result)
 {
   /* (5), a stop request should be sent to ARM successfully.
    * ARM should report that resolver is stopped.
@@ -77,6 +79,7 @@ resolver_stop_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_Reques
 #endif
 }
 
+
 static void
 dns_notify (void *cls, const struct sockaddr *addr, socklen_t addrlen)
 {
@@ -99,8 +102,12 @@ dns_notify (void *cls, const struct sockaddr *addr, socklen_t addrlen)
   ok = 0;
 }
 
+
 static void
-resolver_start_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestStatus status, const char *servicename, enum GNUNET_ARM_Result result)
+resolver_start_cb (void *cls,
+                  enum GNUNET_ARM_RequestStatus status,
+                  const char *servicename,
+                  enum GNUNET_ARM_Result result)
 {
   /* (2), the start request for resolver should be sent successfully
    * ARM should report that resolver service is starting.
@@ -113,6 +120,7 @@ resolver_start_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_Reque
   GNUNET_RESOLVER_ip_get ("localhost", AF_INET, TIMEOUT, &dns_notify, NULL);
 }
 
+
 static void
 trigger_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -121,8 +129,7 @@ trigger_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
 
 static void
-arm_conn (void *cls, 
-         struct GNUNET_ARM_Handle *arm, 
+arm_conn (void *cls,
          int connected)
 {
   if (GNUNET_SYSERR == connected)
@@ -156,28 +163,9 @@ arm_conn (void *cls,
 
 
 static void
-srv_status (void *cls, const char *service, enum GNUNET_ARM_ServiceStatus status)
-{
-  LOG ("Service %s is %u\n", service, status);
-  switch (phase)
-  {
-  default:
-    LOG ("Unexpectedly got status %u for service %s\n", status,
-        service);
-    GNUNET_break (0);
-    ok = 2;
-#if START_ARM
-    GNUNET_ARM_request_service_stop (arm, "arm", TIMEOUT, NULL, NULL);
-#endif
-  }
-}
-
-
-static void
-arm_start_cb (void *cls, 
-             struct GNUNET_ARM_Handle *h, 
-             enum GNUNET_ARM_RequestStatus status, 
-             const char *servicename, 
+arm_start_cb (void *cls,
+             enum GNUNET_ARM_RequestStatus status,
+             const char *servicename,
              enum GNUNET_ARM_Result result)
 {
   /* (0) The request should be "sent" successfully
@@ -197,21 +185,7 @@ static void
 task (void *cls, char *const *args, const char *cfgfile,
       const struct GNUNET_CONFIGURATION_Handle *c)
 {
-  char *armconfig;
   cfg = c;
-  if (NULL != cfgfile)
-  {
-    if (GNUNET_OK !=
-        GNUNET_CONFIGURATION_get_value_filename (cfg, "arm", "CONFIG",
-                                              &armconfig))
-    {
-      GNUNET_CONFIGURATION_set_value_string ((struct GNUNET_CONFIGURATION_Handle
-                                              *) cfg, "arm", "CONFIG",
-                                             cfgfile);
-    }
-    else
-      GNUNET_free (armconfig);
-  }
   arm = GNUNET_ARM_connect (cfg, &arm_conn, NULL);
   if (NULL == arm)
     return;