change default configurations on systems with UNIX domain sockets to NOT specify...
[oweals/gnunet.git] / src / util / test_scheduler_delay.c
index 76cbf94d829e954874c8caee275f06fda13956a4..9cbf7d90f36eb2abf613fdb45c776d6367c7b3f3 100644 (file)
@@ -4,7 +4,7 @@
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -28,7 +28,7 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_EXTRA_LOGGING
 
 static struct GNUNET_TIME_Absolute target;
 
 
 static struct GNUNET_TIME_Absolute target;
 
@@ -52,26 +52,22 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   struct GNUNET_TIME_Absolute now;
 
   now = GNUNET_TIME_absolute_get ();
   struct GNUNET_TIME_Absolute now;
 
   now = GNUNET_TIME_absolute_get ();
-  if (now.value > target.value)
-    cumDelta += (now.value - target.value);
+  if (now.abs_value > target.abs_value)
+    cumDelta += (now.abs_value - target.abs_value);
   else
   else
-    cumDelta += (target.value - now.value);
+    cumDelta += (target.abs_value - now.abs_value);
   target =
   target =
-    GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply
-                                      (GNUNET_TIME_UNIT_MILLISECONDS, i));
-  fprintf (stderr, ".");
+      GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply
+                                        (GNUNET_TIME_UNIT_MILLISECONDS, i));
+  FPRINTF (stderr, "%s",  ".");
   if (i > MAXV)
   if (i > MAXV)
-    {
-      fprintf (stderr, "\n");
-      return;
-    }
-  GNUNET_SCHEDULER_add_delayed (tc->sched,
-                                GNUNET_NO,
-                                GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
-                                GNUNET_TIME_relative_multiply
-                                (GNUNET_TIME_UNIT_MILLISECONDS, i),
-                                &test_task, NULL);
+  {
+    FPRINTF (stderr, "%s",  "\n");
+    return;
+  }
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+                                (GNUNET_TIME_UNIT_MILLISECONDS, i), &test_task,
+                                NULL);
   i += INCR;
 }
 
   i += INCR;
 }
 
@@ -80,16 +76,16 @@ check ()
 {
   target = GNUNET_TIME_absolute_get ();
   GNUNET_SCHEDULER_run (&test_task, NULL);
 {
   target = GNUNET_TIME_absolute_get ();
   GNUNET_SCHEDULER_run (&test_task, NULL);
-  FPRINTF (stdout,
-           "Sleep precision: %llu ms. ", cumDelta / 1000 / (MAXV / INCR));
+  FPRINTF (stdout, "Sleep precision: %llu ms. ",
+           cumDelta / 1000 / (MAXV / INCR));
   if (cumDelta <= 10 * MAXV / INCR)
   if (cumDelta <= 10 * MAXV / INCR)
-    fprintf (stdout, "Timer precision is excellent.\n");
+    FPRINTF (stdout, "%s",  "Timer precision is excellent.\n");
   else if (cumDelta <= 50 * MAXV / INCR)        /* 50 ms average deviation */
   else if (cumDelta <= 50 * MAXV / INCR)        /* 50 ms average deviation */
-    fprintf (stdout, "Timer precision is good.\n");
+    FPRINTF (stdout, "%s",  "Timer precision is good.\n");
   else if (cumDelta > 250 * MAXV / INCR)
   else if (cumDelta > 250 * MAXV / INCR)
-    fprintf (stdout, "Timer precision is awful.\n");
+    FPRINTF (stdout, "%s",  "Timer precision is awful.\n");
   else
   else
-    fprintf (stdout, "Timer precision is acceptable.\n");
+    FPRINTF (stdout, "%s",  "Timer precision is acceptable.\n");
   return 0;
 }
 
   return 0;
 }