allow empty/NULL context message
[oweals/gnunet.git] / src / transport / test_transport_api_reliability.c
index fcada3e8854bf7b81dbb870080ab7056816ce5dc..fe2ac78e07e7a08386d0259c44dadaac2e942a57 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2009, 2010 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009, 2010 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
      You should have received a copy of the GNU General Public License
      along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
 */
 /**
  * @file transport/test_transport_api_reliability.c
 #include "gauger.h"
 #include "transport-testing.h"
 
+/**
+ * Allow making the problem "bigger".
+ */
+#define FACTOR 1
+
 /**
  * Total number of messages to send
  *
@@ -38,7 +43,7 @@
  * 'MAX_PENDING' in 'gnunet-service-transport_clients.c', otherwise
  * messages may be dropped even for a reliable transport.
  */
-#define TOTAL_MSGS (1024 * 3)
+#define TOTAL_MSGS (1024 * 3 * FACTOR)
 
 /**
  * Message type of test messages
 /**
  * Testcase timeout
  */
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90 * FACTOR)
 
 /**
  * How long until we give up on transmitting the message?
  */
-#define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+#define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60 * FACTOR)
 
 
 /**
@@ -156,7 +161,7 @@ static int test_send_timeout;
  */
 static char bitmap[TOTAL_MSGS / 8];
 
-static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
+static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
 
 /*
  * END Testcase specific declarations
@@ -313,8 +318,9 @@ set_bit (unsigned int bitIdx)
   if (bitIdx >= sizeof (bitmap) * 8)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "tried to set bit %d of %d(!?!?)\n",
-                bitIdx, sizeof (bitmap) * 8);
+                "tried to set bit %u of %u(!?!?)\n",
+                bitIdx,
+                (unsigned int) sizeof (bitmap) * 8);
     return GNUNET_SYSERR;
   }
   arraySlot = bitIdx / 8;
@@ -336,8 +342,10 @@ get_bit (const char *map, unsigned int bit)
 {
   if (bit > TOTAL_MSGS)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "get bit %d of %d(!?!?)\n", bit,
-                sizeof (bitmap) * 8);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "get bit %u of %u(!?!?)\n",
+                bit,
+                (unsigned int) sizeof (bitmap) * 8);
     return 0;
   }
   return ((map)[bit >> 3] & (1 << (bit & 7))) > 0;
@@ -388,8 +396,10 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
 #if VERBOSE
   if (ntohl (hdr->num) % 5 == 0)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n",
-                ntohl (hdr->num), ntohs (message->size));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Got message %u of size %u\n",
+                ntohl (hdr->num),
+                ntohs (message->size));
   }
 #endif
   n++;
@@ -500,7 +510,8 @@ notify_ready (void *cls, size_t size, void *buf)
 static void
 notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Peer `%4s' connected to us (%p)!\n",
               GNUNET_i2s (peer), cls);
 }
 
@@ -508,7 +519,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
 static void
 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Peer `%4s' disconnected (%p)!\n",
               GNUNET_i2s (peer), cls);
   if (th != NULL)
     GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
@@ -517,7 +529,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
 
 
 static void
-sendtask ()
+sendtask (void *cls)
 {
   start_time = GNUNET_TIME_absolute_get ();
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -528,13 +540,17 @@ sendtask ()
                                                NULL);
 }
 
+
 static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (struct PeerContext *p1,
+                    struct PeerContext *p2,
+                    void *cls)
 {
   char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peers connected: %s <-> %s\n", p1_c,
+              "Peers connected: %s <-> %s\n",
+              p1_c,
               GNUNET_i2s (&p2->id));
   GNUNET_free (p1_c);