-makefile for new test_stream_local (commented)
[oweals/gnunet.git] / src / transport / test_transport_api_timeout.c
index 9a16447f3dd4f7ad69fef6edb6c6f6f7fc79b11a..9ce701a6fc4cc7413280b1318d251c6ce5fafa96 100644 (file)
@@ -38,9 +38,9 @@
 #include "transport.h"
 #include "transport-testing.h"
 
-#define VERBOSE GNUNET_EXTRA_LOGGING
+#define VERBOSE GNUNET_NO
 
-#define VERBOSE_ARM GNUNET_EXTRA_LOGGING
+#define VERBOSE_ARM GNUNET_NO
 
 #define START_ARM GNUNET_YES
 
@@ -87,7 +87,7 @@ static int disconnects;
 
 
 #if VERBOSE
-#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
+#define OKPP do { ok++; FPRINTF (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
 #else
 #define OKPP do { ok++; } while (0)
 #endif
@@ -210,13 +210,13 @@ timer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   if (time_running.rel_value ==
       GNUNET_TIME_relative_max (time_running, WAIT).rel_value)
   {
-    fprintf (stderr, "100%%\n");
+    FPRINTF (stderr, "%s",  "100%%\n");
     shutdown_flag = GNUNET_YES;
     GNUNET_SCHEDULER_add_now (&end, NULL);
   }
   else
   {
-    fprintf (stderr, "%u%%..", percentage);
+    FPRINTF (stderr, "%u%%..", percentage);
     timer_task =
         GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (WAIT, 10),
                                       &timer, NULL);
@@ -227,7 +227,7 @@ static void
 testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
 {
   cc = NULL;
-  char *p1_c = strdup (GNUNET_i2s (&p1->id));
+  char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c,
               GNUNET_i2s (&p2->id));
@@ -235,6 +235,12 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
 
   shutdown_flag = GNUNET_NO;
 
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Waiting for %llu seconds\n", (WAIT.rel_value) / 1000);
+
+  if (die_task != GNUNET_SCHEDULER_NO_TASK)
+    GNUNET_SCHEDULER_cancel (die_task);
+  die_task = GNUNET_SCHEDULER_add_delayed (WAIT, &end_badly, NULL);
+
   timer_task = GNUNET_SCHEDULER_add_now (&timer, NULL);
 }
 
@@ -251,7 +257,7 @@ start_cb (struct PeerContext *p, void *cls)
   if (started != 2)
     return;
 
-  char *sender_c = strdup (GNUNET_i2s (&p1->id));
+  char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
@@ -319,7 +325,6 @@ int
 main (int argc, char *argv[])
 {
   int ret;
-  int nat_res;
 
   GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
 
@@ -337,24 +342,6 @@ main (int argc, char *argv[])
 
   tth = GNUNET_TRANSPORT_TESTING_init ();
 
-  if ((strcmp (test_plugin, "tcp_nat") == 0) ||
-      (strcmp (test_plugin, "udp_nat") == 0))
-  {
-    nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server");
-    if (GNUNET_NO == nat_res)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Cannot run NAT test: `%s' %s \n",
-                  "gnunet-nat-server", "SUID not set");
-      return 0;
-    }
-    if (GNUNET_SYSERR == nat_res)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Cannot run NAT test: `%s' %s \n",
-                  "gnunet-nat-server", "file not found");
-      return 0;
-    }
-  }
-
   GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
   GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);