/**
* @file fs/test_fs_download.c
- * @brief simple testcase for download
+ * @brief simple testcase for simple publish + download operation
* @author Christian Grothoff
*/
#define START_ARM GNUNET_YES
+/**
+ * File-size we use for testing.
+ */
#define FILESIZE (1024 * 1024 * 2)
/**
static struct PeerContext p1;
+static struct GNUNET_TIME_Absolute start;
static struct GNUNET_SCHEDULER_Handle *sched;
static void
-abort_download_task (void *cls,
+abort_publish_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_FS_download_stop (download, GNUNET_YES);
- download = NULL;
+ GNUNET_FS_publish_stop (publish);
+ publish = NULL;
}
static void
-abort_publish_task (void *cls,
+abort_download_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_FS_publish_stop (publish);
- publish = NULL;
+ GNUNET_FS_download_stop (download, GNUNET_YES);
+ download = NULL;
}
#endif
break;
case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
-#if VERBOSE
- printf ("Publish complete.\n");
-#endif
- GNUNET_SCHEDULER_add_continuation (sched,
- GNUNET_NO,
- &abort_publish_task,
- NULL,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ printf ("Publishing complete, %llu kbps.\n",
+ (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024));
fn = GNUNET_DISK_mktemp ("gnunet-download-test-dstXXXXXX");
+ start = GNUNET_TIME_absolute_get ();
download = GNUNET_FS_download_start (fs,
event->value.publish.specifics.completed.chk_uri,
NULL,
GNUNET_assert (download != NULL);
break;
case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
-#if VERBOSE
- printf ("Download complete.\n");
-#endif
+ printf ("Download complete, %llu kbps.\n",
+ (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024));
GNUNET_SCHEDULER_add_continuation (sched,
GNUNET_NO,
&abort_download_task,
break;
case GNUNET_FS_STATUS_PUBLISH_STOPPED:
/* FIXME: add checks here... */
+ GNUNET_FS_stop (fs);
+ fs = NULL;
break;
case GNUNET_FS_STATUS_DOWNLOAD_START:
/* FIXME: add checks here... */
break;
case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
/* FIXME: add checks here... */
- GNUNET_FS_stop (fs);
- fs = NULL;
+ GNUNET_SCHEDULER_add_continuation (sched,
+ GNUNET_NO,
+ &abort_publish_task,
+ NULL,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
default:
printf ("Unexpected event: %d\n",
GNUNET_FS_uri_destroy (kuri);
GNUNET_CONTAINER_meta_data_destroy (meta);
GNUNET_assert (NULL != fi);
+ start = GNUNET_TIME_absolute_get ();
publish = GNUNET_FS_publish_start (fs,
"publish-context",
fi,