-improve UDP logging
[oweals/gnunet.git] / src / testbed / test_testbed_api_barriers.c
index 35fda4b31a91d3e330db58b14d9eb2b0d61092b9..fc5ecc4acd048b8ba47581ce30efe531b5468812 100644 (file)
@@ -1,6 +1,6 @@
 /*
       This file is part of GNUnet
-      (C) 2008--2013 Christian Grothoff (and other contributing authors)
+      Copyright (C) 2008--2013 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
@@ -21,7 +21,7 @@
 /**
  * @file testbed/test_testbed_api_barriers.c
  * @brief testcase binary for testing testbed barriers API
- * @author Sree Harsha Totakura <sreeharsha@totakura.in> 
+ * @author Sree Harsha Totakura <sreeharsha@totakura.in>
  */
 
 #include "platform.h"
@@ -50,7 +50,7 @@ struct GNUNET_TESTBED_Barrier *barrier;
 /**
  * Identifier for the shutdown task
  */
-static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
+static struct GNUNET_SCHEDULER_Task * shutdown_task;
 
 /**
  * Result of this test case
@@ -67,13 +67,13 @@ static int result;
 static void
 do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  shutdown_task = GNUNET_SCHEDULER_NO_TASK;
+  shutdown_task = NULL;
   if (NULL != barrier)
   {
     GNUNET_TESTBED_barrier_cancel (barrier);
     barrier = NULL;
   }
-  
+
   GNUNET_SCHEDULER_shutdown ();
 }
 
@@ -99,24 +99,24 @@ barrier_cb (void *cls,
             const char *emsg)
 {
   static enum GNUNET_TESTBED_BarrierStatus old_status;
-  
+
   GNUNET_assert (NULL == cls);
   GNUNET_assert (_barrier == barrier);
   switch (status)
   {
-  case BARRIER_STATUS_INITIALISED:
+  case GNUNET_TESTBED_BARRIERSTATUS_INITIALISED:
     LOG (GNUNET_ERROR_TYPE_INFO, "Barrier initialised\n");
     old_status = status;
     return;
-  case BARRIER_STATUS_ERROR:
-    LOG (GNUNET_ERROR_TYPE_ERROR, "Barrier initialisation failed: %s", 
+  case GNUNET_TESTBED_BARRIERSTATUS_ERROR:
+    LOG (GNUNET_ERROR_TYPE_ERROR, "Barrier initialisation failed: %s",
          (NULL == emsg) ? "unknown reason" : emsg);
     barrier = NULL;
-    GNUNET_SCHEDULER_shutdown ();    
+    GNUNET_SCHEDULER_shutdown ();
     return;
-  case BARRIER_STATUS_CROSSED:
+  case GNUNET_TESTBED_BARRIERSTATUS_CROSSED:
     LOG (GNUNET_ERROR_TYPE_INFO, "Barrier crossed\n");
-    if (old_status == BARRIER_STATUS_INITIALISED) 
+    if (old_status == GNUNET_TESTBED_BARRIERSTATUS_INITIALISED)
       result = GNUNET_OK;
     barrier = NULL;
     GNUNET_SCHEDULER_shutdown ();
@@ -161,7 +161,7 @@ test_master (void *cls,
                                          &barrier_cb, NULL);
   shutdown_task =
       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
-                                    (GNUNET_TIME_UNIT_SECONDS, 
+                                    (GNUNET_TIME_UNIT_SECONDS,
                                      10 * (NUM_PEERS + 1)),
                                     &do_shutdown, NULL);
 }
@@ -173,14 +173,33 @@ test_master (void *cls,
 int
 main (int argc, char **argv)
 {
+  struct GNUNET_CONFIGURATION_Handle *cfg;
+  char pwd[PATH_MAX];
+  char *binary;
   uint64_t event_mask;
 
   result = GNUNET_SYSERR;
   event_mask = 0;
+  cfg = GNUNET_CONFIGURATION_create ();
+  GNUNET_assert (GNUNET_YES ==
+                 GNUNET_CONFIGURATION_parse (cfg,
+                                             "test_testbed_api_barriers.conf.in"));
+  if (NULL == getcwd (pwd, PATH_MAX))
+    return 1;
+  GNUNET_assert (0 < GNUNET_asprintf (&binary, "%s/%s", pwd,
+                                      "gnunet-service-test-barriers"));
+  GNUNET_CONFIGURATION_set_value_string (cfg, "test-barriers","BINARY", binary);
+  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_write
+                 (cfg, "test_testbed_api_barriers.conf"));
+  GNUNET_CONFIGURATION_destroy (cfg);
+  cfg = NULL;
+  GNUNET_free (binary);
+  binary = NULL;
   (void) GNUNET_TESTBED_test_run ("test_testbed_api_barriers",
                                   "test_testbed_api_barriers.conf", NUM_PEERS,
                                   event_mask, NULL, NULL,
                                   &test_master, NULL);
+  (void) unlink ("test_testbed_api_barriers.conf");
   if (GNUNET_OK != result)
     return 1;
   return 0;