struct GNUNET_FS_TestDaemon
{
+ /**
+ * Global configuration, only stored in first test daemon,
+ * otherwise NULL.
+ */
+ struct GNUNET_CONFIGURATION_Handle *gcfg;
+
/**
* Handle to the file sharing context using this daemon.
*/
/**
* Check whether peers successfully shut down.
*/
-void shutdown_callback (void *cls,
- const char *emsg)
+static void
+shutdown_callback (void *cls,
+ const char *emsg)
{
+ struct GNUNET_CONFIGURATION_Handle *gcfg = cls;
+
if (emsg != NULL)
{
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Shutdown of peers failed!\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Shutdown of peers failed: %s\n",
+ emsg);
}
else
{
"All peers successfully shut down!\n");
#endif
}
+ if (gcfg != NULL)
+ GNUNET_CONFIGURATION_destroy (gcfg);
}
+
static void
report_uri (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
daemon->download_sched = NULL;
}
+
static void*
progress_cb (void *cls,
const struct GNUNET_FS_ProgressInfo *info)
sctx->cont,
sctx->cont_cls,
GNUNET_SCHEDULER_REASON_PREREQ_DONE);
- GNUNET_CONFIGURATION_destroy (sctx->cfg);
+ sctx->daemons[0]->gcfg = sctx->cfg;
GNUNET_SCHEDULER_cancel (sctx->sched,
sctx->timeout_task);
for (i=0;i<sctx->total;i++)
struct StartContext *sctx = cls;
unsigned int i;
- GNUNET_TESTING_daemons_stop (sctx->group, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), &shutdown_callback, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Timeout while trying to start daemons\n");
+ GNUNET_TESTING_daemons_stop (sctx->group,
+ GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30),
+ &shutdown_callback,
+ NULL);
for (i=0;i<sctx->total;i++)
{
if (i < sctx->have)
GNUNET_CONFIGURATION_destroy (sctx->daemons[i]->cfg);
GNUNET_free (sctx->daemons[i]);
+ sctx->daemons[i] = NULL;
}
GNUNET_CONFIGURATION_destroy (sctx->cfg);
GNUNET_SCHEDULER_add_continuation (sctx->sched,
void *cont_cls;
};
+
/**
* Prototype of a function that will be called whenever
* two daemons are connected by the testing library.
if (emsg != NULL)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to connect peers: %s\n"),
+ "Failed to connect peers: %s\n",
emsg);
GNUNET_SCHEDULER_add_continuation (cc->sched,
cc->cont,
}
+/**
+ * Obtain peer configuration used for testing.
+ *
+ * @param daemons array with the daemons
+ * @param off which configuration to get
+ * @return peer configuration
+ */
+const struct GNUNET_CONFIGURATION_Handle *
+GNUNET_FS_TEST_get_configuration (struct GNUNET_FS_TestDaemon **daemons,
+ unsigned int off)
+{
+ return daemons[off]->cfg;
+}
+
/**
* Obtain peer group used for testing.
*
{
unsigned int i;
struct GNUNET_TESTING_PeerGroup *pg;
+ struct GNUNET_CONFIGURATION_Handle *gcfg;
GNUNET_assert (total > 0);
pg = daemons[0]->group;
+ gcfg = daemons[0]->gcfg;
for (i=0;i<total;i++)
{
- GNUNET_FS_stop (daemons[i]->fs);
- GNUNET_CONFIGURATION_destroy (daemons[i]->cfg);
+ if (daemons[i]->fs != NULL)
+ GNUNET_FS_stop (daemons[i]->fs);
+ if (daemons[i]->cfg != NULL)
+ GNUNET_CONFIGURATION_destroy (daemons[i]->cfg);
GNUNET_free (daemons[i]);
daemons[i] = NULL;
}
- GNUNET_TESTING_daemons_stop (pg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), &shutdown_callback, NULL);
+ GNUNET_TESTING_daemons_stop (pg,
+ GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30),
+ &shutdown_callback,
+ gcfg);
}
{
struct GNUNET_FS_TestDaemon *daemon = cls;
GNUNET_FS_TEST_UriContinuation cont;
-
+
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Timeout while trying to publish data\n");
cont = daemon->publish_cont;
daemon->publish_timeout_task = GNUNET_SCHEDULER_NO_TASK;
daemon->publish_cont = NULL;
uint8_t *cbuf = buf;
int mod;
- for (pos=0;pos<max;pos++)
+ if (buf == NULL)
+ return 0;
+ for (pos=0;pos<8;pos++)
+ cbuf[pos] = (uint8_t) (offset >> pos*8);
+ for (pos=8;pos<max;pos++)
{
mod = (255 - (offset / 1024 / 32));
if (mod == 0)
{
struct GNUNET_FS_TestDaemon *daemon = cls;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Timeout while trying to download file\n");
daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_FS_download_stop (daemon->download_context, GNUNET_YES);
daemon->download_context = NULL;