plane hacking
[oweals/gnunet.git] / src / fs / test_fs_test_lib.c
index d35a91825fbc6e3bbdb14c813e68574370497823..930038da5f12286b47216f37ec16ad14b8e25f33 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
-     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
@@ -26,7 +26,7 @@
 #include "platform.h"
 #include "fs_test_lib.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 /**
  * File-size we use for testing.
@@ -36,7 +36,7 @@
 /**
  * How long until we give up on transmitting the message?
  */
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
 
 #define NUM_DAEMONS 2
 
@@ -46,15 +46,23 @@ static struct GNUNET_FS_TestDaemon *daemons[NUM_DAEMONS];
 
 static struct GNUNET_SCHEDULER_Handle *sched;
 
+static int ret;
 
 static void
 do_stop (void *cls,
         const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Finished download, shutting down\n",
-             (unsigned long long) FILESIZE);
+  if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
+    {
+      GNUNET_break (0);
+      ret = 1;
+    }
+  else
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Finished download, shutting down\n",
+                 (unsigned long long) FILESIZE);
+    }
   GNUNET_FS_TEST_daemons_stop (sched,
                               NUM_DAEMONS,
                               daemons);
@@ -65,7 +73,15 @@ static void
 do_download (void *cls,
             const struct GNUNET_FS_Uri *uri)
 {
-  GNUNET_assert (NULL != uri);
+  if (NULL == uri)
+    {
+      GNUNET_break (0);
+      GNUNET_SCHEDULER_add_now (sched,
+                               &do_stop,
+                               NULL);
+      ret = 1;
+      return;
+    }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Downloading %llu bytes\n",
              (unsigned long long) FILESIZE);
@@ -82,7 +98,15 @@ static void
 do_publish (void *cls,
            const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE));
+  if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
+    {
+      GNUNET_break (0);
+      ret = 1;
+      GNUNET_SCHEDULER_add_now (sched,
+                               &do_stop,
+                               NULL);
+      return;
+    }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Publishing %llu bytes\n",
              (unsigned long long) FILESIZE);
@@ -99,7 +123,15 @@ static void
 do_connect (void *cls,
            const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE));
+  if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
+    {
+      GNUNET_break (0);
+      ret = 1;
+      GNUNET_SCHEDULER_add_now (sched,
+                               &do_stop,
+                               NULL);
+      return;
+    }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Daemons started, will now try to connect them\n");
   GNUNET_FS_TEST_daemons_connect (sched,
@@ -120,6 +152,7 @@ run (void *cls,
 {
   sched = s;
   GNUNET_FS_TEST_daemons_start (sched,
+                               "fs_test_lib_data.conf",
                                TIMEOUT,
                                NUM_DAEMONS,
                                daemons,
@@ -132,7 +165,7 @@ int
 main (int argc, char *argv[])
 {
   char *const argvx[] = { 
-    "test-gnunet-service-fs-p2p",
+    "test-fs-test-lib",
     "-c",
     "fs_test_lib_data.conf",
 #if VERBOSE
@@ -145,7 +178,7 @@ main (int argc, char *argv[])
   };
 
   GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
-  GNUNET_log_setup ("test_gnunet_service_fs_p2p", 
+  GNUNET_log_setup ("test_fs_test_lib", 
 #if VERBOSE
                    "DEBUG",
 #else
@@ -153,10 +186,10 @@ main (int argc, char *argv[])
 #endif
                    NULL);
   GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
-                      argvx, "test-gnunet-service-fs-p2p",
+                      argvx, "test-fs-test-lib",
                      "nohelp", options, &run, NULL);
   GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
-  return 0;
+  return ret;
 }
 
-/* end of test_gnunet_service_fs_p2p.c */
+/* end of test_fs_test_lib.c */