gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r24323 - gnunet/src/regex
Date: Mon, 15 Oct 2012 19:06:17 +0200

Author: szengel
Date: 2012-10-15 19:06:17 +0200 (Mon, 15 Oct 2012)
New Revision: 24323

Added:
   gnunet/src/regex/gnunet-regex-profiler.c
   gnunet/src/regex/regex_profiler_test.conf
Modified:
   gnunet/src/regex/Makefile.am
   gnunet/src/regex/regex.c
   gnunet/src/regex/regex_internal.h
   gnunet/src/regex/test_regex_graph_api.c
   gnunet/src/regex/test_regex_iptoregex.c
   gnunet/src/regex/test_regex_iterate_api.c
Log:
renamed test_regex_big / fixes

Modified: gnunet/src/regex/Makefile.am
===================================================================
--- gnunet/src/regex/Makefile.am        2012-10-15 16:17:25 UTC (rev 24322)
+++ gnunet/src/regex/Makefile.am        2012-10-15 17:06:17 UTC (rev 24323)
@@ -14,65 +14,64 @@
   regex_internal.h regex.c \
   regex_graph.c regex_random.c
 libgnunetregex_la_LIBADD = -lm \
- $(top_builddir)/src/util/libgnunetutil.la
+  $(top_builddir)/src/util/libgnunetutil.la
 libgnunetregex_la_LDFLAGS = \
- $(GN_LIB_LDFLAGS) \
-  -version-info 0:0:0
+  $(GN_LIB_LDFLAGS) \
+   -version-info 0:0:0
 
+noinst_PROGRAMS = \
+  gnunet-regex-profiler
+
+gnunet_regex_profiler_SOURCES = \
+  gnunet-regex-profiler.c
+gnunet_regex_profiler_LDADD = \
+  $(top_builddir)/src/regex/libgnunetregex.la \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/testbed/libgnunettestbed.la
+gnunet_regex_profiler_DEPENDENCIES = \
+  libgnunetregex.la
+
 check_PROGRAMS = \
- test_regex_eval_api \
- test_regex_iterate_api \
- test_regex_proofs \
- test_regex_graph_api \
- test_regex_iptoregex \
- test_regex_big
+  test_regex_eval_api \
+  test_regex_iterate_api \
+  test_regex_proofs \
+  test_regex_graph_api \
+  test_regex_iptoregex
 
-
 if ENABLE_TEST_RUN
-TESTS = \
- test_regex_eval_api \
- test_regex_iterate_api \
- test_regex_proofs \
- test_regex_graph_api
+ TESTS = $(check_PROGRAMS)
 endif
 
 test_regex_eval_api_SOURCES = \
- test_regex_eval_api.c
+  test_regex_eval_api.c
 test_regex_eval_api_LDADD = \
- $(top_builddir)/src/regex/libgnunetregex.la \
- $(top_builddir)/src/util/libgnunetutil.la
+  $(top_builddir)/src/regex/libgnunetregex.la \
+  $(top_builddir)/src/util/libgnunetutil.la
 
 test_regex_iterate_api_SOURCES = \
- test_regex_iterate_api.c
+  test_regex_iterate_api.c
 test_regex_iterate_api_LDADD = \
- $(top_builddir)/src/regex/libgnunetregex.la \
- $(top_builddir)/src/util/libgnunetutil.la
+  $(top_builddir)/src/regex/libgnunetregex.la \
+  $(top_builddir)/src/util/libgnunetutil.la
 
 test_regex_proofs_SOURCES = \
- test_regex_proofs.c
+  test_regex_proofs.c
 test_regex_proofs_LDADD = \
- $(top_builddir)/src/regex/libgnunetregex.la \
- $(top_builddir)/src/util/libgnunetutil.la
+  $(top_builddir)/src/regex/libgnunetregex.la \
+  $(top_builddir)/src/util/libgnunetutil.la
 
 test_regex_graph_api_SOURCES = \
-test_regex_graph_api.c
+  test_regex_graph_api.c
 test_regex_graph_api_LDADD = \
-$(top_builddir)/src/regex/libgnunetregex.la \
-$(top_builddir)/src/util/libgnunetutil.la
+  $(top_builddir)/src/regex/libgnunetregex.la \
+  $(top_builddir)/src/util/libgnunetutil.la
 
-test_regex_big_SOURCES = \
-test_regex_big.c
-test_regex_big_LDADD = \
- $(top_builddir)/src/regex/libgnunetregex.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/testbed/libgnunettestbed.la
-
 test_regex_iptoregex_SOURCES = \
-test_regex_iptoregex.c
+  test_regex_iptoregex.c
 test_regex_iptoregex_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/regex/libgnunetregex.la
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/regex/libgnunetregex.la
 
 
-EXTRA_DIST =
-# test_regex_data.conf
+EXTRA_DIST = \
+  regex_profiler_test.conf

Added: gnunet/src/regex/gnunet-regex-profiler.c
===================================================================
--- gnunet/src/regex/gnunet-regex-profiler.c                            (rev 0)
+++ gnunet/src/regex/gnunet-regex-profiler.c    2012-10-15 17:06:17 UTC (rev 
24323)
@@ -0,0 +1,697 @@
+/*
+     This file is part of GNUnet.
+     (C) 2011, 2012 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/gnunet-regex-profiler.c
+ * @brief Stream API testing between 2 peers using testing API
+ * @author Bart Polot
+ * @author Max Szengel
+ */
+
+#include <string.h>
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_mesh_service.h"
+#include "gnunet_stream_lib.h"
+#include "gnunet_testbed_service.h"
+
+
+#define NUM_HOSTS 2
+
+#define PEER_PER_HOST 1
+
+#define TOTAL_PEERS (NUM_HOSTS * PEER_PER_HOST)
+
+/**
+ * Shorthand for Relative time in seconds
+ */
+#define TIME_REL_SECS(sec) \
+  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)
+
+/**
+ * Structure for holding peer's sockets and IO Handles
+ */
+struct PeerData
+{
+  /**
+   * Handle to testbed peer
+   */
+  struct GNUNET_TESTBED_Peer *peer;
+
+  /**
+   * Peer's stream socket
+   */
+  struct GNUNET_STREAM_Socket *socket;
+
+  /**
+   * Peer's io write handle
+   */
+  struct GNUNET_STREAM_IOWriteHandle *io_write_handle;
+
+  /**
+   * Peer's io read handle
+   */
+  struct GNUNET_STREAM_IOReadHandle *io_read_handle;
+
+  /**
+   * Peer's shutdown handle
+   */
+  struct GNUNET_STREAM_ShutdownHandle *shutdown_handle;
+
+  /**
+   * The service connect operation to stream
+   */
+  struct GNUNET_TESTBED_Operation *op;
+
+  /**
+   * Our Peer id
+   */
+  struct GNUNET_PeerIdentity our_id;
+
+  /**
+   * Bytes the peer has written
+   */
+  unsigned int bytes_wrote;
+
+  /**
+   * Byte the peer has read
+   */
+  unsigned int bytes_read;
+};
+
+
+/**
+ * Different states in test setup
+ */
+enum SetupState
+{
+  /**
+   * The initial state
+   */
+  INIT,
+
+  /**
+   * Connecting to slave controller
+   */
+  LINKING,
+
+  CREATING_PEER,
+
+  STARTING_PEER
+};
+
+
+/**
+ * Event Mask for operation callbacks
+ */
+uint64_t event_mask;
+
+/**
+ * Testbed operation handle
+ */
+static struct GNUNET_TESTBED_Operation *op[NUM_HOSTS];
+
+static enum SetupState state[NUM_HOSTS];
+
+static GNUNET_SCHEDULER_TaskIdentifier abort_task;
+
+/**
+ * Global test result
+ */
+static int result;
+
+/**
+ * Hosts successfully registered
+ */
+static unsigned int host_registered;
+
+/**
+ * Peers successfully started
+ */
+static unsigned int peers_started;
+
+/**
+ * The master controller host
+ */
+struct GNUNET_TESTBED_Host *master_host;
+
+/**
+ * The master controller process
+ */
+static struct GNUNET_TESTBED_ControllerProc *master_proc;
+
+/**
+ * Handle to master controller
+ */
+static struct GNUNET_TESTBED_Controller *master_ctrl;
+
+/**
+ * Slave host IP addresses
+ */
+
+static char *slave_ips[NUM_HOSTS] = { "192.168.1.33", "192.168.1.34" };
+
+/**
+ * The slave hosts
+ */
+struct GNUNET_TESTBED_Host *slave_hosts[NUM_HOSTS];
+
+/**
+ * Slave host registration handles
+ */
+static struct GNUNET_TESTBED_HostRegistrationHandle *rh;
+
+/**
+ * The peers
+ */
+struct GNUNET_TESTBED_Peer *peers[TOTAL_PEERS];
+
+/**
+ * Handle to global configuration
+ */
+static struct GNUNET_CONFIGURATION_Handle *cfg;
+
+
+/**
+ * Completion callback for shutdown
+ *
+ * @param cls the closure from GNUNET_STREAM_shutdown call
+ * @param operation the operation that was shutdown (SHUT_RD, SHUT_WR,
+ *          SHUT_RDWR)
+ */
+// static void
+// shutdown_completion (void *cls,
+//                      int operation)
+// {
+//   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STREAM shutdown successful\n");
+//   GNUNET_SCHEDULER_add_now (&do_close, cls);
+// }
+
+
+
+/**
+ * Shutdown sockets gracefully
+ */
+// static void
+// do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+// {
+//   result = GNUNET_OK;
+//   peer1.shutdown_handle = GNUNET_STREAM_shutdown (peer1.socket, SHUT_RDWR,
+//                                                   &shutdown_completion, 
cls);
+// }
+
+
+/**
+ * Something went wrong and timed out. Kill everything and set error flag
+ */
+static void
+do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: ABORT\n");
+  result = GNUNET_SYSERR;
+  abort_task = 0;
+}
+
+
+/**
+ * Adapter function called to destroy a connection to
+ * a service.
+ *
+ * @param cls closure
+ * @param op_result service handle returned from the connect adapter
+ */
+// static void
+// stream_da (void *cls, void *op_result)
+// {
+//   struct GNUNET_STREAM_ListenSocket *lsocket;
+//   struct GNUNET_STREAM_Socket *socket;
+//
+//   if (&peer1 == cls)
+//   {
+//     lsocket = op_result;
+//     GNUNET_STREAM_listen_close (lsocket);
+//     GNUNET_TESTBED_operation_done (peer2.op);
+//     return;
+//   }
+//   if (&peer2 == cls)
+//   {
+//     socket = op_result;
+//     GNUNET_STREAM_close (socket);
+//     GNUNET_SCHEDULER_shutdown (); /* Exit point of the test */
+//     return;
+//   }
+//   GNUNET_assert (0);
+// }
+
+
+/**
+ * Adapter function called to establish a connection to
+ * a service.
+ *
+ * @param cls closure
+ * @param cfg configuration of the peer to connect to; will be available until
+ *          GNUNET_TESTBED_operation_done() is called on the operation returned
+ *          from GNUNET_TESTBED_service_connect()
+ * @return service handle to return in 'op_result', NULL on error
+ */
+// static void *
+// stream_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
+// {
+//   struct GNUNET_STREAM_ListenSocket *lsocket;
+//
+//   switch (setup_state)
+//   {
+//   case PEER1_STREAM_CONNECT:
+//     lsocket = GNUNET_STREAM_listen (cfg, 10, &stream_listen_cb, NULL,
+//                                     
GNUNET_STREAM_OPTION_SIGNAL_LISTEN_SUCCESS,
+//                                     &stream_connect, 
GNUNET_STREAM_OPTION_END);
+//     return lsocket;
+//   case PEER2_STREAM_CONNECT:
+//     peer2.socket = GNUNET_STREAM_open (cfg, &peer1.our_id, 10, 
&stream_open_cb,
+//                                        &peer2, GNUNET_STREAM_OPTION_END);
+//     return peer2.socket;
+//   default:
+//     GNUNET_assert (0);
+//   }
+// }
+
+
+/**
+ * Listen success callback; connects a peer to stream as client
+ */
+// static void
+// stream_connect (void)
+// {
+//   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stream listen open successful\n");
+//   peer2.op = GNUNET_TESTBED_service_connect (&peer2, peer2.peer, "stream",
+//                                              NULL, NULL,
+//                                              stream_ca, stream_da, &peer2);
+//   setup_state = PEER2_STREAM_CONNECT;
+// }
+
+
+/**
+ * Callback to be called when the requested peer information is available
+ *
+ * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information()
+ * @param op the operation this callback corresponds to
+ * @param pinfo the result; will be NULL if the operation has failed
+ * @param emsg error message if the operation has failed; will be NULL if the
+ *          operation is successfull
+ */
+// static void
+// peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_,
+//              const struct GNUNET_TESTBED_PeerInformation *pinfo,
+//              const char *emsg)
+// {
+//   GNUNET_assert (NULL == emsg);
+//   GNUNET_assert (op == op_);
+//   switch (setup_state)
+//     {
+//     case PEER1_GET_IDENTITY:
+//       memcpy (&peer1.our_id, pinfo->result.id,
+//               sizeof (struct GNUNET_PeerIdentity));
+//       GNUNET_TESTBED_operation_done (op);
+//       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 id: %s\n", GNUNET_i2s
+//                   (&peer1.our_id));
+//       op = GNUNET_TESTBED_peer_get_information (peer2.peer,
+//                                                 GNUNET_TESTBED_PIT_IDENTITY,
+//                                                 &peerinfo_cb, NULL);
+//       setup_state = PEER2_GET_IDENTITY;
+//       break;
+//     case PEER2_GET_IDENTITY:
+//       memcpy (&peer2.our_id, pinfo->result.id,
+//               sizeof (struct GNUNET_PeerIdentity));
+//       GNUNET_TESTBED_operation_done (op);
+//       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 2 id: %s\n", GNUNET_i2s
+//                   (&peer2.our_id));
+//       peer1.op = GNUNET_TESTBED_service_connect (&peer1, peer1.peer, 
"stream",
+//                                                  NULL, NULL, stream_ca,
+//                                                  stream_da, &peer1);
+//       setup_state = PEER1_STREAM_CONNECT;
+//       break;
+//     default:
+//       GNUNET_assert (0);
+//     }
+// }
+
+
+/**
+ * Controller event callback
+ *
+ * @param cls NULL
+ * @param event the controller event
+ */
+// static void
+// controller_event_cb (void *cls,
+//                      const struct GNUNET_TESTBED_EventInformation *event)
+// {
+//   switch (event->type)
+//   {
+//   case GNUNET_TESTBED_ET_CONNECT:
+//     GNUNET_assert (INIT == setup_state);
+//     GNUNET_TESTBED_operation_done (op);
+//     /* Get the peer identity and configuration of peers */
+//     op = GNUNET_TESTBED_peer_get_information (peer1.peer,
+//                                               GNUNET_TESTBED_PIT_IDENTITY,
+//                                               &peerinfo_cb, NULL);
+//     setup_state = PEER1_GET_IDENTITY;
+//     break;
+//   case GNUNET_TESTBED_ET_OPERATION_FINISHED:
+//     switch (setup_state)
+//     {
+//     case PEER1_STREAM_CONNECT:
+//     case PEER2_STREAM_CONNECT:
+//       GNUNET_assert (NULL == event->details.operation_finished.emsg);
+//       break;
+//     default:
+//       GNUNET_assert (0);
+//     }
+//     break;
+//   default:
+//     GNUNET_assert (0);
+//   }
+// }
+
+
+/**
+ * Signature of a main function for a testcase.
+ *
+ * @param cls closure
+ * @param num_peers number of peers in 'peers'
+ * @param peers handle to peers run in the testbed
+ */
+// static void
+// test_master (void *cls, unsigned int num_peers,
+//              struct GNUNET_TESTBED_Peer **peers)
+// {
+//   GNUNET_assert (NULL != peers);
+//   GNUNET_assert (NULL != peers[0]);
+//   GNUNET_assert (NULL != peers[1]);
+//   peer1.peer = peers[0];
+//   peer2.peer = peers[1];
+//   op = GNUNET_TESTBED_overlay_connect (NULL, NULL, NULL, peer2.peer, 
peer1.peer);
+//   setup_state = INIT;
+//   abort_task =
+//     GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+//                                   (GNUNET_TIME_UNIT_SECONDS, 40), &do_abort,
+//                                   NULL);
+// }
+
+/**
+ * Functions of this signature are called when a peer has been successfully
+ * started or stopped.
+ *
+ * @param cls the closure from GNUNET_TESTBED_peer_start/stop()
+ * @param emsg NULL on success; otherwise an error description
+ */
+static void
+peer_start_cb (void *cls, const char *emsg)
+{
+  long i = (long) cls;
+
+  GNUNET_TESTBED_operation_done (op[i]);
+  peers_started++;
+  // FIXME create and start rest of PEERS_PER_HOST
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u peer(s) started\n", peers_started);
+
+  if (TOTAL_PEERS == peers_started)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ok\n");
+  }
+}
+
+
+/**
+ * Functions of this signature are called when a peer has been successfully
+ * created
+ *
+ * @param cls the closure from GNUNET_TESTBED_peer_create()
+ * @param peer the handle for the created peer; NULL on any error during
+ *          creation
+ * @param emsg NULL if peer is not NULL; else MAY contain the error description
+ */
+static void
+peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
+{
+  long i = (long) cls;
+  long peer_id;
+
+//   GNUNET_TESTBED_operation_done(op[i]);
+  peer_id = i;                  // FIXME  A * i + B
+  peers[peer_id] = peer;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer %i created\n", peer_id);
+  op[i] = GNUNET_TESTBED_peer_start (NULL, peer, peer_start_cb, (void *) i);
+}
+
+
+/**
+ * Signature of the event handler function called by the
+ * respective event controller.
+ *
+ * @param cls closure
+ * @param event information about the event
+ */
+static void
+controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
+{
+  long i;
+
+  switch (event->type)
+  {
+  case GNUNET_TESTBED_ET_PEER_START:
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer started\n");
+    /* event->details.peer_start.peer; */
+    /* event->details.peer_start.host; */
+
+    break;
+  case GNUNET_TESTBED_ET_PEER_STOP:
+  case GNUNET_TESTBED_ET_CONNECT:
+    break;
+  case GNUNET_TESTBED_ET_OPERATION_FINISHED:
+    if (NULL != event->details.operation_finished.emsg)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Testbed error: %s\n",
+                  event->details.operation_finished.emsg);
+      GNUNET_assert (0);
+    }
+    GNUNET_TESTBED_operation_done 
(event->details.operation_finished.operation);
+    //GNUNET_assert (NULL != event->details.operation_finished.op_cls);
+    i = (long) event->details.operation_finished.op_cls;
+    op[i] = NULL;
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "  Operation %u finished\n", i);
+    switch (state[i])
+    {
+    case INIT:
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "  Init: %u\n", i);
+      break;
+    case LINKING:
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "   Linked host %i\n", i);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "   Creating peer...\n");
+
+      state[i] = CREATING_PEER;
+      op[i] =
+          GNUNET_TESTBED_peer_create (master_ctrl, slave_hosts[i], cfg,
+                                      peer_create_cb, (void *) i);
+      break;
+    case CREATING_PEER:
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "  Peer create\n");
+      break;
+    default:
+      GNUNET_break (0);
+    }
+    break;
+  default:
+    GNUNET_break (0);
+  }
+}
+
+/**
+ * Callback which will be called to after a host registration succeeded or 
failed
+ *
+ * @param cls the host which has been registered
+ * @param emsg the error message; NULL if host registration is successful
+ */
+static void
+registration_cont (void *cls, const char *emsg)
+{
+  if (NULL != emsg)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
+    GNUNET_assert (0);
+  }
+  state[host_registered] = LINKING;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linking host %u\n", host_registered);
+  op[host_registered] =
+      GNUNET_TESTBED_controller_link ((void *) (long) host_registered,
+                                      master_ctrl, 
slave_hosts[host_registered],
+                                      NULL, cfg, GNUNET_YES);
+  host_registered++;
+  if (NUM_HOSTS != host_registered)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Registering host %u\n",
+                host_registered);
+    rh = GNUNET_TESTBED_register_host (master_ctrl,
+                                       slave_hosts[host_registered],
+                                       &registration_cont, NULL);
+    return;
+  }
+}
+
+/**
+ * Callback to signal successfull startup of the controller process
+ *
+ * @param cls the closure from GNUNET_TESTBED_controller_start()
+ * @param cfg the configuration with which the controller has been started;
+ *          NULL if status is not GNUNET_OK
+ * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not,
+ *          GNUNET_TESTBED_controller_stop() shouldn't be called in this case
+ */
+static void
+status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
+           int status)
+{
+  unsigned int i;
+
+  if (NULL == config || GNUNET_OK != status)
+    return;
+
+  event_mask = 0;
+  event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START);
+  event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP);
+  event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT);
+  event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to master controller\n");
+  master_ctrl =
+      GNUNET_TESTBED_controller_connect (config, master_host, event_mask,
+                                         &controller_cb, NULL);
+  GNUNET_assert (NULL != master_ctrl);
+
+  for (i = 0; i < NUM_HOSTS; i++)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Creating host %u\n", i);
+    slave_hosts[i] = GNUNET_TESTBED_host_create (slave_ips[i], NULL, 0);
+    GNUNET_assert (NULL != slave_hosts[i]);
+  }
+  host_registered = 0;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Registering host %u\n",
+              host_registered);
+  rh = GNUNET_TESTBED_register_host (master_ctrl, slave_hosts[0],
+                                     &registration_cont, NULL);
+  GNUNET_assert (NULL != rh);
+}
+
+
+/**
+ * Main run function.
+ *
+ * @param cls NULL
+ * @param args arguments passed to GNUNET_PROGRAM_run
+ * @param cfgfile the path to configuration file
+ * @param cfg the configuration file handle
+ */
+static void
+run (void *cls, char *const *args, const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *config)
+{
+  master_host = GNUNET_TESTBED_host_create ("192.168.1.33", NULL, 0);
+  GNUNET_assert (NULL != master_host);
+  cfg = GNUNET_CONFIGURATION_dup (config);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting master controller\n");
+  master_proc =
+      GNUNET_TESTBED_controller_start ("192.168.1.33", master_host, cfg,
+                                       status_cb, NULL);
+  abort_task =
+      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+                                    (GNUNET_TIME_UNIT_MINUTES, 60), &do_abort,
+                                    NULL);
+}
+
+/**
+ * Main function
+ */
+int
+main (int argc, char **argv)
+{
+  int ret;
+  int test_hosts;
+  unsigned int i;
+
+  struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_OPTION_END
+  };
+  char *const argv2[] = { "gnunet-regex-profiler",
+    "-c", "regex_profiler_test.conf",
+    NULL
+  };
+
+  test_hosts = GNUNET_OK;
+  for (i = 0; i < NUM_HOSTS; i++)
+  {
+    char *const remote_args[] = {
+      "ssh", "-o", "BatchMode=yes", slave_ips[i],
+      "gnunet-helper-testbed --help > /dev/null", NULL
+    };
+    struct GNUNET_OS_Process *auxp;
+    enum GNUNET_OS_ProcessStatusType type;
+    unsigned long code;
+
+    fprintf (stderr, "Testing host %i\n", i);
+    auxp =
+        GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, 
NULL,
+                                     NULL, "ssh", remote_args);
+    GNUNET_assert (NULL != auxp);
+    do
+    {
+      ret = GNUNET_OS_process_status (auxp, &type, &code);
+      GNUNET_assert (GNUNET_SYSERR != ret);
+      (void) usleep (300);
+    }
+    while (GNUNET_NO == ret);
+    (void) GNUNET_OS_process_wait (auxp);
+    GNUNET_OS_process_destroy (auxp);
+    if (0 != code)
+    {
+      fprintf (stderr,
+               "Unable to run the test as this system is not configured "
+               "to use password less SSH logins to host %s.\n", slave_ips[i]);
+      test_hosts = GNUNET_SYSERR;
+    }
+  }
+  if (test_hosts != GNUNET_OK)
+  {
+    fprintf (stderr, "Some hosts have failed the ssh check. Exiting.\n");
+    return 1;
+  }
+  fprintf (stderr, "START.\n");
+
+  result = GNUNET_SYSERR;
+
+  ret =
+      GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
+                          "test_regex_big", "nohelp", options, &run, NULL);
+
+  fprintf (stderr, "END.\n");
+
+  if (GNUNET_SYSERR == result || GNUNET_OK != ret)
+    return 1;
+  return 0;
+}

Modified: gnunet/src/regex/regex.c
===================================================================
--- gnunet/src/regex/regex.c    2012-10-15 16:17:25 UTC (rev 24322)
+++ gnunet/src/regex/regex.c    2012-10-15 17:06:17 UTC (rev 24323)
@@ -30,12 +30,6 @@
 
 
 /**
- * Constant for how many bits the initial string regex should have.
- */
-#define INITIAL_BITS 8
-
-
-/**
  * Set of states.
  */
 struct GNUNET_REGEX_StateSet
@@ -148,6 +142,7 @@
   state->transition_count--;
   GNUNET_CONTAINER_DLL_remove (state->transitions_head, 
state->transitions_tail,
                                transition);
+
   GNUNET_free (transition);
 }
 
@@ -526,29 +521,6 @@
 
 
 /**
- * Context for adding strided transitions to a DFA.
- */
-struct GNUNET_REGEX_Strided_Context
-{
-  /**
-   * Length of the strides.
-   */
-  const unsigned int stride;
-
-  /**
-   * Strided transitions DLL. New strided transitions will be stored in this 
DLL
-   * and afterwards added to the DFA.
-   */
-  struct GNUNET_REGEX_Transition *transitions_head;
-
-  /**
-   * Strided transitions DLL.
-   */
-  struct GNUNET_REGEX_Transition *transitions_tail;
-};
-
-
-/**
  * Check if the given string 'str' needs parentheses around it when
  * using it to generate a regex.
  *
@@ -1555,6 +1527,29 @@
 
 
 /**
+ * Context for adding strided transitions to a DFA.
+ */
+struct GNUNET_REGEX_Strided_Context
+{
+  /**
+   * Length of the strides.
+   */
+  const unsigned int stride;
+
+  /**
+   * Strided transitions DLL. New strided transitions will be stored in this 
DLL
+   * and afterwards added to the DFA.
+   */
+  struct GNUNET_REGEX_Transition *transitions_head;
+
+  /**
+   * Strided transitions DLL.
+   */
+  struct GNUNET_REGEX_Transition *transitions_tail;
+};
+
+
+/**
  * Recursive helper function to add strides to a DFA.
  *
  * @param cls context, contains stride length and strided transitions DLL.
@@ -1664,15 +1659,19 @@
  * and adds new transitions to the given transitions DLL and marks states that
  * should be removed by setting state->contained to GNUNET_YES.
  *
+ * @param dfa DFA for which the paths should be compressed.
  * @param start starting state for linear path search.
  * @param cur current state in the recursive DFS.
  * @param label current label (string of traversed labels).
+ * @param max_len maximal path compression length.
  * @param transitions_head transitions DLL.
  * @param transitions_tail transitions DLL.
  */
 void
-dfa_compress_paths_helper (struct GNUNET_REGEX_State *start,
+dfa_compress_paths_helper (struct GNUNET_REGEX_Automaton *dfa,
+                           struct GNUNET_REGEX_State *start,
                            struct GNUNET_REGEX_State *cur, char *label,
+                           unsigned int max_len,
                            struct GNUNET_REGEX_Transition **transitions_head,
                            struct GNUNET_REGEX_Transition **transitions_tail)
 {
@@ -1681,8 +1680,11 @@
 
 
   if (NULL != label &&
-      (cur->incoming_transition_count > 1 || GNUNET_YES == cur->accepting ||
-       cur->transition_count > 1 || GNUNET_YES == cur->marked))
+      ((cur->incoming_transition_count > 1 || GNUNET_YES == cur->accepting
+//        || cur->transition_count > 1
+        || GNUNET_YES == cur->marked) || (start != dfa->start && max_len > 0 &&
+                                          max_len == strlen (label)) ||
+       (start == dfa->start && GNUNET_REGEX_INITIAL_BITS == strlen (label))))
   {
     t = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Transition));
     t->label = GNUNET_strdup (label);
@@ -1692,7 +1694,7 @@
 
     if (GNUNET_NO == cur->marked)
     {
-      dfa_compress_paths_helper (cur, cur, NULL, transitions_head,
+      dfa_compress_paths_helper (dfa, cur, cur, NULL, max_len, 
transitions_head,
                                  transitions_tail);
     }
     return;
@@ -1715,7 +1717,7 @@
 
     if (t->to_state != cur)
     {
-      dfa_compress_paths_helper (start, t->to_state, new_label,
+      dfa_compress_paths_helper (dfa, start, t->to_state, new_label, max_len,
                                  transitions_head, transitions_tail);
     }
     GNUNET_free (new_label);
@@ -1728,10 +1730,11 @@
  *
  * @param regex_ctx context for adding new transitions.
  * @param dfa DFA representation, will directly modify the given DFA.
+ * @param max_len maximal length of the compressed paths.
  */
 static void
 dfa_compress_paths (struct GNUNET_REGEX_Context *regex_ctx,
-                    struct GNUNET_REGEX_Automaton *dfa)
+                    struct GNUNET_REGEX_Automaton *dfa, unsigned int max_len)
 {
   struct GNUNET_REGEX_State *s;
   struct GNUNET_REGEX_State *s_next;
@@ -1761,8 +1764,8 @@
   }
 
   // Add strides and mark states that can be deleted.
-  dfa_compress_paths_helper (dfa->start, dfa->start, NULL, &transitions_head,
-                             &transitions_tail);
+  dfa_compress_paths_helper (dfa, dfa->start, dfa->start, NULL, max_len,
+                             &transitions_head, &transitions_tail);
 
   // Add all the new transitions to the automaton.
   for (t = transitions_head; NULL != t; t = t_next)
@@ -2101,6 +2104,14 @@
   struct GNUNET_REGEX_Automaton *a;
 
   a = ctx->stack_tail;
+
+  if (NULL == a)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "nfa_add_plus_op failed, because there was no element on the 
stack");
+    return;
+  }
+
   GNUNET_CONTAINER_DLL_remove (ctx->stack_head, ctx->stack_tail, a);
 
   state_add_transition (ctx, a->end, NULL, a->start);
@@ -2518,12 +2529,12 @@
   // Minimize DFA
   dfa_minimize (&ctx, dfa);
 
-  // Compress DFA paths
-  dfa_compress_paths (&ctx, dfa);
-
   // Create proofs for all states
   automaton_create_proofs (dfa);
 
+  // Compress DFA paths
+  dfa_compress_paths (&ctx, dfa, 8);
+
   // Add strides to DFA
   //GNUNET_REGEX_dfa_add_multi_strides (&ctx, dfa, 2);
 
@@ -2730,10 +2741,9 @@
   if (NULL == a)
     return 0;
 
-  for (t_count = 0, s = a->states_head; NULL != s; s = s->next)
-  {
+  t_count = 0;
+  for (s = a->states_head; NULL != s; s = s->next)
     t_count += s->transition_count;
-  }
 
   return t_count;
 }
@@ -2756,7 +2766,9 @@
 {
   unsigned int size;
 
-  size = string_len < INITIAL_BITS ? string_len : INITIAL_BITS;
+  size =
+      string_len <
+      GNUNET_REGEX_INITIAL_BITS ? string_len : GNUNET_REGEX_INITIAL_BITS;
 
   if (NULL == input_string)
   {
@@ -2796,8 +2808,7 @@
 
 
 /**
- * Recursive helper function for iterate_initial_edges. Will call iterator
- * function for each initial state.
+ * Recursive function that calls the iterator for each synthetic start state.
  *
  * @param min_len minimum length of the path in the graph.
  * @param max_len maximum length of the path in the graph.
@@ -2831,22 +2842,24 @@
   {
     if (cur_len <= max_len)
     {
-      for (i = 0, t = state->transitions_head; NULL != t && i < num_edges;
-           t = t->next, i++)
+      if (state->proof != NULL && 0 != strcmp (consumed_string, state->proof))
       {
-        edges[i].label = t->label;
-        edges[i].destination = t->to_state->hash;
+        for (i = 0, t = state->transitions_head; NULL != t && i < num_edges;
+             t = t->next, i++)
+        {
+          edges[i].label = t->label;
+          edges[i].destination = t->to_state->hash;
+        }
+        GNUNET_CRYPTO_hash (consumed_string, strlen (consumed_string), &hash);
+        iterator (iterator_cls, &hash, consumed_string, state->accepting,
+                  num_edges, edges);
       }
 
-      GNUNET_CRYPTO_hash (consumed_string, strlen (consumed_string), &hash);
-      iterator (iterator_cls, &hash, consumed_string, state->accepting,
-                num_edges, edges);
-
-      // Special case for regex consisting of just a string that is shorter 
than
-      // max_len
       if (GNUNET_YES == state->accepting && cur_len > 1 &&
           state->transition_count < 1 && cur_len < max_len)
       {
+        // Special case for regex consisting of just a string that is shorter 
than
+        // max_len
         edge[0].label = &consumed_string[cur_len - 1];
         edge[0].destination = state->hash;
         temp = GNUNET_strdup (consumed_string);
@@ -2858,6 +2871,7 @@
     }
     else if (max_len < cur_len)
     {
+      // Case where the concatenated labels are longer than max_len, then 
split.
       edge[0].label = &consumed_string[max_len];
       edge[0].destination = state->hash;
       temp = GNUNET_strdup (consumed_string);
@@ -2886,38 +2900,6 @@
 
 
 /**
- * Iterate over all edges helper function starting from state 's', calling
- * iterator function for each edge if the automaton.
- *
- * @param s state.
- * @param iterator iterator function called for each edge.
- * @param iterator_cls closure.
- */
-static void
-iterate_edge (struct GNUNET_REGEX_State *s, GNUNET_REGEX_KeyIterator iterator,
-              void *iterator_cls)
-{
-  struct GNUNET_REGEX_Transition *t;
-  struct GNUNET_REGEX_Edge edges[s->transition_count];
-  unsigned int num_edges;
-
-  if (GNUNET_YES != s->marked)
-  {
-    s->marked = GNUNET_YES;
-
-    num_edges = state_get_edges (s, edges);
-
-    if ((NULL != s->proof && 0 < strlen (s->proof)) || s->accepting)
-      iterator (iterator_cls, &s->hash, s->proof, s->accepting, num_edges,
-                edges);
-
-    for (t = s->transitions_head; NULL != t; t = t->next)
-      iterate_edge (t->to_state, iterator, iterator_cls);
-  }
-}
-
-
-/**
  * Iterate over all edges starting from start state of automaton 'a'. Calling
  * iterator for each edge.
  *
@@ -2933,11 +2915,21 @@
   struct GNUNET_REGEX_State *s;
 
   for (s = a->states_head; NULL != s; s = s->next)
+  {
+    struct GNUNET_REGEX_Edge edges[s->transition_count];
+    unsigned int num_edges;
+
+    num_edges = state_get_edges (s, edges);
+
+    if ((NULL != s->proof && 0 < strlen (s->proof)) || s->accepting)
+      iterator (iterator_cls, &s->hash, s->proof, s->accepting, num_edges,
+                edges);
+
     s->marked = GNUNET_NO;
+  }
 
-  iterate_initial_edge (0, INITIAL_BITS, NULL, a->start, iterator,
-                        iterator_cls);
-  iterate_edge (a->start, iterator, iterator_cls);
+  iterate_initial_edge (GNUNET_REGEX_INITIAL_BITS, GNUNET_REGEX_INITIAL_BITS,
+                        NULL, a->start, iterator, iterator_cls);
 }
 
 

Modified: gnunet/src/regex/regex_internal.h
===================================================================
--- gnunet/src/regex/regex_internal.h   2012-10-15 16:17:25 UTC (rev 24322)
+++ gnunet/src/regex/regex_internal.h   2012-10-15 17:06:17 UTC (rev 24323)
@@ -142,7 +142,7 @@
   int lowlink;
 
   /**
-   * Human readable name of the automaton. Used for debugging and graph
+   * Human readable name of the state. Used for debugging and graph
    * creation.
    */
   char *name;

Added: gnunet/src/regex/regex_profiler_test.conf
===================================================================
--- gnunet/src/regex/regex_profiler_test.conf                           (rev 0)
+++ gnunet/src/regex/regex_profiler_test.conf   2012-10-15 17:06:17 UTC (rev 
24323)
@@ -0,0 +1,87 @@
+[lockmanager]
+AUTOSTART = NO
+ACCEPT_FROM = 127.0.0.1;
+HOSTNAME = localhost
+PORT = 12101
+
+[fs]
+AUTOSTART = NO
+
+[resolver]
+AUTOSTART = NO
+
+[mesh]
+AUTOSTART = YES
+ACCEPT_FROM = 127.0.0.1;
+HOSTNAME = localhost
+PORT = 10700
+# PREFIX = valgrind --leak-check=full
+# PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
+
+[dht]
+DEBUG = NO
+AUTOSTART = YES
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+HOSTNAME = localhost
+PORT = 12100
+
+[block]
+plugins = dht test
+
+[dhtcache]
+QUOTA = 1 MB
+DATABASE = sqlite
+
+[transport]
+PLUGINS = tcp
+DEBUG = NO
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+NEIGHBOUR_LIMIT = 50
+PORT = 12365
+
+[ats]
+WAN_QUOTA_OUT = 3932160
+WAN_QUOTA_IN = 3932160
+
+[core]
+PORT = 12092
+
+[arm]
+DEFAULTSERVICES = core lockmanager statistics
+PORT = 12366
+DEBUG = NO
+
+[transport-tcp]
+TIMEOUT = 300 s
+PORT = 12368
+
+[TESTING]
+WEAKRANDOM = YES
+
+[testing_old]
+NUM_PEERS = 5
+DEBUG = YES
+HOSTKEYSFILE = ${DATADIR}/testing_hostkeys.dat
+MAX_CONCURRENT_SSH = 10
+USE_PROGRESSBARS = YES
+PEERGROUP_TIMEOUT = 2400 s
+
+[gnunetd]
+HOSTKEY = $SERVICEHOME/.hostkey
+
+[PATHS]
+SERVICEHOME = /tmp/test-stream/
+
+[dns]
+AUTOSTART = NO
+
+[nse]
+AUTOSTART = NO
+
+[vpn]
+AUTOSTART = NO
+
+[testbed]
+PORT = 12099

Modified: gnunet/src/regex/test_regex_graph_api.c
===================================================================
--- gnunet/src/regex/test_regex_graph_api.c     2012-10-15 16:17:25 UTC (rev 
24322)
+++ gnunet/src/regex/test_regex_graph_api.c     2012-10-15 17:06:17 UTC (rev 
24323)
@@ -86,7 +86,7 @@
 
   error = 0;
 
-  const char *regex[10] = {
+  const char *regex[12] = {
     "ab(c|d)+c*(a(b|c)+d)+(bla)+",
     "(bla)*",
     "b(lab)*la",
@@ -96,10 +96,13 @@
     "1*0(0|1)*",
     "a*b*",
     "a+X*y+c|p|R|Z*K*y*R+w|Y*6+n+h*k*w+V*F|W*B*e*",
-    "a"
+    "a",
+    "a|b",
+//    "abc(d+|e)fgh"
+    
"PADPADPADPADPADPabcdefghixxxxxxxxxxxxxjklmnop*qstoisdjfguisdfguihsdfgbdsuivggsd"
   };
 
-  for (i = 0; i < 10; i++)
+  for (i = 0; i < 12; i++)
   {
     // Check NFA graph creation
     a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i]));
@@ -152,10 +155,9 @@
 
 
     a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]));
-    GNUNET_REGEX_automaton_save_graph (a, filename,
-                                       GNUNET_REGEX_GRAPH_DEFAULT |
-                                       GNUNET_REGEX_GRAPH_VERBOSE |
-                                       GNUNET_REGEX_GRAPH_COLORING);
+    GNUNET_REGEX_automaton_save_graph (a, filename, 
GNUNET_REGEX_GRAPH_DEFAULT);        //|
+    //                               GNUNET_REGEX_GRAPH_VERBOSE |
+    //GNUNET_REGEX_GRAPH_COLORING);
     GNUNET_REGEX_automaton_destroy (a);
     error += filecheck (filename);
 

Modified: gnunet/src/regex/test_regex_iptoregex.c
===================================================================
--- gnunet/src/regex/test_regex_iptoregex.c     2012-10-15 16:17:25 UTC (rev 
24322)
+++ gnunet/src/regex/test_regex_iptoregex.c     2012-10-15 17:06:17 UTC (rev 
24323)
@@ -77,9 +77,10 @@
                       "1111111111111111(0|1)+");
 
   error +=
-    test_iptoregex ("187.238.225.0", "255.255.255.128",
-                    "1011101111101110111000010(0|1)+", "E1E1:73F9:51BE::0", 49,
-                    "1110000111100001011100111111100101010001101111100(0|1)+");
+      test_iptoregex ("187.238.225.0", "255.255.255.128",
+                      "1011101111101110111000010(0|1)+", "E1E1:73F9:51BE::0",
+                      49,
+                      
"1110000111100001011100111111100101010001101111100(0|1)+");
 
   error +=
       test_iptoregex ("255.255.255.255", "255.255.255.255",

Modified: gnunet/src/regex/test_regex_iterate_api.c
===================================================================
--- gnunet/src/regex/test_regex_iterate_api.c   2012-10-15 16:17:25 UTC (rev 
24322)
+++ gnunet/src/regex/test_regex_iterate_api.c   2012-10-15 17:06:17 UTC (rev 
24323)
@@ -28,6 +28,7 @@
 #include "gnunet_regex_lib.h"
 #include "regex_internal.h"
 
+#define INITIAL_PADDING "PADPADPADPADPADP"
 #define GNUNET_REGEX_ITERATE_SAVE_DEBUG_GRAPH GNUNET_NO
 
 static unsigned int transition_counter;
@@ -115,30 +116,41 @@
 
   error = 0;
 
-  const struct RegexStringPair rxstr[14] = {
-    {"ab(c|d)+c*(a(b|c)+d)+(bla)+", 2, {"abcdcdca", "abcabdbl"}},
-    {"abcdefghijklmnop*qst", 1, {"abcdefgh"}},
-    {"VPN-4-1(0|1)*", 2, {"VPN-4-10", "VPN-4-11"}},
-    {"a+X*y+c|p|R|Z*K*y*R+w|Y*6+n+h*k*w+V*F|W*B*e*", 4,
-     {"aaaaaaaa", "aaXXyyyc", "p", "Y"}},
-    {"a*", 8,
-     {"a", "aa", "aaa", "aaaa", "aaaaa", "aaaaaa", "aaaaaaa", "aaaaaaaa"}},
-    {"xzxzxzxzxz", 1, {"xzxzxzxz"}},
-    {"xyz*", 2, {"xy", "xyz"}},
-    {"ab", 1, {"a"}},
-    
{"abcd:(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1):(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)",
 2, {"abcd:000", "abcd:101"}},
-    {"x*|(0|1|2)(a|b|c|d)", 2, {"xxxxxxxx", "0a"}},
-    {"(0|1)(0|1)23456789ABC", 1, {"11234567"}},
-    {"0*123456789ABC*", 3, {"00123456", "00000000", "12345678"}},
-    {"0123456789A*BC", 1, {"01234567"}},
-    {"GNUNETVPN000100000IPEX6-fc5a:4e1:c2ba::1", 1, {"GNUNETVP"}}
+  const struct RegexStringPair rxstr[13] = {
+    {INITIAL_PADDING "ab(c|d)+c*(a(b|c)+d)+(bla)+", 2,
+     {INITIAL_PADDING "abcdcdca", INITIAL_PADDING "abcabdbl"}},
+    {INITIAL_PADDING
+     "abcdefghixxxxxxxxxxxxxjklmnop*qstoisdjfguisdfguihsdfgbdsuivggsd", 1,
+     {INITIAL_PADDING "abcdefgh"}},
+    {INITIAL_PADDING "VPN-4-1(0|1)*", 2,
+     {INITIAL_PADDING "VPN-4-10", INITIAL_PADDING "VPN-4-11"}},
+    {INITIAL_PADDING "(a+X*y+c|p|R|Z*K*y*R+w|Y*6+n+h*k*w+V*F|W*B*e*)", 2,
+     {INITIAL_PADDING "aaaaaaaa", INITIAL_PADDING "aaXXyyyc"}},
+    {INITIAL_PADDING "a*", 1, {INITIAL_PADDING "aaaaaaaa"}},
+    {INITIAL_PADDING "xzxzxzxzxz", 1, {INITIAL_PADDING "xzxzxzxz"}},
+    {INITIAL_PADDING "xyz*", 1, {INITIAL_PADDING "xyzzzzzz"}},
+    {INITIAL_PADDING
+     
"abcd:(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1):(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)(0|1)",
+     2, {INITIAL_PADDING "abcd:000", INITIAL_PADDING "abcd:101"}},
+    {INITIAL_PADDING "(x*|(0|1|2)(a|b|c|d)+)", 2,
+     {INITIAL_PADDING "xxxxxxxx", INITIAL_PADDING "0abcdbad"}},
+    {INITIAL_PADDING "(0|1)(0|1)23456789ABC", 1, {INITIAL_PADDING "11234567"}},
+    {INITIAL_PADDING "0*123456789ABC*", 3,
+     {INITIAL_PADDING "00123456", INITIAL_PADDING "00000000",
+      INITIAL_PADDING "12345678"}},
+    {INITIAL_PADDING "0123456789A*BC", 1, {INITIAL_PADDING "01234567"}},
+    {"GNUNETVPN000100000IPEX6-fc5a:4e1:c2ba::1", 1, 
{"GNUNETVPN000100000IPEX6-"}}
   };
 
   const char *graph_start_str = "digraph G {\nrankdir=LR\n";
   const char *graph_end_str = "\n}\n";
 
-  for (i = 0; i < 14; i++)
+  for (i = 0; i < 13; i++)
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iterating DFA for regex %s\n",
+                rxstr[i].regex);
+
+
     // Create graph
     if (GNUNET_YES == GNUNET_REGEX_ITERATE_SAVE_DEBUG_GRAPH)
     {
@@ -171,7 +183,8 @@
     ctx.match_count = 0;
     dfa = GNUNET_REGEX_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex));
     GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &ctx);
-    num_transitions = GNUNET_REGEX_get_transition_count (dfa);
+    num_transitions =
+        GNUNET_REGEX_get_transition_count (dfa) - dfa->start->transition_count;
 
     if (transition_counter < num_transitions)
     {
@@ -179,7 +192,6 @@
                   "Automaton has %d transitions, iterated over %d 
transitions\n",
                   num_transitions, transition_counter);
       error += 1;
-      break;
     }
 
     if (ctx.match_count < ctx.string_count)
@@ -209,7 +221,7 @@
   }
 
 
-  for (i = 0; i < 10; i++)
+  for (i = 0; i < 13; i++)
   {
     ctx.string_count = rxstr[i].string_count;
     ctx.strings = rxstr[i].strings;




reply via email to

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