gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated (e4e8919f8 -> 8d7ab1640)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (e4e8919f8 -> 8d7ab1640)
Date: Wed, 23 May 2018 00:01:00 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository gnunet.

    from e4e8919f8 +
     new ea5fa09f7 log on success, too
     new 9be8a466a fix indentation
     new 9af391e15 no need to dup cfg
     new 8d7ab1640 starting with another CADET testcase (unfinished)

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/cadet/cadet_test_lib.c                    |  65 ++--
 src/cadet/test_cadet.c                        |  52 ++-
 src/cadet/{test_cadet.c => test_cadet_flow.c} | 440 ++++++--------------------
 src/cadet/test_cadet_local_mq.c               |  12 +-
 src/dht/gnunet_dht_profiler.c                 |   4 +-
 src/gns/gnunet-gns-benchmark.c                |   3 +
 6 files changed, 174 insertions(+), 402 deletions(-)
 copy src/cadet/{test_cadet.c => test_cadet_flow.c} (68%)

diff --git a/src/cadet/cadet_test_lib.c b/src/cadet/cadet_test_lib.c
index 20ef028b2..0efb81ab4 100644
--- a/src/cadet/cadet_test_lib.c
+++ b/src/cadet/cadet_test_lib.c
@@ -110,7 +110,7 @@ struct GNUNET_CADET_TEST_AdapterContext
    * Port handlers for open ports.
    */
   struct GNUNET_CADET_Port **ports;
- 
+
   /**
    * General context.
    */
@@ -135,14 +135,13 @@ cadet_connect_adapter (void *cls,
   struct GNUNET_CADET_TEST_AdapterContext *actx = cls;
   struct GNUNET_CADET_TEST_Context *ctx = actx->ctx;
   struct GNUNET_CADET_Handle *h;
-  unsigned int i;
 
   h = GNUNET_CADET_connect (cfg);
   if (NULL == ctx->ports)
     return h;
-
-  actx->ports = GNUNET_new_array (ctx->port_count, struct GNUNET_CADET_Port *);
-  for (i = 0; i < ctx->port_count; i++)
+  actx->ports = GNUNET_new_array (ctx->port_count,
+                                  struct GNUNET_CADET_Port *);
+  for (unsigned int i = 0; i < ctx->port_count; i++)
   {
     actx->ports[i] = GNUNET_CADET_open_port (h,
                                              ctx->ports[i],
@@ -165,14 +164,14 @@ cadet_connect_adapter (void *cls,
  */
 static void
 cadet_disconnect_adapter (void *cls,
-                         void *op_result)
+                          void *op_result)
 {
   struct GNUNET_CADET_Handle *cadet = op_result;
   struct GNUNET_CADET_TEST_AdapterContext *actx = cls;
 
   if (NULL != actx->ports)
   {
-    for (int i = 0; i < actx->ctx->port_count; i++)
+    for (unsigned int i = 0; i < actx->ctx->port_count; i++)
     {
       GNUNET_CADET_close_port (actx->ports[i]);
       actx->ports[i] = NULL;
@@ -201,22 +200,24 @@ cadet_connect_cb (void *cls,
                  const char *emsg)
 {
   struct GNUNET_CADET_TEST_Context *ctx = cls;
-  unsigned int i;
 
   if (NULL != emsg)
   {
-    fprintf (stderr, "Failed to connect to CADET service: %s\n",
+    fprintf (stderr,
+             "Failed to connect to CADET service: %s\n",
              emsg);
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  for (i = 0; i < ctx->num_peers; i++)
+  for (unsigned int i = 0; i < ctx->num_peers; i++)
     if (op == ctx->ops[i])
     {
       ctx->cadets[i] = ca_result;
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO, "...cadet %u connected\n", i);
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  "...cadet %u connected\n",
+                  i);
     }
-  for (i = 0; i < ctx->num_peers; i++)
+  for (unsigned int i = 0; i < ctx->num_peers; i++)
     if (NULL == ctx->cadets[i])
       return; /* still some CADET connections missing */
   /* all CADET connections ready! */
@@ -231,9 +232,7 @@ cadet_connect_cb (void *cls,
 void
 GNUNET_CADET_TEST_cleanup (struct GNUNET_CADET_TEST_Context *ctx)
 {
-  unsigned int i;
-
-  for (i = 0; i < ctx->num_peers; i++)
+  for (unsigned int i = 0; i < ctx->num_peers; i++)
   {
     GNUNET_assert (NULL != ctx->ops[i]);
     GNUNET_TESTBED_operation_done (ctx->ops[i]);
@@ -269,33 +268,37 @@ cadet_test_run (void *cls,
                unsigned int links_failed)
 {
   struct GNUNET_CADET_TEST_Context *ctx = cls;
-  unsigned int i;
 
   if (0 != links_failed)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Some links failed (%u), ending\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Some links failed (%u), ending\n",
                 links_failed);
     exit (2);
   }
-
   if  (num_peers != ctx->num_peers)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers started %u/%u, ending\n",
-                num_peers, ctx->num_peers);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Peers started %u/%u, ending\n",
+                num_peers,
+                ctx->num_peers);
     exit (1);
   }
-
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Testbed up, %u peers and %u links\n",
-              num_peers, links_succeeded);
+              num_peers,
+              links_succeeded);
   ctx->peers = peers;
-  for (i = 0; i < num_peers; i++)
+  for (unsigned int i = 0; i < num_peers; i++)
   {
     struct GNUNET_CADET_TEST_AdapterContext *newctx;
+
     newctx = GNUNET_new (struct GNUNET_CADET_TEST_AdapterContext);
     newctx->peer = i;
     newctx->ctx = ctx;
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connecting to cadet %u\n", i);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Connecting to cadet %u\n",
+                i);
     ctx->ops[i] = GNUNET_TESTBED_service_connect (ctx,
                                                   peers[i],
                                                   "cadet",
@@ -304,7 +307,9 @@ cadet_test_run (void *cls,
                                                   &cadet_connect_adapter,
                                                   &cadet_disconnect_adapter,
                                                   newctx);
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "op handle %p\n", ctx->ops[i]);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "op handle %p\n",
+                ctx->ops[i]);
   }
 }
 
@@ -340,8 +345,10 @@ GNUNET_CADET_TEST_ruN (const char *testname,
 
   ctx = GNUNET_new (struct GNUNET_CADET_TEST_Context);
   ctx->num_peers = num_peers;
-  ctx->ops = GNUNET_new_array (num_peers, struct GNUNET_TESTBED_Operation *);
-  ctx->cadets = GNUNET_new_array (num_peers, struct GNUNET_CADET_Handle *);
+  ctx->ops = GNUNET_new_array (num_peers,
+                               struct GNUNET_TESTBED_Operation *);
+  ctx->cadets = GNUNET_new_array (num_peers,
+                                  struct GNUNET_CADET_Handle *);
   ctx->app_main = tmain;
   ctx->app_main_cls = tmain_cls;
   ctx->connects = connects;
@@ -352,12 +359,12 @@ GNUNET_CADET_TEST_ruN (const char *testname,
   ctx->port_count = 0;
   while (NULL != ctx->ports[ctx->port_count])
     ctx->port_count++;
-
   GNUNET_TESTBED_test_run (testname,
                            cfgfile,
                            num_peers,
                            0LL, NULL, NULL,
-                           &cadet_test_run, ctx);
+                           &cadet_test_run,
+                           ctx);
 }
 
 /* end of cadet_test_lib.c */
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c
index b9f177652..608136e56 100644
--- a/src/cadet/test_cadet.c
+++ b/src/cadet/test_cadet.c
@@ -402,8 +402,11 @@ stats_cont (void *cls,
  * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
  */
 static int
-stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
-                const char *subsystem, const char *name, uint64_t value,
+stats_iterator (void *cls,
+                const struct GNUNET_TESTBED_Peer *peer,
+                const char *subsystem,
+                const char *name,
+                uint64_t value,
                 int is_persistent)
 {
   static const char *s_sent = "# keepalives sent";
@@ -614,10 +617,9 @@ reschedule_timeout_task (long line)
  *         #GNUNET_SYSERR to close it (signal serious error).
  */
 static int
-check_data (void *cls, const struct GNUNET_MessageHeader *message)
+check_data (void *cls,
+            const struct GNUNET_MessageHeader *message)
 {
-  if (sizeof (struct GNUNET_MessageHeader) >= ntohs (message->size))
-    return GNUNET_SYSERR;
   return GNUNET_OK;             /* all is well-formed */
 }
 
@@ -646,24 +648,33 @@ handle_data (void *cls,
 
   if (channel == outgoing_ch)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message.\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Root client got a message.\n");
   }
   else if (channel == incoming_ch)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Leaf client got a message.\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Leaf client got a message.\n");
   }
   else
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unknown channel %p.\n", channel);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unknown channel %p.\n",
+                channel);
     GNUNET_assert (0);
   }
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              " ok: (%d/%d)\n",
+              ok,
+              ok_goal);
   data = (uint32_t *) &message[1];
   payload = ntohl (*data);
   if (payload == *counter)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload as expected: %u\n", payload);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                " payload as expected: %u\n",
+                payload);
   }
   else
   {
@@ -679,7 +690,8 @@ handle_data (void *cls,
     if (SPEED == test)
     {
       GNUNET_assert (incoming_ch == channel);
-      send_next_msg_task = GNUNET_SCHEDULER_add_now (&send_next_msg, NULL);
+      send_next_msg_task = GNUNET_SCHEDULER_add_now (&send_next_msg,
+                                                     NULL);
       return;
     }
   }
@@ -740,7 +752,8 @@ handle_data (void *cls,
  *           received on the @a channel.
  */
 static void *
-connect_handler (void *cls, struct GNUNET_CADET_Channel *channel,
+connect_handler (void *cls,
+                 struct GNUNET_CADET_Channel *channel,
                  const struct GNUNET_PeerIdentity *source)
 {
   struct CadetTestChannelWrapper *ch;
@@ -748,15 +761,20 @@ connect_handler (void *cls, struct GNUNET_CADET_Channel 
*channel,
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Incoming channel from %s to %ld: %p\n",
-              GNUNET_i2s (source), peer, channel);
+              GNUNET_i2s (source),
+              peer,
+              channel);
   ok++;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              " ok: %d\n",
+              ok);
   if (peer == peers_requested - 1)
   {
     if (NULL != incoming_ch)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "Duplicate incoming channel for client %lu\n", (long) cls);
+                  "Duplicate incoming channel for client %lu\n",
+                  (long) cls);
       GNUNET_assert (0);
     }
     incoming_ch = channel;
@@ -764,7 +782,8 @@ connect_handler (void *cls, struct GNUNET_CADET_Channel 
*channel,
   else
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Incoming channel for unexpected peer #%lu\n", (long) cls);
+                "Incoming channel for unexpected peer #%lu\n",
+                (long) cls);
     GNUNET_assert (0);
   }
   if (NULL != disconnect_task)
@@ -1003,7 +1022,6 @@ main (int argc, char *argv[])
                                        "short_time",
                                        gettext_noop ("set short timeout"),
                                        &short_time),
-
     GNUNET_GETOPT_option_uint ('m',
                               "messages",
                               "NUM_MESSAGES",
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet_flow.c
similarity index 68%
copy from src/cadet/test_cadet.c
copy to src/cadet/test_cadet_flow.c
index b9f177652..554ee1d85 100644
--- a/src/cadet/test_cadet.c
+++ b/src/cadet/test_cadet_flow.c
@@ -18,10 +18,10 @@
      Boston, MA 02110-1301, USA.
 */
 /**
- * @file cadet/test_cadet.c
+ * @file cadet/test_cadet_flow.c
  * @author Bart Polot
  * @author Christian Grothoff
- * @brief Test for the cadet service using mq API.
+ * @brief Test for flow control of CADET service
  */
 #include <stdio.h>
 #include "platform.h"
@@ -45,7 +45,7 @@ struct CadetTestChannelWrapper
 /**
  * How many messages to send by default.
  */
-#define TOTAL_PACKETS 500       /* Cannot exceed 64k! */
+#define TOTAL_PACKETS_DEFAULT 500
 
 /**
  * How long until we give up on connecting the peers?
@@ -62,36 +62,11 @@ struct CadetTestChannelWrapper
  */
 #define SEND_INTERVAL GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_MILLISECONDS, 10)
 
-/**
- * DIFFERENT TESTS TO RUN
- */
-#define SETUP 0
-#define FORWARD 1
-#define KEEPALIVE 2
-#define SPEED 3
-#define SPEED_ACK 4
-#define SPEED_REL 8
-#define P2P_SIGNAL 10
-
-/**
- * Which test are we running?
- */
-static int test;
-
-/**
- * String with test name
- */
-static char *test_name;
-
-/**
- * Flag to send traffic leaf->root in speed tests to test BCK_ACK logic.
- */
-static int test_backwards = GNUNET_NO;
 
 /**
  * How many packets to send.
  */
-static unsigned int total_packets;
+static unsigned int total_packets = TOTAL_PACKETS_DEFAULT;
 
 /**
  * Time to wait for fast operations.
@@ -99,16 +74,6 @@ static unsigned int total_packets;
 static struct GNUNET_TIME_Relative short_time;
 
 /**
- * How many events have happened
- */
-static int ok;
-
-/**
- * Number of events expected to conclude the test successfully.
- */
-static int ok_goal;
-
-/**
  * Size of each test packet's payload
  */
 static size_t size_payload = sizeof (uint32_t);
@@ -161,12 +126,12 @@ static int ack_received;
 /**
  * Total number of peers asked to run.
  */
-static unsigned long long peers_requested;
+static unsigned int peers_requested = 2;
 
 /**
  * Number of currently running peers (should be same as @c peers_requested).
  */
-static unsigned long long peers_running;
+static unsigned int peers_running;
 
 /**
  * Test context (to shut down).
@@ -240,29 +205,6 @@ static unsigned int ka_received;
 static unsigned int msg_dropped;
 
 
-/******************************************************************************/
-
-
-/******************************************************************************/
-
-
-/**
- * Get the channel considered as the "target" or "receiver", depending on
- * the test type and size.
- *
- * @return Channel handle of the target client, either 0 (for backward tests)
- *         or the last peer in the line (for other tests).
- */
-static struct GNUNET_CADET_Channel *
-get_target_channel ()
-{
-  if (SPEED == test && GNUNET_YES == test_backwards)
-    return outgoing_ch;
-  else
-    return incoming_ch;
-}
-
-
 /**
  * Show the results of the test (banwidth acheived) and log them to GAUGER
  */
@@ -294,40 +236,6 @@ show_end_data (void)
 
 
 /**
- * Disconnect from cadet services af all peers, call shutdown.
- *
- * @param cls Closure (line number from which termination was requested).
- * @param tc Task Context.
- */
-static void
-disconnect_cadet_peers (void *cls)
-{
-  long line = (long) cls;
-
-  disconnect_task = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "disconnecting cadet service of peers, called from line %ld\n",
-              line);
-  for (unsigned int i = 0; i < 2; i++)
-  {
-    GNUNET_TESTBED_operation_done (t_op[i]);
-  }
-  if (NULL != outgoing_ch)
-  {
-    GNUNET_CADET_channel_destroy (outgoing_ch);
-    outgoing_ch = NULL;
-  }
-  if (NULL != incoming_ch)
-  {
-    GNUNET_CADET_channel_destroy (incoming_ch);
-    incoming_ch = NULL;
-  }
-  GNUNET_CADET_TEST_cleanup (test_ctx);
-  GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
  * Shut down peergroup, clean up.
  *
  * @param cls Closure (unused).
@@ -348,13 +256,19 @@ shutdown_task (void *cls)
     GNUNET_SCHEDULER_cancel (test_task);
     test_task = NULL;
   }
-  if (NULL != disconnect_task)
+  for (unsigned int i = 0; i < 2; i++)
+    GNUNET_TESTBED_operation_done (t_op[i]);
+  if (NULL != outgoing_ch)
   {
-    GNUNET_SCHEDULER_cancel (disconnect_task);
-    disconnect_task =
-        GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
-                                 (void *) __LINE__);
+    GNUNET_CADET_channel_destroy (outgoing_ch);
+    outgoing_ch = NULL;
   }
+  if (NULL != incoming_ch)
+  {
+    GNUNET_CADET_channel_destroy (incoming_ch);
+    incoming_ch = NULL;
+  }
+  GNUNET_CADET_TEST_cleanup (test_ctx);
 }
 
 
@@ -402,8 +316,11 @@ stats_cont (void *cls,
  * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
  */
 static int
-stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
-                const char *subsystem, const char *name, uint64_t value,
+stats_iterator (void *cls,
+                const struct GNUNET_TESTBED_Peer *peer,
+                const char *subsystem,
+                const char *name,
+                uint64_t value,
                 int is_persistent)
 {
   static const char *s_sent = "# keepalives sent";
@@ -582,30 +499,6 @@ send_next_msg (void *cls)
 
 
 /**
- * Every few messages cancel the timeout task and re-schedule it again, to
- * avoid timing out when traffic keeps coming.
- *
- * @param line Code line number to log if a timeout occurs.
- */
-static void
-reschedule_timeout_task (long line)
-{
-  if ((ok % 10) == 0)
-  {
-    if (NULL != disconnect_task)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "reschedule timeout every 10 messages\n");
-      GNUNET_SCHEDULER_cancel (disconnect_task);
-      disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
-                                                      &gather_stats_and_exit,
-                                                      (void *) line);
-    }
-  }
-}
-
-
-/**
  * Check if payload is sane (size contains payload).
  *
  * @param cls should match #ch
@@ -614,10 +507,9 @@ reschedule_timeout_task (long line)
  *         #GNUNET_SYSERR to close it (signal serious error).
  */
 static int
-check_data (void *cls, const struct GNUNET_MessageHeader *message)
+check_data (void *cls,
+            const struct GNUNET_MessageHeader *message)
 {
-  if (sizeof (struct GNUNET_MessageHeader) >= ntohs (message->size))
-    return GNUNET_SYSERR;
   return GNUNET_OK;             /* all is well-formed */
 }
 
@@ -638,67 +530,48 @@ handle_data (void *cls,
   uint32_t payload;
   int *counter;
 
-  ok++;
   GNUNET_CADET_receive_done (channel);
   counter = get_target_channel () == channel ? &data_received : &ack_received;
-
-  reschedule_timeout_task ((long) __LINE__);
-
   if (channel == outgoing_ch)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message.\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Root client got a message.\n");
   }
   else if (channel == incoming_ch)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Leaf client got a message.\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Leaf client got a message.\n");
   }
   else
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unknown channel %p.\n", channel);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unknown channel %p.\n",
+                channel);
     GNUNET_assert (0);
   }
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
   data = (uint32_t *) &message[1];
   payload = ntohl (*data);
   if (payload == *counter)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload as expected: %u\n", payload);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Payload as expected: %u\n",
+                payload);
   }
   else
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                " payload %u, expected: %u\n",
+                "Received payload %u, expected: %u\n",
                 payload, *counter);
   }
-
-  if (GNUNET_NO == initialized)
-  {
-    initialized = GNUNET_YES;
-    start_time = GNUNET_TIME_absolute_get ();
-    if (SPEED == test)
-    {
-      GNUNET_assert (incoming_ch == channel);
-      send_next_msg_task = GNUNET_SCHEDULER_add_now (&send_next_msg, NULL);
-      return;
-    }
-  }
-
   (*counter)++;
   if (get_target_channel () == channel) /* Got "data" */
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
-    if (SPEED != test || (ok_goal - 2) == ok)
-    {
-      /* Send ACK */
-      send_test_message (channel);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                " received data %u\n",
+                data_received);
+    if (data_received < total_packets)
       return;
-    }
-    else
-    {
-      if (data_received < total_packets)
-        return;
-    }
   }
   else /* Got "ack" */
   {
@@ -740,7 +613,8 @@ handle_data (void *cls,
  *           received on the @a channel.
  */
 static void *
-connect_handler (void *cls, struct GNUNET_CADET_Channel *channel,
+connect_handler (void *cls,
+                 struct GNUNET_CADET_Channel *channel,
                  const struct GNUNET_PeerIdentity *source)
 {
   struct CadetTestChannelWrapper *ch;
@@ -748,15 +622,16 @@ connect_handler (void *cls, struct GNUNET_CADET_Channel 
*channel,
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Incoming channel from %s to %ld: %p\n",
-              GNUNET_i2s (source), peer, channel);
-  ok++;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
+              GNUNET_i2s (source),
+              peer,
+              channel);
   if (peer == peers_requested - 1)
   {
     if (NULL != incoming_ch)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "Duplicate incoming channel for client %lu\n", (long) cls);
+                  "Duplicate incoming channel for client %lu\n",
+                  (long) cls);
       GNUNET_assert (0);
     }
     incoming_ch = channel;
@@ -764,18 +639,10 @@ connect_handler (void *cls, struct GNUNET_CADET_Channel 
*channel,
   else
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Incoming channel for unexpected peer #%lu\n", (long) cls);
+                "Incoming channel for unexpected peer #%lu\n",
+                (long) cls);
     GNUNET_assert (0);
   }
-  if (NULL != disconnect_task)
-  {
-    GNUNET_SCHEDULER_cancel (disconnect_task);
-    disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
-                                                    &gather_stats_and_exit,
-                                                    (void *) __LINE__);
-  }
-
-  /* TODO: cannot return channel as-is, in order to unify the data handlers */
   ch = GNUNET_new (struct CadetTestChannelWrapper);
   ch->ch = channel;
 
@@ -805,35 +672,23 @@ disconnect_handler (void *cls,
              ok);
   GNUNET_assert (ch_w->ch == channel);
   if (channel == incoming_ch)
-  {
-    ok++;
     incoming_ch = NULL;
-  }
   else if (outgoing_ch == channel)
-  {
-    if (P2P_SIGNAL == test)
-    {
-      ok++;
-    }
     outgoing_ch = NULL;
-  }
   else
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               "Unknown channel! %p\n",
+               "Disconnect on unknown channel %p\n",
                channel);
   if (NULL != disconnect_task)
-  {
     GNUNET_SCHEDULER_cancel (disconnect_task);
-    disconnect_task =
-        GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
-                                 (void *) __LINE__);
-  }
+  disconnect_task = GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
+                                              (void *) __LINE__);
   GNUNET_free (ch_w);
 }
 
 
 /**
- * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
+ * Start the testcase, we know the peers and have handles to CADET.
  *
  * Testcase continues when the root receives confirmation of connected peers,
  * on callback function ch.
@@ -854,20 +709,9 @@ start_test (void *cls)
   enum GNUNET_CADET_ChannelOption flags;
 
   test_task = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test\n");
-  if (NULL != disconnect_task)
-  {
-    GNUNET_SCHEDULER_cancel (disconnect_task);
-    disconnect_task = NULL;
-  }
-
-  flags = GNUNET_CADET_OPTION_DEFAULT;
-  if (SPEED_REL == test)
-  {
-    test = SPEED;
-    flags |= GNUNET_CADET_OPTION_RELIABLE;
-  }
-
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "In start_test\n");
+  start_time = GNUNET_TIME_absolute_get ();
   ch = GNUNET_new (struct CadetTestChannelWrapper);
   outgoing_ch = GNUNET_CADET_channel_create (h1,
                                              ch,
@@ -877,20 +721,12 @@ start_test (void *cls)
                                              NULL,
                                              &disconnect_handler,
                                              handlers);
-
   ch->ch = outgoing_ch;
-
-  disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
-                                                  &gather_stats_and_exit,
-                                                  (void *) __LINE__);
-  if (KEEPALIVE == test)
-    return;                     /* Don't send any data. */
-
-
-  data_received = 0;
-  data_sent = 0;
-  ack_received = 0;
-  ack_sent = 0;
+  GNUNET_assert (NULL == disconnect_task);
+  disconnect_task
+    = GNUNET_SCHEDULER_add_delayed (short_time,
+                                    &gather_stats_and_exit,
+                                    (void *) __LINE__);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Sending data initializer on channel %p...\n",
               outgoing_ch);
@@ -936,7 +772,8 @@ pi_cb (void *cls,
     return;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Got all IDs, starting test\n");
-  test_task = GNUNET_SCHEDULER_add_now (&start_test, NULL);
+  test_task = GNUNET_SCHEDULER_add_now (&start_test,
+                                        NULL);
 }
 
 
@@ -956,19 +793,17 @@ tmain (void *cls,
        struct GNUNET_TESTBED_Peer **peers,
        struct GNUNET_CADET_Handle **cadets)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
-  ok = 0;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "test main\n");
   test_ctx = ctx;
   peers_running = num_peers;
   GNUNET_assert (peers_running == peers_requested);
   testbed_peers = peers;
   h1 = cadets[0];
   h2 = cadets[num_peers - 1];
-  disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
-                                                  &disconnect_cadet_peers,
-                                                  (void *) __LINE__);
   GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
                                 NULL);
+  p_ids = 0;
   t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
                                                  GNUNET_TESTBED_PIT_IDENTITY,
                                                  &pi_cb,
@@ -977,7 +812,8 @@ tmain (void *cls,
                                                  GNUNET_TESTBED_PIT_IDENTITY,
                                                  &pi_cb,
                                                  (void *) 1L);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "requested peer ids\n");
 }
 
 
@@ -985,7 +821,8 @@ tmain (void *cls,
  * Main: start test
  */
 int
-main (int argc, char *argv[])
+main (int argc,
+      char *argv[])
 {
   static const struct GNUNET_HashCode *ports[2];
   struct GNUNET_MQ_MessageHandler handlers[] = {
@@ -995,7 +832,7 @@ main (int argc, char *argv[])
                            NULL),
     GNUNET_MQ_handler_end ()
   };
-  const char *config_file;
+  const char *config_file = "test_cadet.conf";
   char port_id[] = "test port";
   struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_option_relative_time ('t',
@@ -1003,127 +840,39 @@ main (int argc, char *argv[])
                                        "short_time",
                                        gettext_noop ("set short timeout"),
                                        &short_time),
-
     GNUNET_GETOPT_option_uint ('m',
                               "messages",
                               "NUM_MESSAGES",
                               gettext_noop ("set number of messages to send"),
                               &total_packets),
-
+    GNUNET_GETOPT_option_uint ('p',
+                              "peers",
+                              "NUM_PEERS",
+                              gettext_noop ("number of peers to launch"),
+                              &peers_requested),
     GNUNET_GETOPT_OPTION_END
   };
 
-
-  initialized = GNUNET_NO;
-  GNUNET_log_setup ("test", "DEBUG", NULL);
-
+  GNUNET_log_setup ("test-cadet-flow",
+                    "DEBUG",
+                    NULL);
   total_packets = TOTAL_PACKETS;
   short_time = SHORT_TIME;
-  if (-1 == GNUNET_GETOPT_run (argv[0], options, argc, argv))
-  {
-    FPRINTF (stderr, "test failed: problem with CLI parameters\n");
-    exit (1);
-  }
-
-  config_file = "test_cadet.conf";
-  GNUNET_CRYPTO_hash (port_id, sizeof (port_id), &port);
-
-  /* Find out requested size */
-  if (strstr (argv[0], "_2_") != NULL)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
-    peers_requested = 2;
-  }
-  else if (strstr (argv[0], "_5_") != NULL)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
-    peers_requested = 5;
-  }
-  else
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
-    peers_requested = 2;
-  }
-
-  /* Find out requested test */
-  if (strstr (argv[0], "_forward") != NULL)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
-    test = FORWARD;
-    test_name = "unicast";
-    ok_goal = 4;
-  }
-  else if (strstr (argv[0], "_signal") != NULL)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
-    test = P2P_SIGNAL;
-    test_name = "signal";
-    ok_goal = 4;
-  }
-  else if (strstr (argv[0], "_speed_ack") != NULL)
+  if (-1 == GNUNET_GETOPT_run (argv[0],
+                               options,
+                               argc,
+                               argv))
   {
-    /* Test is supposed to generate the following callbacks:
-     * 1 incoming channel (@dest)
-     * total_packets received data packet (@dest)
-     * total_packets received data packet (@orig)
-     * 1 received channel destroy (@dest)
-     */
-    ok_goal = total_packets * 2 + 2;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
-    test = SPEED_ACK;
-    test_name = "speed ack";
-  }
-  else if (strstr (argv[0], "_speed") != NULL)
-  {
-    /* Test is supposed to generate the following callbacks:
-     * 1 incoming channel (@dest)
-     * 1 initial packet (@dest)
-     * total_packets received data packet (@dest)
-     * 1 received data packet (@orig)
-     * 1 received channel destroy (@dest)
-     */
-    ok_goal = total_packets + 4;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
-    if (strstr (argv[0], "_reliable") != NULL)
-    {
-      test = SPEED_REL;
-      test_name = "speed reliable";
-      config_file = "test_cadet_drop.conf";
-    }
-    else
-    {
-      test = SPEED;
-      test_name = "speed";
-    }
-  }
-  else if (strstr (argv[0], "_keepalive") != NULL)
-  {
-    test = KEEPALIVE;
-    /* Test is supposed to generate the following callbacks:
-     * 1 incoming channel (@dest)
-     * [wait]
-     * 1 received channel destroy (@dest)
-     */
-    ok_goal = 2;
-  }
-  else
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
-    test = SETUP;
-    ok_goal = 0;
-  }
-
-  if (strstr (argv[0], "backwards") != NULL)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
-    test_backwards = GNUNET_YES;
-    GNUNET_asprintf (&test_name, "backwards %s", test_name);
+    FPRINTF (stderr,
+             "test failed: problem with CLI parameters\n");
+    return 1;
   }
-
-  p_ids = 0;
+  GNUNET_CRYPTO_hash (port_id,
+                      sizeof (port_id),
+                      &port);
   ports[0] = &port;
   ports[1] = NULL;
-  GNUNET_CADET_TEST_ruN ("test_cadet_small",
+  GNUNET_CADET_TEST_ruN ("test_cadet_flow",
                          config_file,
                          peers_requested,
                          &tmain,
@@ -1133,16 +882,7 @@ main (int argc, char *argv[])
                          &disconnect_handler,
                          handlers,
                          ports);
-  if (NULL != strstr (argv[0], "_reliable"))
-    msg_dropped = 0;            /* dropped should be retransmitted */
-
-  if (ok_goal > ok - msg_dropped)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "FAILED! (%d/%d)\n", ok, ok_goal);
-    return 1;
-  }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
   return 0;
 }
 
-/* end of test_cadet.c */
+/* end of test_cadet_flow.c */
diff --git a/src/cadet/test_cadet_local_mq.c b/src/cadet/test_cadet_local_mq.c
index 3089c7fbb..2ea754743 100644
--- a/src/cadet/test_cadet_local_mq.c
+++ b/src/cadet/test_cadet_local_mq.c
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file cadet/test_cadet_local.c
+ * @file cadet/test_cadet_local_mq.c
  * @brief test cadet local: test of cadet channels with just one peer
  * @author Bartlomiej Polot
  */
@@ -123,7 +123,9 @@ do_shutdown (void *cls)
 static void
 do_abort (void *cls)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ABORT from line %ld\n", (long) cls);
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+              "ABORT from line %ld\n",
+              (long) cls);
   result = GNUNET_SYSERR;
   abort_task = NULL;
   GNUNET_SCHEDULER_shutdown ();
@@ -148,7 +150,8 @@ connected (void *cls,
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "connected %s, cls: %p\n",
-              GNUNET_i2s(source), cls);
+              GNUNET_i2s(source),
+              cls);
   return channel;
 }
 
@@ -206,7 +209,8 @@ handle_data_received (void *cls,
 static void
 message_sent (void *cls)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "message sent\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "message sent\n");
 }
 
 
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c
index 403deb38a..5341e7d61 100644
--- a/src/dht/gnunet_dht_profiler.c
+++ b/src/dht/gnunet_dht_profiler.c
@@ -45,7 +45,7 @@ static unsigned int put_probability = 100;
 /**
  * Configuration
  */
-static struct GNUNET_CONFIGURATION_Handle *cfg;
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
 
 /**
  * Name of the file with the hosts to run the test over
@@ -917,7 +917,7 @@ run (void *cls,
                 num_peers);
     return;
   }
-  cfg = GNUNET_CONFIGURATION_dup (config);
+  cfg = config;
   event_mask = 0;
   GNUNET_TESTBED_run (hosts_file,
                       cfg,
diff --git a/src/gns/gnunet-gns-benchmark.c b/src/gns/gnunet-gns-benchmark.c
index 00d1c6813..0ab6cefd5 100644
--- a/src/gns/gnunet-gns-benchmark.c
+++ b/src/gns/gnunet-gns-benchmark.c
@@ -216,6 +216,9 @@ process_result (void *cls,
   (void) rd_count;
   (void) rd;
   active_cnt--;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Got response for request `%s'\n",
+              req->hostname);
   req->lr = NULL;
   req->latency = GNUNET_TIME_absolute_get_duration (req->op_start_time);
   GNUNET_CONTAINER_DLL_remove (act_head,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]