log: add \n
[oweals/gnunet.git] / src / regex / test_regex_integration.c
index 734b1c604277438519ce504b4fd219190112fc4c..d98d800709407540d28b95be936cc309b0022160 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2013, 2015 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2013, 2015 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
      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.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
 */
 /**
  * @file regex/test_regex_integration.c
@@ -25,6 +25,7 @@
  * @author Christian Grothoff
  */
 #include "platform.h"
+#include "gnunet_applications.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_tun_lib.h"
 #include "gnunet_testing_lib.h"
@@ -56,8 +57,7 @@ static struct GNUNET_SCHEDULER_Task *die_task;
 
 
 static void
-end (void *cls,
-     const struct GNUNET_SCHEDULER_TaskContext *tc)
+end (void *cls)
 {
   die_task = NULL;
   GNUNET_REGEX_announce_cancel (a4);
@@ -75,9 +75,8 @@ end (void *cls,
 static void
 end_badly ()
 {
-  die_task = NULL;
   FPRINTF (stderr, "%s",  "Testcase failed (timeout).\n");
-  end (NULL, NULL);
+  end (NULL);
   ok = 1;
 }
 
@@ -85,7 +84,7 @@ end_badly ()
 /**
  * Search callback function, invoked for every result that was found.
  *
- * @param cls Closure provided in GNUNET_REGEX_search.
+ * @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.
@@ -103,9 +102,9 @@ found_cb (void *cls,
   const char *str = cls;
   static int found;
 
-  fprintf (stderr,
-           "IPv%s-exit found\n",
-           str);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "IPv%s-exit found\n",
+              str);
   if (0 == strcmp (str, "4"))
     found |= 4;
   if (0 == strcmp (str, "6"))
@@ -125,9 +124,13 @@ run (void *cls,
      struct GNUNET_TESTING_Peer *peer)
 {
   char rxstr4[GNUNET_TUN_IPV4_REGEXLEN];
-  char rxstr6[GNUNET_TUN_IPV4_REGEXLEN];
+  char rxstr6[GNUNET_TUN_IPV6_REGEXLEN];
+  char *p4r;
+  char *p6r;
   char *p4;
   char *p6;
+  char *ss4;
+  char *ss6;
   struct in_addr i4;
   struct in6_addr i6;
 
@@ -148,8 +151,26 @@ run (void *cls,
   GNUNET_TUN_ipv6toregexsearch (&i6,
                                 8686,
                                 rxstr6);
-  p4 = GNUNET_TUN_ipv4policy2regex ("0.0.0.0/0:!25;");
-  p6 = GNUNET_TUN_ipv6policy2regex ("::/0:!25;");
+  GNUNET_asprintf (&ss4,
+                   "%s%s",
+                   GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
+                   rxstr4);
+  GNUNET_asprintf (&ss6,
+                   "%s%s",
+                   GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
+                   rxstr6);
+  p4r = GNUNET_TUN_ipv4policy2regex ("0.0.0.0/0:!25;");
+  p6r = GNUNET_TUN_ipv6policy2regex ("::/0:!25;");
+  GNUNET_asprintf (&p4,
+                   "%s%s",
+                   GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
+                   p4r);
+  GNUNET_asprintf (&p6,
+                   "%s%s",
+                   GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
+                   p6r);
+  GNUNET_free (p4r);
+  GNUNET_free (p6r);
   a4 = GNUNET_REGEX_announce (cfg,
                               p4,
                               GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
@@ -164,11 +185,13 @@ run (void *cls,
   GNUNET_free (p6);
 
   s4 = GNUNET_REGEX_search (cfg,
-                            rxstr4,
+                            ss4,
                             &found_cb, "4");
   s6 = GNUNET_REGEX_search (cfg,
-                            rxstr6,
+                            ss6,
                             &found_cb, "6");
+  GNUNET_free (ss4);
+  GNUNET_free (ss6);
 }