arg
[oweals/gnunet.git] / src / fs / test_fs_download.c
index 44e2cc48bca0508c7c236d1c9afb7534d2e0d8a9..6bc287da345c4cf9df892c5d3842cb68ab242642 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2004, 2005, 2006, 2008, 2009 Christian Grothoff (and other contributing authors)
+     (C) 2004, 2005, 2006, 2008, 2009, 2011 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
@@ -150,10 +150,10 @@ progress_cb (void *cls,
 #endif      
       break;
     case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
-      printf ("Publishing complete, %llu kbps.\n",
+      printf ("Publishing complete, %llu kb/s.\n",
              (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL));
       GAUGER ("FS",
-             "Publishing speed",
+             "Publishing speed (insertion)",
              (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL),
              "kb/s");      
       fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst");
@@ -171,10 +171,10 @@ progress_cb (void *cls,
       GNUNET_assert (download != NULL);
       break;
     case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
-      printf ("Download complete,  %llu kbps.\n",
+      printf ("Download complete,  %llu kb/s.\n",
              (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL));
       GAUGER ("FS",
-             "Local download speed",
+             "Local download speed (inserted)",
              (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL),
              "kb/s");      
       GNUNET_SCHEDULER_add_now (&abort_download_task,
@@ -267,14 +267,17 @@ static void
 stop_arm (struct PeerContext *p)
 {
 #if START_ARM
-  if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-  if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
-  GNUNET_OS_process_close (p->arm_proc);
-  p->arm_proc = NULL;
+  if (NULL != p->arm_proc)
+    {
+      if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
+       GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+      if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
+       GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+      GNUNET_OS_process_close (p->arm_proc);    
+      p->arm_proc = NULL;
+    }
 #endif
   GNUNET_CONFIGURATION_destroy (p->cfg);
 }
@@ -295,6 +298,7 @@ run (void *cls,
   struct GNUNET_FS_Uri *kuri;
   struct GNUNET_FS_FileInformation *fi;
   size_t i;
+  struct GNUNET_FS_BlockOptions bo;
 
   setup_peer (&p1, "test_fs_download_data.conf");
   fs = GNUNET_FS_start (cfg,
@@ -309,6 +313,10 @@ run (void *cls,
     buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
   meta = GNUNET_CONTAINER_meta_data_create ();
   kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
+  bo.content_priority = 42;
+  bo.anonymity_level = 1;
+  bo.replication_level = 0;
+  bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 
   fi = GNUNET_FS_file_information_create_from_data (fs,
                                                    "publish-context",
                                                    FILESIZE,
@@ -316,9 +324,7 @@ run (void *cls,
                                                    kuri,
                                                    meta,
                                                    GNUNET_NO,
-                                                   1,
-                                                   42,
-                                                   GNUNET_TIME_relative_to_absolute (LIFETIME)); 
+                                                   &bo);
   GNUNET_FS_uri_destroy (kuri);
   GNUNET_CONTAINER_meta_data_destroy (meta);
   GNUNET_assert (NULL != fi);