* 'MAX_PENDING' in 'gnunet-service-transport.c', otherwise
* messages may be dropped even for a reliable transport.
*/
-#define TOTAL_MSGS (80000 * 3) /* Total messages should be divisible by 8, so we can make a nice bitmap */
+#define TOTAL_MSGS (1024 * 3) /* Total messages should be divisible by 8, so we can make a nice bitmap */
/**
* How long until we give up on transmitting the message?
static int p1_hello_canceled;
static int p2_hello_canceled;
+static int test_failed;
+
/**
* Sets a bit active in the bitmap.
*
}
+
+static void
+exchange_hello_last (void *cls,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct PeerContext *me = cls;
+
+ GNUNET_assert (message != NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Exchanging HELLO of size %d with peer (%s)!\n",
+ (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
+ GNUNET_i2s (&me->id));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
+ message, &me->id));
+ GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
+}
+
+
+
+static void
+exchange_hello (void *cls,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct PeerContext *me = cls;
+
+ GNUNET_assert (message != NULL);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
+ message, &me->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Exchanging HELLO of size %d from peer %s!\n",
+ (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
+ GNUNET_i2s (&me->id));
+ GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
+}
+
+
+
static void
end_badly (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Reliability failed: Last message sent %u Next message scheduled %u Last message received %u Message expected %u\n",
- msg_sent,
- msg_scheduled,
- msg_recv,
- msg_recv_expected);
+ if (test_failed == GNUNET_NO)
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Testcase timeout\n");
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Reliability failed: Last message sent %u, Next message scheduled %u, Last message received %u, Message expected %u\n",
+ msg_sent,
+ msg_scheduled,
+ msg_recv,
+ msg_recv_expected);
+
GNUNET_break (0);
-
if (th_p2 != NULL)
- GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2);
- th_p2 = NULL;
-
+ {
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2);
+ th_p2 = NULL;
+ }
+ if (p2_hello_canceled == GNUNET_NO)
+ {
+ GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
+ p2_hello_canceled = GNUNET_YES;
+ }
+ if (p1_hello_canceled == GNUNET_NO)
+ {
+ GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ p1_hello_canceled = GNUNET_YES;
+ }
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_TRANSPORT_disconnect (p2.th);
-
if (GNUNET_SCHEDULER_NO_TASK != tct)
{
GNUNET_SCHEDULER_cancel (tct);
}
+
struct TestMessage
{
struct GNUNET_MessageHeader header;
{
unsigned int ret;
- if (iter < 60000)
- return iter + sizeof (struct TestMessage);
ret = (iter * iter * iter);
return sizeof (struct TestMessage) + (ret % 60000);
}
ntohl (hdr->num));
if (GNUNET_SCHEDULER_NO_TASK != die_task)
GNUNET_SCHEDULER_cancel (die_task);
+ test_failed = GNUNET_YES;
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
return;
}
ntohl(hdr->num), (unsigned char) n);
if (GNUNET_SCHEDULER_NO_TASK != die_task)
GNUNET_SCHEDULER_cancel (die_task);
+ test_failed = GNUNET_YES;
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
return;
}
#endif
n++;
set_bit(ntohl(hdr->num));
- if (0 == (n % (5000)))
+ if (0 == (n % (TOTAL_MSGS / 100)))
{
fprintf (stderr, ".");
if (GNUNET_SCHEDULER_NO_TASK != die_task)
GNUNET_SCHEDULER_cancel (die_task);
+ test_failed = GNUNET_YES;
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
&end_badly,
NULL);
GNUNET_i2s (peer), cls);
#endif
if (th_p2 != NULL)
- GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2);
-}
-
-
-
-static void
-exchange_hello_last (void *cls,
- const struct GNUNET_MessageHeader *message)
-{
- struct PeerContext *me = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Exchanging HELLO of size %d with peer (%s)!\n",
- (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
- GNUNET_i2s (&me->id));
- GNUNET_assert (message != NULL);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
- message, &me->id));
- GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
+ {
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel (th_p2);
+ th_p2 = NULL;
+ }
}
-static void
-exchange_hello (void *cls,
- const struct GNUNET_MessageHeader *message)
-{
- struct PeerContext *me = cls;
-
- GNUNET_assert (message != NULL);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
- message, &me->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Exchanging HELLO of size %d from peer %s!\n",
- (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
- GNUNET_i2s (&me->id));
- GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
-}
-
-
static void
notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer,
GNUNET_SCHEDULER_cancel (tct);
tct = GNUNET_SCHEDULER_NO_TASK;
}
-
if (p2_hello_canceled == GNUNET_NO)
- {
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
- p2_hello_canceled = GNUNET_YES;
- }
+ {
+ GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
+ p2_hello_canceled = GNUNET_YES;
+ }
if (p1_hello_canceled == GNUNET_NO)
- {
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
- p1_hello_canceled = GNUNET_YES;
- }
+ {
+ GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ p1_hello_canceled = GNUNET_YES;
+ }
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
&end_badly, NULL);
static void
setup_peer (struct PeerContext *p, const char *cfgname)
{
+ memset (p, 0, sizeof (*p));
p->cfg = GNUNET_CONFIGURATION_create ();
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome);
- GNUNET_DISK_directory_remove (p->servicehome);
+ {
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (p->cfg,
+ "PATHS", "SERVICEHOME",
+ &p->servicehome));
+ GNUNET_DISK_directory_remove (p->servicehome);
+ }
#if START_ARM
GNUNET_free(cert_file_p2);
}
- if ((p1.servicehome != NULL) && (p2.servicehome != NULL))
- {
- GNUNET_DISK_directory_remove (p1.servicehome);
- GNUNET_DISK_directory_remove (p2.servicehome);
- GNUNET_free(p1.servicehome);
- GNUNET_free(p2.servicehome);
- }
- return ok;
-
+ if (p1.servicehome != NULL)
+ {
+ GNUNET_DISK_directory_remove (p1.servicehome);
+ GNUNET_free(p1.servicehome);
+ }
+ if (p2.servicehome != NULL)
+ {
+ GNUNET_DISK_directory_remove (p2.servicehome);
+ GNUNET_free(p2.servicehome);
+ }
return ok;
}
main (int argc, char *argv[])
{
int ret;
-#ifdef MINGW
- return GNUNET_SYSERR;
-#endif
+
+ test_failed = GNUNET_NO;
GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1");
GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-2");