[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23375 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23375 - gnunet/src/transport |
Date: |
Thu, 23 Aug 2012 13:48:27 +0200 |
Author: wachs
Date: 2012-08-23 13:48:27 +0200 (Thu, 23 Aug 2012)
New Revision: 23375
Modified:
gnunet/src/transport/Makefile.am
gnunet/src/transport/plugin_transport_udp_broadcasting.c
gnunet/src/transport/test_plugin_transport.c
Log:
plugin test
Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am 2012-08-23 10:01:46 UTC (rev 23374)
+++ gnunet/src/transport/Makefile.am 2012-08-23 11:48:27 UTC (rev 23375)
@@ -47,6 +47,7 @@
WLAN_BIN_DUMMY = gnunet-helper-transport-wlan-dummy
WLAN_BIN_SENDER = gnunet-transport-wlan-sender
WLAN_PLUGIN_LA = libgnunet_plugin_transport_wlan.la
+ WLAN_PLUGIN_TEST = test_plugin_wlan
WLAN_API_TEST = test_transport_api_wlan
WLAN_REL_TEST = test_transport_api_reliability_wlan
WLAN_UREL_TEST = test_transport_api_unreliability_wlan
@@ -295,6 +296,10 @@
test_transport_testing_restart \
test_transport_testing \
test_transport_startonly \
+ test_plugin_tcp \
+ test_plugin_udp \
+ test_plugin_unix \
+ $(WLAN_PLUGIN_TEST) \
test_transport_api_blacklisting \
test_transport_api_disconnect_tcp \
test_transport_api_bidirectional_connect \
@@ -342,6 +347,10 @@
test_transport_testing_restart \
test_transport_testing \
test_transport_startonly \
+ test_plugin_tcp \
+ test_plugin_udp \
+ test_plugin_unix \
+ $(WLAN_PLUGIN_TEST) \
test_transport_api_blacklisting \
test_transport_api_disconnect_tcp \
test_transport_api_bidirectional_connect \
@@ -435,6 +444,42 @@
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/transport/libgnunettransporttesting.la
+test_plugin_tcp_SOURCES = \
+ test_plugin_transport.c
+test_plugin_tcp_LDADD = \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport/libgnunettransporttesting.la
+
+test_plugin_udp_SOURCES = \
+ test_plugin_transport.c
+test_plugin_udp_LDADD = \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport/libgnunettransporttesting.la
+
+test_plugin_unix_SOURCES = \
+ test_plugin_transport.c
+test_plugin_unix_LDADD = \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport/libgnunettransporttesting.la
+
+test_plugin_wlan_SOURCES = \
+ test_plugin_transport.c
+test_plugin_wlan_LDADD = \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport/libgnunettransporttesting.la
+
test_transport_api_tcp_SOURCES = \
test_transport_api.c
test_transport_api_tcp_LDADD = \
Modified: gnunet/src/transport/plugin_transport_udp_broadcasting.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp_broadcasting.c 2012-08-23
10:01:46 UTC (rev 23374)
+++ gnunet/src/transport/plugin_transport_udp_broadcasting.c 2012-08-23
11:48:27 UTC (rev 23375)
@@ -228,6 +228,8 @@
const struct GNUNET_MessageHeader *hello;
hello = plugin->env->get_our_hello ();
+ if (NULL == hello)
+ return 0;
hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
msg_size = hello_size + sizeof (struct UDP_Beacon_Message);
@@ -258,7 +260,7 @@
sent = 0;
baddr = plugin->ipv4_broadcast_head;
/* just IPv4 */
- while ((baddr != NULL) && (baddr->addrlen == sizeof (struct sockaddr_in)))
+ while ((msg_size > 0) && (baddr != NULL) && (baddr->addrlen == sizeof
(struct sockaddr_in)))
{
struct sockaddr_in *addr = (struct sockaddr_in *) baddr->addr;
Modified: gnunet/src/transport/test_plugin_transport.c
===================================================================
--- gnunet/src/transport/test_plugin_transport.c 2012-08-23 10:01:46 UTC
(rev 23374)
+++ gnunet/src/transport/test_plugin_transport.c 2012-08-23 11:48:27 UTC
(rev 23375)
@@ -40,7 +40,8 @@
/**
* How long until we give up on transmitting the message?
*/
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
+#define WAIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+#define TIMEOUT GNUNET_TIME_relative_multiply (WAIT, 3)
/**
* Our public key.
@@ -68,6 +69,11 @@
struct GNUNET_STATISTICS_Handle *stats;
/**
+ * Our HELLO
+ */
+struct GNUNET_HELLO_Message *hello;
+
+/**
* Number of neighbours we'd like to have.
*/
static uint32_t max_connect_per_transport;
@@ -88,13 +94,27 @@
static GNUNET_SCHEDULER_TaskIdentifier timeout_task;
/**
+ * Timeout task
+ */
+static GNUNET_SCHEDULER_TaskIdentifier timeout_wait;
+
+/**
* Library name
*/
static char *libname;
+/**
+ * Plugin addresses head
+ */
struct AddressWrapper *head;
+
+/**
+ * Plugin addresses tail
+ */
struct AddressWrapper *tail;
+unsigned int addresses_reported;
+
/**
* Did the test pass or fail?
*/
@@ -115,21 +135,13 @@
static void
end ()
{
- if (NULL != head)
- {
-
- }
-
if (GNUNET_SCHEDULER_NO_TASK != timeout_task)
{
GNUNET_SCHEDULER_cancel (timeout_task);
timeout_task = GNUNET_SCHEDULER_NO_TASK;
}
-
if (NULL != api)
- {
GNUNET_PLUGIN_unload (libname, api);
- }
GNUNET_free (libname);
libname = NULL;
GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
@@ -139,13 +151,16 @@
}
static void
-
end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct AddressWrapper *w;
int c = 0;
-
timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ if (GNUNET_SCHEDULER_NO_TASK != timeout_wait)
+ {
+ GNUNET_SCHEDULER_cancel (timeout_wait);
+ timeout_wait = GNUNET_SCHEDULER_NO_TASK;
+ }
if (NULL != libname)
{
if (NULL != api)
@@ -178,10 +193,25 @@
ok = 1;
}
+static void
+wait_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ timeout_wait = GNUNET_SCHEDULER_NO_TASK;
+ if (0 == addresses_reported)
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Plugin did not report any addresses, could not check plugin
\n"));
+ end ();
+}
+
static void
end_badly_now ()
{
+ if (GNUNET_SCHEDULER_NO_TASK != timeout_wait)
+ {
+ GNUNET_SCHEDULER_cancel (timeout_wait);
+ timeout_wait = GNUNET_SCHEDULER_NO_TASK;
+ }
if (GNUNET_SCHEDULER_NO_TASK != timeout_task)
{
GNUNET_SCHEDULER_cancel (timeout_task);
@@ -202,7 +232,6 @@
uint16_t sender_address_len)
{
/* do nothing */
- GNUNET_break (0);
return GNUNET_TIME_relative_get_zero_();
}
@@ -220,7 +249,8 @@
if (GNUNET_YES == add_remove)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ addresses_reported ++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Adding address of length %u\n"), addrlen);
w = GNUNET_malloc (sizeof (struct AddressWrapper));
@@ -271,10 +301,16 @@
end_badly_now();
return;
}
+ if (GNUNET_SCHEDULER_NO_TASK != timeout_wait)
+ {
+ GNUNET_SCHEDULER_cancel (timeout_wait);
+ timeout_wait = GNUNET_SCHEDULER_NO_TASK;
+ }
+ timeout_wait = GNUNET_SCHEDULER_add_delayed (WAIT, &wait_end, NULL);
}
else if (GNUNET_NO == add_remove)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Removing address of length %u\n"), addrlen);
w = head;
@@ -304,8 +340,9 @@
{
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Invalid operation\n"));
+ _("Invalid operation: %u \n"), add_remove);
end_badly_now ();
+ return;
}
}
@@ -315,17 +352,15 @@
size_t addrlen)
{
struct GNUNET_ATS_Information ats;
- ats.type = htonl (0);
- ats.value = htonl (0);
+ ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
+ ats.value = htonl (GNUNET_ATS_NET_LOOPBACK);
return ats;
}
-
const struct GNUNET_MessageHeader *
env_get_our_hello (void)
{
- GNUNET_break (0);
- return NULL;
+ return (const struct GNUNET_MessageHeader *) hello;
}
void env_session_end (void *cls,
@@ -409,6 +444,9 @@
GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key),
&my_identity.hashPubKey);
+
+ hello = GNUNET_HELLO_create(&my_public_key, NULL, NULL);
+
/* load plugins... */
setup_plugin_environment ();
@@ -431,11 +469,13 @@
if (api == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to load transport plugin for tcp\n"));
+ _("Failed to load transport plugin for %s\n"), plugin);
end_badly_now ();
return;
}
+ timeout_wait = GNUNET_SCHEDULER_add_delayed (WAIT, &wait_end, NULL);
+
/* Check if all functions are implemented */
if (NULL == api->address_pretty_printer)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23375 - gnunet/src/transport,
gnunet <=