*/
/**
- * @file fs/test_fs_lib.c
+ * @file fs/fs_test_lib.c
* @brief library routines for testing FS publishing and downloading
* with multiple peers; this code is limited to flat files
* and no keywords (those functions can be tested with
#include "fs_test_lib.h"
#include "gnunet_testing_lib.h"
+#define CONNECT_ATTEMPTS 4
/**
* Handle for a daemon started for testing FS.
daemon,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
+ case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
+ if (daemon->verbose)
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Download at %llu/%llu bytes\n",
+ (unsigned long long) info->value.download.completed,
+ (unsigned long long) info->value.download.size);
+ break;
case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
GNUNET_SCHEDULER_cancel (daemon->download_sched,
daemon->download_timeout_task);
daemon,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
break;
+ case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
+ case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:
+ break;
/* FIXME: monitor data correctness during download progress */
/* FIXME: do performance reports given sufficient verbosity */
/* FIXME: advance timeout task to "immediate" on error */
struct StartContext *sctx = cls;
unsigned int i;
- GNUNET_TESTING_daemons_stop (sctx->group);
+ GNUNET_TESTING_daemons_stop (sctx->group, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30));
for (i=0;i<sctx->total;i++)
{
if (i < sctx->have)
sctx->cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK !=
GNUNET_CONFIGURATION_load (sctx->cfg,
- "test_fs_lib_data.conf"))
+ "fs_test_lib_data.conf"))
{
GNUNET_break (0);
GNUNET_CONFIGURATION_destroy (sctx->cfg);
sctx->group = GNUNET_TESTING_daemons_start (sched,
sctx->cfg,
total,
+ timeout,
+ NULL,
+ NULL,
¬ify_running,
sctx,
NULL, NULL,
GNUNET_TESTING_daemons_connect (daemon1->daemon,
daemon2->daemon,
timeout,
+ CONNECT_ATTEMPTS,
¬ify_connection,
ncc);
}
* Stop daemons used for testing.
*
* @param sched scheduler to use
- * @param timeout if this operation cannot be completed within the
- * given period, call the continuation with an error code
* @param total number of daemons to stop
* @param daemons array with the daemons (values will be clobbered)
- * @param cont function to call when done
- * @param cont_cls closure for cont
*/
void
GNUNET_FS_TEST_daemons_stop (struct GNUNET_SCHEDULER_Handle *sched,
unsigned int i;
GNUNET_assert (total > 0);
- GNUNET_TESTING_daemons_stop (daemons[0]->group);
+ GNUNET_TESTING_daemons_stop (daemons[0]->group, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30));
for (i=0;i<total;i++)
{
GNUNET_FS_stop (daemons[i]->fs);
struct GNUNET_FS_TestDaemon *daemon = cls;
uint64_t pos;
uint8_t *cbuf = buf;
+ int mod;
for (pos=0;pos<max;pos++)
- cbuf[pos] = (uint8_t) ((offset * daemon->publish_seed) % (255 - (offset / 1024 / 32)));
+ {
+ mod = (255 - (offset / 1024 / 32));
+ if (mod == 0)
+ mod = 1;
+ cbuf[pos] = (uint8_t) ((offset * daemon->publish_seed) % mod);
+ }
return max;
}
daemon->publish_seed = seed;
daemon->verbose = verbose;
daemon->publish_sched = sched;
- fi = GNUNET_FS_file_information_create_from_reader (daemon,
+ fi = GNUNET_FS_file_information_create_from_reader (daemon->fs,
+ daemon,
size,
&file_generator,
daemon,
struct GNUNET_FS_TestDaemon *daemon = cls;
daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_FS_download_stop (daemon->download_context, GNUNET_YES);
+ daemon->download_context = NULL;
GNUNET_SCHEDULER_add_continuation (daemon->download_sched,
daemon->download_cont,
daemon->download_cont_cls,
* given period, call the continuation with an error code
* @param anonymity option for download
* @param seed used for file validation
+ * @param uri URI of file to download (CHK/LOC only)
* @param verbose how verbose to be in reporting
* @param cont function to call when done
* @param cont_cls closure for cont
daemon->download_seed = seed;
daemon->download_context = GNUNET_FS_download_start (daemon->fs,
uri,
- NULL,
+ NULL, NULL,
NULL,
0,
size,