gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r11783 - gnunet/src/testing


From: gnunet
Subject: [GNUnet-SVN] r11783 - gnunet/src/testing
Date: Thu, 17 Jun 2010 17:29:40 +0200

Author: nevans
Date: 2010-06-17 17:29:40 +0200 (Thu, 17 Jun 2010)
New Revision: 11783

Modified:
   gnunet/src/testing/test_testing_topology.c
   gnunet/src/testing/testing.c
   gnunet/src/testing/testing_group.c
Log:
some testing changes, including an api change that likely breaks things for 
others

Modified: gnunet/src/testing/test_testing_topology.c
===================================================================
--- gnunet/src/testing/test_testing_topology.c  2010-06-17 15:27:19 UTC (rev 
11782)
+++ gnunet/src/testing/test_testing_topology.c  2010-06-17 15:29:40 UTC (rev 
11783)
@@ -25,7 +25,7 @@
 #include "gnunet_testing_lib.h"
 #include "gnunet_core_service.h"
 
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
 
 /**
  * How long until we fail the whole testcase?
@@ -445,6 +445,7 @@
 topology_callback (void *cls,
                    const struct GNUNET_PeerIdentity *first,
                    const struct GNUNET_PeerIdentity *second,
+                   uint32_t distance,
                    const struct GNUNET_CONFIGURATION_Handle *first_cfg,
                    const struct GNUNET_CONFIGURATION_Handle *second_cfg,
                    struct GNUNET_TESTING_Daemon *first_daemon,
@@ -699,7 +700,7 @@
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "Invalid connect topology `%s' given for section %s option 
%s\n", connect_topology_str, "TESTING", "CONNECT_TOPOLOGY");
     }
-
+  GNUNET_free_non_null(connect_topology_str);
   if ((GNUNET_YES ==
       GNUNET_CONFIGURATION_get_value_string(cfg, "testing", 
"connect_topology_option",
                                             &connect_topology_option_str)) && 
(GNUNET_NO == GNUNET_TESTING_topology_option_get(&connect_topology_option, 
connect_topology_option_str)))
@@ -708,7 +709,7 @@
                   "Invalid connect topology option `%s' given for section %s 
option %s\n", connect_topology_option_str, "TESTING", 
"CONNECT_TOPOLOGY_OPTION");
       connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* 
Defaults to NONE, set to ALL */
     }
-
+  GNUNET_free_non_null(connect_topology_option_str);
   if (GNUNET_YES ==
         GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 
"connect_topology_option_modifier",
                                                
&connect_topology_option_modifier_string))
@@ -730,11 +731,13 @@
 
   if ((GNUNET_YES ==
       GNUNET_CONFIGURATION_get_value_string(cfg, "testing", 
"blacklist_topology",
-                                            & blacklist_topology_str)) && 
(GNUNET_NO == GNUNET_TESTING_topology_get(&blacklist_topology, 
blacklist_topology_str)))
+                                            &blacklist_topology_str)) && 
(GNUNET_NO == GNUNET_TESTING_topology_get(&blacklist_topology, 
blacklist_topology_str)))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "Invalid topology `%s' given for section %s option %s\n", 
topology_str, "TESTING", "BLACKLIST_TOPOLOGY");
     }
+  GNUNET_free_non_null(topology_str);
+  GNUNET_free_non_null(blacklist_topology_str);
 
   if (GNUNET_SYSERR ==
       GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",

Modified: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c        2010-06-17 15:27:19 UTC (rev 11782)
+++ gnunet/src/testing/testing.c        2010-06-17 15:29:40 UTC (rev 11783)
@@ -1158,11 +1158,15 @@
    */
   struct GNUNET_TIME_Relative timeout_hello;
 
-
   /**
    * Was the connection attempt successful?
    */
   int connected;
+
+  /**
+   * The distance between the two connected peers
+   */
+  uint32_t distance;
 };
 
 
@@ -1210,7 +1214,7 @@
     {
       if (ctx->cb != NULL)
         {
-          ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, ctx->d1->cfg,
+          ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, ctx->distance, 
ctx->d1->cfg,
                    ctx->d2->cfg, ctx->d1, ctx->d2, NULL);
         }
     }
@@ -1234,7 +1238,7 @@
     {
       if (ctx->cb != NULL)
         {
-          ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, ctx->d1->cfg,
+          ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, 0, ctx->d1->cfg,
                    ctx->d2->cfg, ctx->d1, ctx->d2,
                    _("Peers failed to connect"));
         }
@@ -1266,6 +1270,7 @@
   if (memcmp(&ctx->d2->id, peer, sizeof(struct GNUNET_PeerIdentity)) == 0)
     {
       ctx->connected = GNUNET_YES;
+      ctx->distance = distance;
       GNUNET_SCHEDULER_cancel(ctx->d1->sched, ctx->timeout_task);
       ctx->timeout_task = GNUNET_SCHEDULER_add_now (ctx->d1->sched,
                                                    &notify_connect_result,
@@ -1319,7 +1324,7 @@
   if ((d1->running == GNUNET_NO) || (d2->running == GNUNET_NO))
     {
       if (NULL != cb)
-        cb (cb_cls, &d1->id, &d2->id, d1->cfg, d2->cfg, d1, d2,
+        cb (cb_cls, &d1->id, &d2->id, 0, d1->cfg, d2->cfg, d1, d2,
             _("Peers are not fully running yet, can not connect!\n"));
       return;
     }
@@ -1351,7 +1356,7 @@
     {
       GNUNET_free (ctx);
       if (NULL != cb)
-        cb (cb_cls, &d1->id, &d2->id, d1->cfg, d2->cfg, d1, d2,
+        cb (cb_cls, &d1->id, &d2->id, 0, d1->cfg, d2->cfg, d1, d2,
             _("Failed to connect to core service of first peer!\n"));
       return;
     }
@@ -1372,7 +1377,7 @@
       GNUNET_CORE_disconnect(ctx->d1core);
       GNUNET_free (ctx);
       if (NULL != cb)
-        cb (cb_cls, &d1->id, &d2->id, d1->cfg, d2->cfg, d1, d2,
+        cb (cb_cls, &d1->id, &d2->id, 0, d1->cfg, d2->cfg, d1, d2,
             _("Failed to connect to transport service!\n"));
       return;
     }
@@ -1412,7 +1417,7 @@
   if (ctx->d1core == NULL)
     {
       if (NULL != ctx->cb)
-        ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, ctx->d1->cfg, 
ctx->d2->cfg, ctx->d1, ctx->d2,
+        ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, 0, ctx->d1->cfg, 
ctx->d2->cfg, ctx->d1, ctx->d2,
                  _("Failed to connect to core service of first peer!\n"));
       GNUNET_free (ctx);
       return;
@@ -1425,7 +1430,7 @@
       GNUNET_CORE_disconnect(ctx->d1core);
       GNUNET_free (ctx);
       if (NULL != ctx->cb)
-        ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, ctx->d1->cfg, 
ctx->d2->cfg, ctx->d1, ctx->d2,
+        ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, 0, ctx->d1->cfg, 
ctx->d2->cfg, ctx->d1, ctx->d2,
             _("Failed to connect to transport service!\n"));
       return;
     }

Modified: gnunet/src/testing/testing_group.c
===================================================================
--- gnunet/src/testing/testing_group.c  2010-06-17 15:27:19 UTC (rev 11782)
+++ gnunet/src/testing/testing_group.c  2010-06-17 15:29:40 UTC (rev 11783)
@@ -22,6 +22,15 @@
  * @file testing/testing_group.c
  * @brief convenience API for writing testcases for GNUnet
  * @author Christian Grothoff
+ *
+ * FIXME: have connection processor functions take a cls argument
+ *        which specifies where to write the connection information
+ *        instead of assuming it's certain peergroup places. (maybe?)
+ * FIXME: create static struct which contains the TOPOLOGY enum, the
+ *        associated string, and the function used to create it.
+ *        Then replace the create_X calls with topology_struct[i][2]
+ *        or something. (Store function pointers instead of using
+ *        switch statements)
  */
 #include "platform.h"
 #include "gnunet_arm_service.h"
@@ -108,6 +117,11 @@
   "SCALE_FREE",
 
   /**
+   * Straight line topology.
+   */
+  "LINE",
+
+  /**
    * All peers are disconnected.
    */
   "NONE"
@@ -902,6 +916,17 @@
   return total_connections;
 }
 
+/**
+ * Create a topology given a peer group (set of running peers)
+ * and a connection processor.
+ *
+ * @param pg the peergroup to create the topology on
+ * @param proc the connection processor to call to actually set
+ *        up connections between two peers
+ *
+ * @return the number of connections that were set up
+ *
+ */
 int
 create_small_world_ring(struct GNUNET_TESTING_PeerGroup *pg, 
GNUNET_TESTING_ConnectionProcessor proc)
 {
@@ -1013,7 +1038,17 @@
   return connect_attempts;
 }
 
-
+/**
+ * Create a topology given a peer group (set of running peers)
+ * and a connection processor.
+ *
+ * @param pg the peergroup to create the topology on
+ * @param proc the connection processor to call to actually set
+ *        up connections between two peers
+ *
+ * @return the number of connections that were set up
+ *
+ */
 static int
 create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg, 
GNUNET_TESTING_ConnectionProcessor proc)
 {
@@ -1065,8 +1100,17 @@
 
 }
 
-
-
+/**
+ * Create a topology given a peer group (set of running peers)
+ * and a connection processor.
+ *
+ * @param pg the peergroup to create the topology on
+ * @param proc the connection processor to call to actually set
+ *        up connections between two peers
+ *
+ * @return the number of connections that were set up
+ *
+ */
 static int
 create_small_world (struct GNUNET_TESTING_PeerGroup *pg, 
GNUNET_TESTING_ConnectionProcessor proc)
 {
@@ -1208,8 +1252,17 @@
   return connect_attempts;
 }
 
-
-
+/**
+ * Create a topology given a peer group (set of running peers)
+ * and a connection processor.
+ *
+ * @param pg the peergroup to create the topology on
+ * @param proc the connection processor to call to actually set
+ *        up connections between two peers
+ *
+ * @return the number of connections that were set up
+ *
+ */
 static int
 create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg, 
GNUNET_TESTING_ConnectionProcessor proc)
 {
@@ -1257,6 +1310,17 @@
   return connect_attempts;
 }
 
+/**
+ * Create a topology given a peer group (set of running peers)
+ * and a connection processor.
+ *
+ * @param pg the peergroup to create the topology on
+ * @param proc the connection processor to call to actually set
+ *        up connections between two peers
+ *
+ * @return the number of connections that were set up
+ *
+ */
 static int
 create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg, 
GNUNET_TESTING_ConnectionProcessor proc)
 {
@@ -1334,7 +1398,17 @@
 }
 
 
-
+/**
+ * Create a topology given a peer group (set of running peers)
+ * and a connection processor.
+ *
+ * @param pg the peergroup to create the topology on
+ * @param proc the connection processor to call to actually set
+ *        up connections between two peers
+ *
+ * @return the number of connections that were set up
+ *
+ */
 static int
 create_clique (struct GNUNET_TESTING_PeerGroup *pg, 
GNUNET_TESTING_ConnectionProcessor proc)
 {
@@ -1361,7 +1435,50 @@
   return connect_attempts;
 }
 
+/**
+ * Create a topology given a peer group (set of running peers)
+ * and a connection processor.
+ *
+ * @param pg the peergroup to create the topology on
+ * @param proc the connection processor to call to actually set
+ *        up connections between two peers
+ *
+ * @return the number of connections that were set up
+ *
+ */
+static int
+create_line (struct GNUNET_TESTING_PeerGroup *pg, 
GNUNET_TESTING_ConnectionProcessor proc)
+{
+  unsigned int count;
+  int connect_attempts;
 
+  connect_attempts = 0;
+
+  /* Connect each peer to the next highest numbered peer */
+  for (count = 0; count < pg->total - 1; count++)
+    {
+#if VERBOSE_TESTING
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      "Connecting peer %d to peer %d\n",
+                      count, count + 1);
+#endif
+      connect_attempts += proc(pg, count, count + 1);
+    }
+
+  return connect_attempts;
+}
+
+/**
+ * Create a topology given a peer group (set of running peers)
+ * and a connection processor.
+ *
+ * @param pg the peergroup to create the topology on
+ * @param proc the connection processor to call to actually set
+ *        up connections between two peers
+ *
+ * @return the number of connections that were set up
+ *
+ */
 static int
 create_ring (struct GNUNET_TESTING_PeerGroup *pg, 
GNUNET_TESTING_ConnectionProcessor proc)
 {
@@ -1745,6 +1862,7 @@
 static void internal_connect_notify (void *cls,
                                      const struct GNUNET_PeerIdentity *first,
                                      const struct GNUNET_PeerIdentity *second,
+                                     uint32_t distance,
                                      const struct GNUNET_CONFIGURATION_Handle 
*first_cfg,
                                      const struct GNUNET_CONFIGURATION_Handle 
*second_cfg,
                                      struct GNUNET_TESTING_Daemon 
*first_daemon,
@@ -1754,12 +1872,16 @@
   struct GNUNET_TESTING_PeerGroup *pg = cls;
   outstanding_connects--;
 
+<<<<<<< .mine
+  pg->notify_connection(pg->notify_connection_cls, first, second, distance, 
first_cfg, second_cfg, first_daemon, second_daemon, emsg);
+=======
   pg->notify_connection(pg->notify_connection_cls, 
                        first,
                        second, 
                        first_cfg, second_cfg, 
                        first_daemon, second_daemon, 
                        emsg);
+>>>>>>> .r11782
 
 }
 
@@ -2010,6 +2132,13 @@
 #endif
       num_connections = create_scale_free (pg, &add_allowed_connections);
       break;
+    case GNUNET_TESTING_TOPOLOGY_LINE:
+#if VERBOSE_TESTING
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  _("Creating straight line topology\n"));
+#endif
+      num_connections = create_line (pg, &add_allowed_connections);
+      break;
     case GNUNET_TESTING_TOPOLOGY_NONE:
       num_connections = 0;
       break;
@@ -2103,6 +2232,13 @@
 #endif
       unblacklisted_connections = create_scale_free (pg, 
&unblacklist_connections);
       break;
+    case GNUNET_TESTING_TOPOLOGY_LINE:
+#if VERBOSE_TESTING
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  _("Blacklisting all but straight line topology\n"));
+#endif
+      unblacklisted_connections = create_line (pg, &unblacklist_connections);
+      break;
     case GNUNET_TESTING_TOPOLOGY_NONE:
       /* Fall through */
     default:
@@ -2581,6 +2717,13 @@
 #endif
         create_scale_free (pg, &add_actual_connections);
         break;
+      case GNUNET_TESTING_TOPOLOGY_LINE:
+#if VERBOSE_TOPOLOGY
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  _("Creating straight line CONNECT topology\n"));
+#endif
+        create_line (pg, &add_actual_connections);
+        break;
       case GNUNET_TESTING_TOPOLOGY_NONE:
 #if VERBOSE_TOPOLOGY
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,




reply via email to

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