* @file transport/test_transport_api.c
* @brief testcase for transport_api.c
* @author Sailor Siraj
+ * @author Christian Grothoff
*/
#include "platform.h"
#include "plugin_transport.h"
#include "transport.h"
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
/**
* How long until we give up on transmitting the message?
/**
* Our configuration.
*/
-struct GNUNET_CONFIGURATION_Handle *cfg;
+const struct GNUNET_CONFIGURATION_Handle *cfg;
/**
* Number of neighbours we'd like to have.
* @param cfg configuration to use
*/
static void
-unload_plugins (void *cls, struct GNUNET_CONFIGURATION_Handle *cfg)
+unload_plugins (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
{
GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_tcp",api));
if (my_private_key != NULL)
}
+static void
+unload_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+ unload_plugins (NULL, cfg);
+}
+
+
static GNUNET_SCHEDULER_TaskIdentifier validation_timeout_task;
/* Sailor: 'test_validation' should get here
if the validation worked; so we cancel the
"delayed" task that will cause failure */
- if (validation_timeout_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK)
+ if (validation_timeout_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (sched, validation_timeout_task);
- validation_timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+ validation_timeout_task = GNUNET_SCHEDULER_NO_TASK;
}
GNUNET_assert (challenge == 42);
/* Sailor: if this is the last test, calling this function
here will end the process. */
ok = 0; /* if the last test succeeded, report success */
- unload_plugins (NULL, cfg);
+ GNUNET_SCHEDULER_add_continuation (sched,
+ &unload_task,
+ (void*) cfg,
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
}
validation_failed (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- validation_timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
+ validation_timeout_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_break (0); /* output error */
/* the "validation_notification" was not called
in a timely fashion; we should set an error
* work for other plugins; we should ask
* the plugin about its address instead...).
*/
+/* FIXME: won't work on IPv6 enabled systems where IPv4 bridge
+ * mode isn't enabled (eg. FreeBSD > 4)
+ */
static void
test_validation ()
{
struct sockaddr_in soaddr;
memset (&soaddr, 0, sizeof(soaddr));
+#if HAVE_SOCKADDR_IN_SIN_LEN
+ soaddr.sin_len = sizeof (soaddr);
+#endif
soaddr.sin_family = AF_INET;
/* Sailor: set this port to 2367 to see the
testcase fail after 30s (because validation
/* add job to catch failure (timeout) */
validation_timeout_task =
GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_NO,
- GNUNET_SCHEDULER_PRIORITY_KEEP,
- GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
TIMEOUT,
&validation_failed,
NULL);
struct GNUNET_SCHEDULER_Handle *s,
char *const *args,
const char *cfgfile,
- struct GNUNET_CONFIGURATION_Handle *c)
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
unsigned long long tneigh;
char *keyfile;
GNUNET_asprintf (&libname, "libgnunet_plugin_transport_tcp");
api = GNUNET_PLUGIN_load(libname, &env);
+ GNUNET_free (libname);
if (api == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
static struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
+ int ret;
char *const argv_prog[] = {
"test_plugin_transport",
"-c",
#endif
NULL);
ok = 1; /* set to fail */
- return (GNUNET_OK ==
+ ret = (GNUNET_OK ==
GNUNET_PROGRAM_run (5,
argv_prog,
"test-plugin-transport",
"testcase",
options,
&run, NULL)) ? ok : 1;
+ GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport");
+ return ret;
}
/* end of test_plugin_transport.c */