- fix handling of duplicate incoming channel create with respect to queued retransmis...
[oweals/gnunet.git] / src / mesh / mesh_test_lib.c
index a6a7c2114ab61aefa41b82006d2eed6495f16e76..3fa73df4d8f7baf71ba9ae5ecfc950f3724eceaf 100644 (file)
@@ -25,7 +25,7 @@
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "mesh_test_lib.h"
-#include "gnunet_mesh_service_enc.h"
+#include "gnunet_mesh_service.h"
 
 /**
  * Test context for a MESH Test.
@@ -51,7 +51,7 @@ struct GNUNET_MESH_TEST_Context
    * Main function of the test to run once all MESHs are available.
    */
   GNUNET_MESH_TEST_AppMain app_main;
-  
+
   /**
    * Closure for 'app_main'.
    */
@@ -137,7 +137,7 @@ mesh_connect_adapter (void *cls,
  * @param cls closure
  * @param op_result service handle returned from the connect adapter
  */
-static void 
+static void
 mesh_disconnect_adapter (void *cls,
                          void *op_result)
 {
@@ -154,12 +154,12 @@ mesh_disconnect_adapter (void *cls,
  *
  * @param cls The callback closure from functions generating an operation.
  * @param op The operation that has been finished.
- * @param ca_result The service handle returned from 
+ * @param ca_result The service handle returned from
  *                  GNUNET_TESTBED_ConnectAdapter() (mesh handle).
  * @param emsg Error message in case the operation has failed.
  *             NULL if operation has executed successfully.
  */
-static void 
+static void
 mesh_connect_cb (void *cls,
                  struct GNUNET_TESTBED_Operation *op,
                  void *ca_result,
@@ -167,7 +167,7 @@ mesh_connect_cb (void *cls,
 {
   struct GNUNET_MESH_TEST_Context *ctx = cls;
   unsigned int i;
+
   if (NULL != emsg)
   {
     fprintf (stderr, "Failed to connect to MESH service: %s\n",
@@ -177,7 +177,10 @@ mesh_connect_cb (void *cls,
   }
   for (i = 0; i < ctx->num_peers; i++)
     if (op == ctx->ops[i])
+    {
       ctx->meshes[i] = ca_result;
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO, "...mesh %u connected\n", i);
+    }
   for (i = 0; i < ctx->num_peers; i++)
     if (NULL == ctx->meshes[i])
       return; /* still some MESH connections missing */
@@ -211,8 +214,9 @@ GNUNET_MESH_TEST_cleanup (struct GNUNET_MESH_TEST_Context *ctx)
 /**
  * Callback run when the testbed is ready (peers running and connected to
  * each other)
- * 
+ *
  * @param cls Closure (context).
+ * @param h the run handle
  * @param num_peers Number of peers that are running.
  * @param peers Handles to each one of the @c num_peers peers.
  * @param links_succeeded the number of overlay link connection attempts that
@@ -222,6 +226,7 @@ GNUNET_MESH_TEST_cleanup (struct GNUNET_MESH_TEST_Context *ctx)
  */
 static void
 mesh_test_run (void *cls,
+               struct GNUNET_TESTBED_RunHandle *h,
                unsigned int num_peers,
                struct GNUNET_TESTBED_Peer **peers,
                unsigned int links_succeeded,
@@ -230,14 +235,20 @@ mesh_test_run (void *cls,
   struct GNUNET_MESH_TEST_Context *ctx = cls;
   unsigned int i;
 
-  GNUNET_assert (num_peers == ctx->num_peers);
+  if  (num_peers != ctx->num_peers)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers started %u/%u, ending\n",
+                num_peers, ctx->num_peers);
+    exit (1);
+  }
   ctx->peers = peers;
   for (i = 0; i < num_peers; i++)
   {
     struct GNUNET_MESH_TEST_AdapterContext *newctx;
-    newctx = GNUNET_malloc (sizeof (struct GNUNET_MESH_TEST_AdapterContext));
+    newctx = GNUNET_new (struct GNUNET_MESH_TEST_AdapterContext);
     newctx->peer = i;
     newctx->ctx = ctx;
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connecting to mesh %u\n", i);
     ctx->ops[i] = GNUNET_TESTBED_service_connect (ctx,
                                                   peers[i],
                                                   "mesh",
@@ -246,11 +257,12 @@ mesh_test_run (void *cls,
                                                   &mesh_connect_adapter,
                                                   &mesh_disconnect_adapter,
                                                   newctx);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "op handle %p\n", ctx->ops[i]);
   }
 }
 
 
-void 
+void
 GNUNET_MESH_TEST_run (const char *testname,
                       const char *cfgname,
                       unsigned int num_peers,
@@ -263,7 +275,7 @@ GNUNET_MESH_TEST_run (const char *testname,
 {
   struct GNUNET_MESH_TEST_Context *ctx;
 
-  ctx = GNUNET_malloc (sizeof (struct GNUNET_MESH_TEST_Context));
+  ctx = GNUNET_new (struct GNUNET_MESH_TEST_Context);
   ctx->num_peers = num_peers;
   ctx->ops = GNUNET_malloc (num_peers * sizeof (struct GNUNET_TESTBED_Operation *));
   ctx->meshes = GNUNET_malloc (num_peers * sizeof (struct GNUNET_MESH_Handle *));