gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r9371 - in gnunet: . src/testing


From: gnunet
Subject: [GNUnet-SVN] r9371 - in gnunet: . src/testing
Date: Sat, 31 Oct 2009 15:57:40 -0600

Author: grothoff
Date: 2009-10-31 15:57:40 -0600 (Sat, 31 Oct 2009)
New Revision: 9371

Added:
   gnunet/src/testing/test_testing_group.c
Modified:
   gnunet/BUGS
   gnunet/TODO
   gnunet/src/testing/
   gnunet/src/testing/Makefile.am
   gnunet/src/testing/test_testing_connect.c
Log:
group test works

Modified: gnunet/BUGS
===================================================================
--- gnunet/BUGS 2009-10-31 21:29:07 UTC (rev 9370)
+++ gnunet/BUGS 2009-10-31 21:57:40 UTC (rev 9371)
@@ -133,4 +133,6 @@
 * HOSTLIST:
   - implement advertising of hostlist URL
   - implement learning of hostlist URLs
-
+* TESTING:
+  - consider changing API for peer-group termination to 
+    call continuation when done

Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2009-10-31 21:29:07 UTC (rev 9370)
+++ gnunet/TODO 2009-10-31 21:57:40 UTC (rev 9371)
@@ -12,12 +12,6 @@
 * UPNP [Milan]
 
 Urgent items (before announcing ng.gnunet.org):
-* TESTING (needed for DV, DHT, Topology)
-  - implement library for local testing
-    + consider changing API for peer-group termination to 
-      call continuation when done
-  - implement testcases for library
-    + test group start
 * TEST:
   - topology (needs TESTING)
   - hostlist (maybe easier with TESTING?)


Property changes on: gnunet/src/testing
___________________________________________________________________
Modified: svn:ignore
   - test_testing_connect
testing_testbed.gcno
testing_testbed.gcda
testing_group.gcno
testing_group.gcda
testing.gcno
testing.gcda
test_testing.gcno
test_testing.gcda
test_testing
Makefile.in
Makefile
.deps

   + test_testing_group
test_testing_connect
testing_testbed.gcno
testing_testbed.gcda
testing_group.gcno
testing_group.gcda
testing.gcno
testing.gcda
test_testing.gcno
test_testing.gcda
test_testing
Makefile.in
Makefile
.deps


Modified: gnunet/src/testing/Makefile.am
===================================================================
--- gnunet/src/testing/Makefile.am      2009-10-31 21:29:07 UTC (rev 9370)
+++ gnunet/src/testing/Makefile.am      2009-10-31 21:57:40 UTC (rev 9371)
@@ -22,9 +22,14 @@
 
 check_PROGRAMS = \
  test_testing \
- test_testing_connect
+ test_testing_connect \
+ test_testing_group
 
-TESTS = $(check_PROGRAMS)
+TESTS = \
+ test_testing \
+ test_testing_connect \
+ test_testing_group
+#$(check_PROGRAMS)
 
 test_testing_SOURCES = \
  test_testing.c
@@ -38,6 +43,12 @@
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
+test_testing_group_SOURCES = \
+ test_testing_group.c
+test_testing_group_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la  
+
 EXTRA_DIST = \
  test_testing_data.conf \
  test_testing_connect_peer1.conf \

Modified: gnunet/src/testing/test_testing_connect.c
===================================================================
--- gnunet/src/testing/test_testing_connect.c   2009-10-31 21:29:07 UTC (rev 
9370)
+++ gnunet/src/testing/test_testing_connect.c   2009-10-31 21:57:40 UTC (rev 
9371)
@@ -157,7 +157,7 @@
     GNUNET_GETOPT_OPTION_END
   };
   GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
-                      argv, "test-testing", "nohelp",
+                      argv, "test-testing-connect", "nohelp",
                       options, &run, &ok);
   return ok;
 }
@@ -167,7 +167,7 @@
 {
   int ret;
 
-  GNUNET_log_setup ("test-testing",
+  GNUNET_log_setup ("test-testing-connect",
 #if VERBOSE
                     "DEBUG",
 #else

Added: gnunet/src/testing/test_testing_group.c
===================================================================
--- gnunet/src/testing/test_testing_group.c                             (rev 0)
+++ gnunet/src/testing/test_testing_group.c     2009-10-31 21:57:40 UTC (rev 
9371)
@@ -0,0 +1,119 @@
+/*
+     This file is part of GNUnet.
+     (C) 2009 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     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.
+*/
+/**
+ * @file testing/test_testing_group.c
+ * @brief testcase for functions to connect two peers in testing.c
+ */
+#include "platform.h"
+#include "gnunet_testing_lib.h"
+
+#define VERBOSE GNUNET_NO
+
+
+/**
+ * How long until we give up on connecting the peers?
+ */
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+
+
+static int ok;
+
+static int peers_left;
+
+static struct GNUNET_TESTING_PeerGroup *pg;
+
+static struct GNUNET_SCHEDULER_Handle *sched;
+
+
+static void my_cb(void *cls,
+                  const struct GNUNET_PeerIdentity *id,
+                  const struct GNUNET_CONFIGURATION_Handle *cfg,
+                  struct GNUNET_TESTING_Daemon *d,
+                  const char *emsg)
+{
+  GNUNET_assert (id != NULL);
+  peers_left--;
+  if (peers_left == 0)
+    {
+      GNUNET_TESTING_daemons_stop (pg);
+      ok = 0;
+    }
+}
+
+
+static void
+run (void *cls,
+     struct GNUNET_SCHEDULER_Handle *s,
+     char *const *args,
+     const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  sched = s;
+  ok = 1;
+#if VERBOSE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Starting daemons.\n");
+#endif
+  peers_left = 4;
+  pg = GNUNET_TESTING_daemons_start (sched, cfg, 
+                                    peers_left,
+                                    &my_cb, NULL, NULL);
+  GNUNET_assert (pg != NULL);
+}
+
+static int
+check ()
+{
+  char *const argv[] = { "test-testing",
+    "-c",
+    "test_testing_data.conf",
+#if VERBOSE
+    "-L", "DEBUG",
+#endif
+    NULL
+  };
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_OPTION_END
+  };
+  GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
+                      argv, "test-testing-group", "nohelp",
+                      options, &run, &ok);
+  return ok;
+}
+
+int
+main (int argc, char *argv[])
+{
+  int ret;
+
+  GNUNET_log_setup ("test-testing-group",
+#if VERBOSE
+                    "DEBUG",
+#else
+                    "WARNING",
+#endif
+                    NULL);
+  ret = check ();
+  sleep (1);
+  GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
+  return ret;
+}
+
+/* end of test_testing_group.c */





reply via email to

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