-fix fix
[oweals/gnunet.git] / src / mesh / test_mesh_2dtorus.c
index 718ab0864cd9a74bbd27bc1878778f28f86d42e7..4c1e406efe96eab1cc0657cd3433f673ca0f8a96 100644 (file)
@@ -25,7 +25,6 @@
 #include "platform.h"
 #include "gnunet_testing_lib.h"
 
-#define VERBOSE GNUNET_YES
 #define REMOVE_DIR GNUNET_YES
 
 /**
@@ -104,38 +103,30 @@ shutdown_callback (void *cls, const char *emsg)
   if (emsg != NULL)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "test: Shutdown of peers failed! (%s)\n",
-                emsg);
+                "test: Shutdown of peers failed! (%s)\n", emsg);
     ok--;
   }
-#if VERBOSE
   else
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "test: All peers successfully shut down!\n");
   }
-#endif
+  GNUNET_CONFIGURATION_destroy (testing_cfg);
 }
 
 
 static void
 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-#if VERBOSE
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "test: Ending test.\n");
-#endif
-
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Ending test.\n");
   GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
-  GNUNET_CONFIGURATION_destroy (testing_cfg);
 }
 
 
 static void
 disconnect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "test: disconnecting peers\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: disconnecting peers\n");
 
   if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle)
   {
@@ -162,33 +153,26 @@ topo_cb (void *cls, const struct GNUNET_PeerIdentity *first,
   topo_connections++;
   if (NULL != emsg)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "test: Error by topo %u: %s\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "test: Error by topo %u: %s\n",
                 topo_connections, emsg);
   }
   else
   {
     if (first == NULL || second == NULL)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "test: Connection %u NULL\n",
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Connection %u NULL\n",
                   topo_connections);
       if (disconnect_task != GNUNET_SCHEDULER_NO_TASK)
       {
         GNUNET_SCHEDULER_cancel (disconnect_task);
-        GNUNET_SCHEDULER_add_now(&disconnect_peers, NULL);
+        disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
       }
       return;
     }
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "test: Connection %u ok\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Connection %u ok\n",
                 topo_connections);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "test:   %s\n",
-                GNUNET_i2s (first));
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "test:   %s\n",
-                GNUNET_i2s (second));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:   %s\n", GNUNET_i2s (first));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:   %s\n", GNUNET_i2s (second));
   }
 }
 
@@ -205,28 +189,20 @@ peergroup_ready (void *cls, const char *emsg)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "test: Peergroup callback called with error, aborting test!\n");
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "test: Error from testing: `%s'\n", emsg);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Error from testing: `%s'\n",
+                emsg);
     ok--;
     GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
     return;
   }
-#if VERBOSE
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "************************************************************\n");
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "test: Peer Group started successfully!\n");
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "test: Have %u connections\n",
+              "test: Peer Group started successfully with %u connections\n",
               total_connections);
-#endif
-
   peers_running = GNUNET_TESTING_daemons_running (pg);
   if (0 < failed_connections)
   {
     ok = GNUNET_SYSERR;
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "test: %u connections have FAILED!\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "test: %u connections have FAILED!\n",
                 failed_connections);
     disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
 
@@ -272,12 +248,9 @@ connect_cb (void *cls, const struct GNUNET_PeerIdentity *first,
   {
     failed_connections++;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "test: Problem with new connection (%s)\n",
-                emsg);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:   (%s)\n",
-                GNUNET_i2s (first));
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:   (%s)\n",
-                GNUNET_i2s (second));
+                "test: Problem with new connection (%s)\n", emsg);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:   (%s)\n", GNUNET_i2s (first));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:   (%s)\n", GNUNET_i2s (second));
   }
 
 }
@@ -302,22 +275,13 @@ run (void *cls, char *const *args, const char *cfgfile,
   testing_cfg = GNUNET_CONFIGURATION_dup (cfg);
 
   GNUNET_log_setup ("test_mesh_2dtorus",
-#if VERBOSE
-                    "DEBUG",
-#else
                     "WARNING",
-#endif
                     NULL);
 
-#if VERBOSE
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "test: Starting daemons.\n");
-  GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing",
-                                         "use_progressbars", "YES");
-#endif
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Starting daemons.\n");
   if (GNUNET_OK !=
-      GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing",
+      GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing_old",
                                              "num_peers", &num_peers))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -332,7 +296,7 @@ run (void *cls, char *const *args, const char *cfgfile,
                                        hosts);
   GNUNET_assert (pg != NULL);
   shutdown_handle =
-      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (),
+    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
                                     &shutdown_task, NULL);
 }
 
@@ -358,10 +322,6 @@ main (int argc, char *argv[])
     argv[0],
     "-c",
     "test_mesh_2dtorus.conf",
-#if VERBOSE
-    "-L",
-    "DEBUG",
-#endif
     NULL
   };
 
@@ -369,16 +329,14 @@ main (int argc, char *argv[])
 
 
   GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
-                      "test_mesh_2dtorus",
-                      gettext_noop ("Test mesh 2d torus."), options,
-                      &run, NULL);
+                      "test_mesh_2dtorus", gettext_noop ("Test mesh 2d torus."),
+                      options, &run, NULL);
 #if REMOVE_DIR
   GNUNET_DISK_directory_remove ("/tmp/test_mesh_2dtorus");
 #endif
   if (GNUNET_OK != ok)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "test: FAILED!\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "test: FAILED!\n");
     return 1;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: success\n");