gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r35786 - gnunet/src/regex


From: gnunet
Subject: [GNUnet-SVN] r35786 - gnunet/src/regex
Date: Fri, 22 May 2015 14:03:07 +0200

Author: grothoff
Date: 2015-05-22 14:03:07 +0200 (Fri, 22 May 2015)
New Revision: 35786

Added:
   gnunet/src/regex/test_regex_integration.c
Modified:
   gnunet/src/regex/Makefile.am
   gnunet/src/regex/regex.conf.in
Log:
-adding integration test

Modified: gnunet/src/regex/Makefile.am
===================================================================
--- gnunet/src/regex/Makefile.am        2015-05-22 10:20:33 UTC (rev 35785)
+++ gnunet/src/regex/Makefile.am        2015-05-22 12:03:07 UTC (rev 35786)
@@ -31,7 +31,7 @@
  $(top_builddir)/src/dht/libgnunetdht.la \
  $(top_builddir)/src/statistics/libgnunetstatistics.la \
  $(top_builddir)/src/util/libgnunetutil.la \
- $(GN_LIBINTL) 
+ $(GN_LIBINTL)
 
 noinst_LIBRARIES = \
   libgnunetregex_internal.a \
@@ -64,7 +64,7 @@
 libgnunetregex_la_SOURCES = \
   regex_api.c regex_ipc.h
 libgnunetregex_la_LIBADD = \
-  $(top_builddir)/src/util/libgnunetutil.la 
+  $(top_builddir)/src/util/libgnunetutil.la
 libgnunetregex_la_LDFLAGS = \
   $(GN_LIB_LDFLAGS) \
    -version-info 3:1:0
@@ -92,13 +92,13 @@
   $(top_builddir)/src/util/libgnunetutil.la \
   libgnunetregex_internal.a \
   $(top_builddir)/src/dht/libgnunetdht.la \
-  $(top_builddir)/src/mysql/libgnunetmysql.la 
+  $(top_builddir)/src/mysql/libgnunetmysql.la
 endif
 
 libgnunetregextest_a_SOURCES = \
   regex_test_lib.c regex_test_lib.h \
   regex_test_graph.c \
-  regex_test_random.c 
+  regex_test_random.c
 libgnunetregextest_a_LIBADD = \
  $(top_builddir)/src/util/libgnunetutil.la \
  libgnunetregex_internal.a
@@ -116,7 +116,7 @@
   $(top_builddir)/src/dht/libgnunetdht.la \
   libgnunetregexblock.la \
   libgnunetregextest.a \
-  $(top_builddir)/src/util/libgnunetutil.la 
+  $(top_builddir)/src/util/libgnunetutil.la
 
 gnunet_regex_profiler_SOURCES = \
   gnunet-regex-profiler.c
@@ -128,7 +128,7 @@
   libgnunetregexblock.la \
   libgnunetregextest.a \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
-  $(top_builddir)/src/util/libgnunetutil.la 
+  $(top_builddir)/src/util/libgnunetutil.la
 
 gnunet_daemon_regexprofiler_SOURCES = \
   gnunet-daemon-regexprofiler.c
@@ -138,9 +138,10 @@
   libgnunetregexblock.la \
   libgnunetregextest.a \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
-  $(top_builddir)/src/util/libgnunetutil.la 
+  $(top_builddir)/src/util/libgnunetutil.la
 
 check_PROGRAMS = \
+  test_regex_integration \
   test_regex_eval_api \
   test_regex_iterate_api \
   test_regex_proofs \
@@ -161,6 +162,14 @@
   libgnunetregexblock.la \
   $(top_builddir)/src/util/libgnunetutil.la
 
+test_regex_integration_SOURCES = \
+  test_regex_integration.c
+test_regex_integration_LDADD = -lm \
+  libgnunetregex.la \
+  $(top_builddir)/src/testing/libgnunettesting.la \
+  $(top_builddir)/src/tun/libgnunettun.la \
+  $(top_builddir)/src/util/libgnunetutil.la
+
 test_regex_api_SOURCES = \
   test_regex_api.c
 test_regex_api_LDADD = -lm \

Modified: gnunet/src/regex/regex.conf.in
===================================================================
--- gnunet/src/regex/regex.conf.in      2015-05-22 10:20:33 UTC (rev 35785)
+++ gnunet/src/regex/regex.conf.in      2015-05-22 12:03:07 UTC (rev 35786)
@@ -1,6 +1,6 @@
 [regex]
 AUTOSTART = @AUTOSTART@
address@hidden@ PORT = 2107
+PORT = 2107
 UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-regex.sock
 HOSTNAME = localhost
 BINARY = gnunet-service-regex

Added: gnunet/src/regex/test_regex_integration.c
===================================================================
--- gnunet/src/regex/test_regex_integration.c                           (rev 0)
+++ gnunet/src/regex/test_regex_integration.c   2015-05-22 12:03:07 UTC (rev 
35786)
@@ -0,0 +1,185 @@
+/*
+     This file is part of GNUnet.
+     Copyright (C) 2013, 2015 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 3, 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 regex/test_regex_integration.c
+ * @brief base test case for regex integration with VPN;
+ *        tests that the regexes generated by the TUN API
+ *        for IP addresses work (for some simple cases)
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_tun_lib.h"
+#include "gnunet_testing_lib.h"
+#include "gnunet_regex_service.h"
+
+
+/**
+ * How long until we really give up on a particular testcase portion?
+ */
+#define TOTAL_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 
600)
+
+/**
+ * How long until we give up on any particular operation (and retry)?
+ */
+#define BASE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 
3)
+
+
+static struct GNUNET_REGEX_Announcement *a4;
+
+static struct GNUNET_REGEX_Search *s4;
+
+static struct GNUNET_REGEX_Announcement *a6;
+
+static struct GNUNET_REGEX_Search *s6;
+
+static int ok = 1;
+
+static struct GNUNET_SCHEDULER_Task *die_task;
+
+
+static void
+end (void *cls,
+     const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  die_task = NULL;
+  GNUNET_REGEX_announce_cancel (a4);
+  a4 = NULL;
+  GNUNET_REGEX_search_cancel (s4);
+  s4 = NULL;
+  GNUNET_REGEX_announce_cancel (a6);
+  a6 = NULL;
+  GNUNET_REGEX_search_cancel (s6);
+  s6 = NULL;
+  ok = 0;
+}
+
+
+static void
+end_badly ()
+{
+  die_task = NULL;
+  FPRINTF (stderr, "%s",  "Testcase failed (timeout).\n");
+  end (NULL, NULL);
+  ok = 1;
+}
+
+
+/**
+ * Search callback function, invoked for every result that was found.
+ *
+ * @param cls Closure provided in GNUNET_REGEX_search.
+ * @param id Peer providing a regex that matches the string.
+ * @param get_path Path of the get request.
+ * @param get_path_length Length of @a get_path.
+ * @param put_path Path of the put request.
+ * @param put_path_length Length of the @a put_path.
+ */
+static void
+found_cb (void *cls,
+         const struct GNUNET_PeerIdentity *id,
+         const struct GNUNET_PeerIdentity *get_path,
+         unsigned int get_path_length,
+         const struct GNUNET_PeerIdentity *put_path,
+         unsigned int put_path_length)
+{
+  const char *str = cls;
+  static int found;
+
+  fprintf (stderr,
+           "IPv%s-exit found\n",
+           str);
+  if (0 == strcmp (str, "4"))
+    found |= 4;
+  if (0 == strcmp (str, "6"))
+    found |= 2;
+  if ((4|2) == found)
+  {
+    GNUNET_SCHEDULER_cancel (die_task);
+    die_task =
+    GNUNET_SCHEDULER_add_now (&end, NULL);
+  }
+}
+
+
+static void
+run (void *cls,
+     const struct GNUNET_CONFIGURATION_Handle *cfg,
+     struct GNUNET_TESTING_Peer *peer)
+{
+  char rxstr4[GNUNET_TUN_IPV4_REGEXLEN];
+  char rxstr6[GNUNET_TUN_IPV4_REGEXLEN];
+  char *p4;
+  char *p6;
+  struct in_addr i4;
+  struct in6_addr i6;
+
+  die_task =
+    GNUNET_SCHEDULER_add_delayed (TOTAL_TIMEOUT,
+                                 &end_badly, NULL);
+  GNUNET_assert (1 ==
+                 inet_pton (AF_INET,
+                            "127.0.0.1",
+                            &i4));
+  GNUNET_assert (1 ==
+                 inet_pton (AF_INET6,
+                            "::1:5",
+                            &i6));
+  GNUNET_TUN_ipv4toregexsearch (&i4,
+                                8080,
+                                rxstr4);
+  GNUNET_TUN_ipv6toregexsearch (&i6,
+                                8686,
+                                rxstr6);
+  p4 = GNUNET_TUN_ipv4policy2regex ("0.0.0.0/0:!25;");
+  p6 = GNUNET_TUN_ipv6policy2regex ("::/0:!25;");
+  a4 = GNUNET_REGEX_announce (cfg,
+                              p4,
+                              GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS,
+                                                             5),
+                            1);
+  a6 = GNUNET_REGEX_announce (cfg,
+                              p6,
+                              GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS,
+                                                             5),
+                              1);
+  GNUNET_free (p4);
+  GNUNET_free (p6);
+
+  s4 = GNUNET_REGEX_search (cfg,
+                            rxstr4,
+                            &found_cb, "4");
+  s6 = GNUNET_REGEX_search (cfg,
+                            rxstr6,
+                            &found_cb, "6");
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  if (0 != GNUNET_TESTING_peer_run ("test-regex-integration",
+                                   "test_regex_api_data.conf",
+                                   &run, NULL))
+    return 1;
+  return ok;
+}
+
+/* end of test_regex_integration.c */




reply via email to

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