gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r12013 - gnunet/src/testing
Date: Mon, 28 Jun 2010 14:21:40 +0200

Author: nevans
Date: 2010-06-28 14:21:40 +0200 (Mon, 28 Jun 2010)
New Revision: 12013

Modified:
   gnunet/src/testing/test_testing_connect.c
   gnunet/src/testing/test_testing_data_topology_clique.conf
   gnunet/src/testing/test_testing_data_topology_clique_minimum.conf
   gnunet/src/testing/test_testing_data_topology_clique_random.conf
   gnunet/src/testing/test_testing_group.c
   gnunet/src/testing/test_testing_group_remote.c
   gnunet/src/testing/test_testing_topology.c
   gnunet/src/testing/test_testing_topology_blacklist.c
   gnunet/src/testing/test_testing_topology_churn.c
   gnunet/src/testing/testing_group.c
Log:
callback for peergroup shutdown in testing, requisite testcase changes

Modified: gnunet/src/testing/test_testing_connect.c
===================================================================
--- gnunet/src/testing/test_testing_connect.c   2010-06-28 11:37:52 UTC (rev 
12012)
+++ gnunet/src/testing/test_testing_connect.c   2010-06-28 12:21:40 UTC (rev 
12013)
@@ -26,7 +26,6 @@
 
 #define VERBOSE GNUNET_NO
 
-
 /**
  * How long until we give up on connecting the peers?
  */

Modified: gnunet/src/testing/test_testing_data_topology_clique.conf
===================================================================
--- gnunet/src/testing/test_testing_data_topology_clique.conf   2010-06-28 
11:37:52 UTC (rev 12012)
+++ gnunet/src/testing/test_testing_data_topology_clique.conf   2010-06-28 
12:21:40 UTC (rev 12013)
@@ -32,7 +32,7 @@
 #DEBUG = YES
 #PREFIX = xterm -e xterm -T peerinfo -e gdb --args
 #BINARY = 
/home/mrwiggles/documents/research/gnunet/gnunet-ng/src/peerinfo/.libs/gnunet-service-peerinfo
-#PREFIX = valgrind --tool=memcheck --log-file=peerinfo%p
+PREFIX = valgrind --tool=memcheck --log-file=peerinfo%p
 
 [core]
 PORT = 2570

Modified: gnunet/src/testing/test_testing_data_topology_clique_minimum.conf
===================================================================
--- gnunet/src/testing/test_testing_data_topology_clique_minimum.conf   
2010-06-28 11:37:52 UTC (rev 12012)
+++ gnunet/src/testing/test_testing_data_topology_clique_minimum.conf   
2010-06-28 12:21:40 UTC (rev 12013)
@@ -40,9 +40,9 @@
 #DEBUG = YES
 
 [testing]
-NUM_PEERS = 5
+NUM_PEERS = 20
 WEAKRANDOM = YES
 TOPOLOGY = CLIQUE
 CONNECT_TOPOLOGY_OPTION = CONNECT_MINIMUM
-CONNECT_TOPOLOGY_OPTION_MODIFIER = 1.0
+CONNECT_TOPOLOGY_OPTION_MODIFIER = 2.0
 F2F = YES

Modified: gnunet/src/testing/test_testing_data_topology_clique_random.conf
===================================================================
--- gnunet/src/testing/test_testing_data_topology_clique_random.conf    
2010-06-28 11:37:52 UTC (rev 12012)
+++ gnunet/src/testing/test_testing_data_topology_clique_random.conf    
2010-06-28 12:21:40 UTC (rev 12013)
@@ -40,9 +40,9 @@
 #DEBUG = YES
 
 [testing]
-NUM_PEERS = 5
+NUM_PEERS = 20
 WEAKRANDOM = YES
 TOPOLOGY = CLIQUE
 CONNECT_TOPOLOGY_OPTION = CONNECT_RANDOM_SUBSET
-CONNECT_TOPOLOGY_OPTION_MODIFIER = .5
+CONNECT_TOPOLOGY_OPTION_MODIFIER = .15
 F2F = YES

Modified: gnunet/src/testing/test_testing_group.c
===================================================================
--- gnunet/src/testing/test_testing_group.c     2010-06-28 11:37:52 UTC (rev 
12012)
+++ gnunet/src/testing/test_testing_group.c     2010-06-28 12:21:40 UTC (rev 
12013)
@@ -24,7 +24,7 @@
 #include "platform.h"
 #include "gnunet_testing_lib.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 #define NUM_PEERS 4
 
@@ -43,7 +43,31 @@
 
 static struct GNUNET_SCHEDULER_Handle *sched;
 
+/**
+ * Check whether peers successfully shut down.
+ */
+void shutdown_callback (void *cls,
+                        const char *emsg)
+{
+  if (emsg != NULL)
+    {
+#if VERBOSE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Shutdown of peers failed!\n");
+#endif
+      if (ok == 0)
+        ok = 666;
+    }
+  else
+    {
+#if VERBOSE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "All peers successfully shut down!\n");
+#endif
+    }
+}
 
+
 static void
 my_cb (void *cls,
        const struct GNUNET_PeerIdentity *id,
@@ -59,7 +83,7 @@
        {
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Too many peers failed, ending 
test!\n");
          ok = 1;
-         GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+         GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
        }
       return;
     }
@@ -68,14 +92,14 @@
   if (peers_left == 0)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started successfully, 
ending test!\n");
-      GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+      GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
       ok = 0;
     }
   else if (failed_peers == peers_left)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Too many peers failed, ending 
test!\n");
       ok = 1;
-      GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+      GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
     }
 }
 

Modified: gnunet/src/testing/test_testing_group_remote.c
===================================================================
--- gnunet/src/testing/test_testing_group_remote.c      2010-06-28 11:37:52 UTC 
(rev 12012)
+++ gnunet/src/testing/test_testing_group_remote.c      2010-06-28 12:21:40 UTC 
(rev 12013)
@@ -50,7 +50,31 @@
 
 static char *hostnames;
 
+/**
+ * Check whether peers successfully shut down.
+ */
+void shutdown_callback (void *cls,
+                        const char *emsg)
+{
+  if (emsg != NULL)
+    {
+#if VERBOSE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Shutdown of peers failed!\n");
+#endif
+      if (ok == 0)
+        ok = 666;
+    }
+  else
+    {
+#if VERBOSE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "All peers successfully shut down!\n");
+#endif
+    }
+}
 
+
 static void
 my_cb (void *cls,
        const struct GNUNET_PeerIdentity *id,
@@ -65,13 +89,13 @@
   peers_left--;
   if (peers_left == 0)
     {
-      GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+      GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
       ok = 0;
     }
   else if (peers_failed == peers_left)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Too many peers failed, ending 
test!\n");
-      GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+      GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
     }
 }
 

Modified: gnunet/src/testing/test_testing_topology.c
===================================================================
--- gnunet/src/testing/test_testing_topology.c  2010-06-28 11:37:52 UTC (rev 
12012)
+++ gnunet/src/testing/test_testing_topology.c  2010-06-28 12:21:40 UTC (rev 
12013)
@@ -25,7 +25,7 @@
 #include "gnunet_testing_lib.h"
 #include "gnunet_core_service.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 /**
  * How long until we fail the whole testcase?
@@ -137,6 +137,30 @@
 
 static struct TestMessageContext *test_messages;
 
+/**
+ * Check whether peers successfully shut down.
+ */
+void shutdown_callback (void *cls,
+                        const char *emsg)
+{
+  if (emsg != NULL)
+    {
+#if VERBOSE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Shutdown of peers failed!\n");
+#endif
+      if (ok == 0)
+        ok = 666;
+    }
+  else
+    {
+#if VERBOSE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "All peers successfully shut down!\n");
+#endif
+    }
+}
+
 static void
 finish_testing ()
 {
@@ -179,11 +203,8 @@
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "Calling daemons_stop\n");
 #endif
-  GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
-#if VERBOSE
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                      "daemons_stop finished\n");
-#endif
+  GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
+
   if (dotOutFile != NULL)
     {
       fprintf(dotOutFile, "}");
@@ -282,7 +303,7 @@
 
   if (pg != NULL)
     {
-      GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+      GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
       ok = 7331;                /* Opposite of leet */
     }
   else
@@ -295,8 +316,6 @@
     }
 }
 
-
-
 static size_t
 transmit_ready (void *cls, size_t size, void *buf)
 {

Modified: gnunet/src/testing/test_testing_topology_blacklist.c
===================================================================
--- gnunet/src/testing/test_testing_topology_blacklist.c        2010-06-28 
11:37:52 UTC (rev 12012)
+++ gnunet/src/testing/test_testing_topology_blacklist.c        2010-06-28 
12:21:40 UTC (rev 12013)
@@ -96,6 +96,31 @@
   uint32_t uid;
 };
 
+
+/**
+ * Check whether peers successfully shut down.
+ */
+void shutdown_callback (void *cls,
+                        const char *emsg)
+{
+  if (emsg != NULL)
+    {
+#if VERBOSE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Shutdown of peers failed!\n");
+#endif
+      if (ok == 0)
+        ok = 666;
+    }
+  else
+    {
+#if VERBOSE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "All peers successfully shut down!\n");
+#endif
+    }
+}
+
 static void
 finish_testing ()
 {
@@ -110,7 +135,7 @@
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "Calling daemons_stop\n");
 #endif
-  GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+  GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
 #if VERBOSE
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "daemons_stop finished\n");
@@ -133,7 +158,7 @@
 
   if (pg != NULL)
     {
-      GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+      GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
       ok = 7331;                /* Opposite of leet */
     }
   else

Modified: gnunet/src/testing/test_testing_topology_churn.c
===================================================================
--- gnunet/src/testing/test_testing_topology_churn.c    2010-06-28 11:37:52 UTC 
(rev 12012)
+++ gnunet/src/testing/test_testing_topology_churn.c    2010-06-28 12:21:40 UTC 
(rev 12013)
@@ -74,6 +74,30 @@
   uint32_t uid;
 };
 
+/**
+ * Check whether peers successfully shut down.
+ */
+void shutdown_callback (void *cls,
+                        const char *emsg)
+{
+  if (emsg != NULL)
+    {
+#if VERBOSE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Shutdown of peers failed!\n");
+#endif
+      if (ok == 0)
+        ok = 666;
+    }
+  else
+    {
+#if VERBOSE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "All peers successfully shut down!\n");
+#endif
+    }
+}
+
 static void
 finish_testing ()
 {
@@ -91,7 +115,7 @@
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "Calling daemons_stop\n");
 #endif
-  GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+  GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
 #if VERBOSE
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "daemons_stop finished\n");
@@ -109,7 +133,7 @@
 
   if (pg != NULL)
     {
-      GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+      GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
       ok = 7331;                /* Opposite of leet */
     }
   else

Modified: gnunet/src/testing/testing_group.c
===================================================================
--- gnunet/src/testing/testing_group.c  2010-06-28 11:37:52 UTC (rev 12012)
+++ gnunet/src/testing/testing_group.c  2010-06-28 12:21:40 UTC (rev 12013)
@@ -21,16 +21,9 @@
 /**
  * @file testing/testing_group.c
  * @brief convenience API for writing testcases for GNUnet
+ * @author Nathan Evans
  * @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"
@@ -55,7 +48,7 @@
  * conflict with the port range for "local" ports (client apps; see
  * /proc/sys/net/ipv4/ip_local_port_range on Linux for example).
  */
-#define HIGH_PORT 32000
+#define HIGH_PORT 56000
 
 #define MAX_OUTSTANDING_CONNECTIONS 50
 
@@ -137,6 +130,36 @@
 
 };
 
+
+struct ShutdownContext
+{
+  /**
+   * Total peers to wait for
+   */
+  int total_peers;
+
+  /**
+   * Number of peers successfully shut down
+   */
+  int peers_down;
+
+  /**
+   * Number of peers failed to shut down
+   */
+  int peers_failed;
+
+  /**
+   * Callback to call when all peers either
+   * shutdown or failed to shutdown
+   */
+  GNUNET_TESTING_NotifyCompletion cb;
+
+  /**
+   * Closure for cb
+   */
+  void *cb_cls;
+};
+
 struct CreateTopologyContext
 {
 
@@ -3347,25 +3370,73 @@
 
 
 /**
+ * Callback for shutting down peers in a peer group.
+ *
+ * @param cls closure (struct ShutdownContext)
+ * @param emsg NULL on success
+ */
+void internal_shutdown_callback (void *cls,
+                        const char *emsg)
+{
+  struct ShutdownContext *shutdown_ctx = cls;
+
+  if (emsg == NULL)
+    {
+      shutdown_ctx->peers_down++;
+    }
+  else
+    {
+      shutdown_ctx->peers_failed++;
+    }
+
+  if ((shutdown_ctx->cb != NULL) && (shutdown_ctx->peers_down + 
shutdown_ctx->peers_failed == shutdown_ctx->total_peers))
+    {
+      if (shutdown_ctx->peers_failed > 0)
+        shutdown_ctx->cb(shutdown_ctx->cb_cls, "Not all peers successfully 
shut down!");
+      else
+        shutdown_ctx->cb(shutdown_ctx->cb_cls, NULL);
+      GNUNET_free(shutdown_ctx);
+    }
+}
+
+/**
  * Shutdown all peers started in the given group.
  *
  * @param pg handle to the peer group
  * @param timeout how long to wait for shutdown
+ * @param cb callback to notify upon success or failure
+ * @param cb_cls closure for cb
  */
 void
 GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg, 
-                            struct GNUNET_TIME_Relative timeout)
+                            struct GNUNET_TIME_Relative timeout,
+                            GNUNET_TESTING_NotifyCompletion cb,
+                             void *cb_cls)
 {
   unsigned int off;
+  struct ShutdownContext *shutdown_ctx;
+  GNUNET_TESTING_NotifyCompletion shutdown_cb;
+  void *shutdown_cb_cls;
 
+  GNUNET_assert(pg->total > 0);
+
+  shutdown_cb = NULL;
+  shutdown_ctx = NULL;
+
+  if (cb != NULL)
+    {
+      shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext));
+      shutdown_ctx->cb = cb;
+      shutdown_ctx->cb_cls = cb_cls;
+      shutdown_ctx->total_peers = pg->total;
+      shutdown_cb = &internal_shutdown_callback;
+      shutdown_cb_cls = cb_cls;
+    }
+
   for (off = 0; off < pg->total; off++)
     {
-      /* FIXME: should we wait for our continuations to be called
-         here? This would require us to take a continuation as
-         well... */
-
       if (NULL != pg->peers[off].daemon)
-        GNUNET_TESTING_daemon_stop (pg->peers[off].daemon, timeout, NULL, 
NULL, GNUNET_YES, GNUNET_NO);
+        GNUNET_TESTING_daemon_stop (pg->peers[off].daemon, timeout, 
shutdown_cb, shutdown_ctx, GNUNET_YES, GNUNET_NO);
       if (NULL != pg->peers[off].cfg)
         GNUNET_CONFIGURATION_destroy (pg->peers[off].cfg);
       if (pg->peers[off].allowed_peers != NULL)




reply via email to

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