aboutsummaryrefslogtreecommitdiff
path: root/src/regex
diff options
context:
space:
mode:
authorMaximilian Szengel <gnunet@maxsz.de>2012-10-15 17:06:17 +0000
committerMaximilian Szengel <gnunet@maxsz.de>2012-10-15 17:06:17 +0000
commit0cbfe4d4b98355087c387124e6b852d06093a26e (patch)
tree8940b0c23afcc8138b0d13279f775fca6036f3cc /src/regex
parent745f5b00bd774fc723b644ccbea4284f5ac00771 (diff)
downloadgnunet-0cbfe4d4b98355087c387124e6b852d06093a26e.tar.gz
gnunet-0cbfe4d4b98355087c387124e6b852d06093a26e.zip
renamed test_regex_big / fixes
Diffstat (limited to 'src/regex')
-rw-r--r--src/regex/Makefile.am77
-rw-r--r--src/regex/gnunet-regex-profiler.c697
-rw-r--r--src/regex/regex.c174
-rw-r--r--src/regex/regex_internal.h2
-rw-r--r--src/regex/regex_profiler_test.conf87
-rw-r--r--src/regex/test_regex_graph_api.c16
-rw-r--r--src/regex/test_regex_iptoregex.c7
-rw-r--r--src/regex/test_regex_iterate_api.c54
8 files changed, 952 insertions, 162 deletions
diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am
index 2919e4da9..9824db522 100644
--- a/src/regex/Makefile.am
+++ b/src/regex/Makefile.am
@@ -14,65 +14,64 @@ libgnunetregex_la_SOURCES = \
14 regex_internal.h regex.c \ 14 regex_internal.h regex.c \
15 regex_graph.c regex_random.c 15 regex_graph.c regex_random.c
16libgnunetregex_la_LIBADD = -lm \ 16libgnunetregex_la_LIBADD = -lm \
17 $(top_builddir)/src/util/libgnunetutil.la 17 $(top_builddir)/src/util/libgnunetutil.la
18libgnunetregex_la_LDFLAGS = \ 18libgnunetregex_la_LDFLAGS = \
19 $(GN_LIB_LDFLAGS) \ 19 $(GN_LIB_LDFLAGS) \
20 -version-info 0:0:0 20 -version-info 0:0:0
21 21
22check_PROGRAMS = \ 22noinst_PROGRAMS = \
23 test_regex_eval_api \ 23 gnunet-regex-profiler
24 test_regex_iterate_api \ 24
25 test_regex_proofs \ 25gnunet_regex_profiler_SOURCES = \
26 test_regex_graph_api \ 26 gnunet-regex-profiler.c
27 test_regex_iptoregex \ 27gnunet_regex_profiler_LDADD = \
28 test_regex_big 28 $(top_builddir)/src/regex/libgnunetregex.la \
29 $(top_builddir)/src/util/libgnunetutil.la \
30 $(top_builddir)/src/testbed/libgnunettestbed.la
31gnunet_regex_profiler_DEPENDENCIES = \
32 libgnunetregex.la
29 33
34check_PROGRAMS = \
35 test_regex_eval_api \
36 test_regex_iterate_api \
37 test_regex_proofs \
38 test_regex_graph_api \
39 test_regex_iptoregex
30 40
31if ENABLE_TEST_RUN 41if ENABLE_TEST_RUN
32TESTS = \ 42 TESTS = $(check_PROGRAMS)
33 test_regex_eval_api \
34 test_regex_iterate_api \
35 test_regex_proofs \
36 test_regex_graph_api
37endif 43endif
38 44
39test_regex_eval_api_SOURCES = \ 45test_regex_eval_api_SOURCES = \
40 test_regex_eval_api.c 46 test_regex_eval_api.c
41test_regex_eval_api_LDADD = \ 47test_regex_eval_api_LDADD = \
42 $(top_builddir)/src/regex/libgnunetregex.la \ 48 $(top_builddir)/src/regex/libgnunetregex.la \
43 $(top_builddir)/src/util/libgnunetutil.la 49 $(top_builddir)/src/util/libgnunetutil.la
44 50
45test_regex_iterate_api_SOURCES = \ 51test_regex_iterate_api_SOURCES = \
46 test_regex_iterate_api.c 52 test_regex_iterate_api.c
47test_regex_iterate_api_LDADD = \ 53test_regex_iterate_api_LDADD = \
48 $(top_builddir)/src/regex/libgnunetregex.la \ 54 $(top_builddir)/src/regex/libgnunetregex.la \
49 $(top_builddir)/src/util/libgnunetutil.la 55 $(top_builddir)/src/util/libgnunetutil.la
50 56
51test_regex_proofs_SOURCES = \ 57test_regex_proofs_SOURCES = \
52 test_regex_proofs.c 58 test_regex_proofs.c
53test_regex_proofs_LDADD = \ 59test_regex_proofs_LDADD = \
54 $(top_builddir)/src/regex/libgnunetregex.la \ 60 $(top_builddir)/src/regex/libgnunetregex.la \
55 $(top_builddir)/src/util/libgnunetutil.la 61 $(top_builddir)/src/util/libgnunetutil.la
56 62
57test_regex_graph_api_SOURCES = \ 63test_regex_graph_api_SOURCES = \
58test_regex_graph_api.c 64 test_regex_graph_api.c
59test_regex_graph_api_LDADD = \ 65test_regex_graph_api_LDADD = \
60$(top_builddir)/src/regex/libgnunetregex.la \ 66 $(top_builddir)/src/regex/libgnunetregex.la \
61$(top_builddir)/src/util/libgnunetutil.la 67 $(top_builddir)/src/util/libgnunetutil.la
62
63test_regex_big_SOURCES = \
64test_regex_big.c
65test_regex_big_LDADD = \
66 $(top_builddir)/src/regex/libgnunetregex.la \
67 $(top_builddir)/src/util/libgnunetutil.la \
68 $(top_builddir)/src/testbed/libgnunettestbed.la
69 68
70test_regex_iptoregex_SOURCES = \ 69test_regex_iptoregex_SOURCES = \
71test_regex_iptoregex.c 70 test_regex_iptoregex.c
72test_regex_iptoregex_LDADD = \ 71test_regex_iptoregex_LDADD = \
73 $(top_builddir)/src/util/libgnunetutil.la \ 72 $(top_builddir)/src/util/libgnunetutil.la \
74 $(top_builddir)/src/regex/libgnunetregex.la 73 $(top_builddir)/src/regex/libgnunetregex.la
75 74
76 75
77EXTRA_DIST = 76EXTRA_DIST = \
78# test_regex_data.conf 77 regex_profiler_test.conf
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c
new file mode 100644
index 000000000..fea2886a2
--- /dev/null
+++ b/src/regex/gnunet-regex-profiler.c
@@ -0,0 +1,697 @@
1/*
2 This file is part of GNUnet.
3 (C) 2011, 2012 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file regex/gnunet-regex-profiler.c
23 * @brief Stream API testing between 2 peers using testing API
24 * @author Bart Polot
25 * @author Max Szengel
26 */
27
28#include <string.h>
29
30#include "platform.h"
31#include "gnunet_util_lib.h"
32#include "gnunet_mesh_service.h"
33#include "gnunet_stream_lib.h"
34#include "gnunet_testbed_service.h"
35
36
37#define NUM_HOSTS 2
38
39#define PEER_PER_HOST 1
40
41#define TOTAL_PEERS (NUM_HOSTS * PEER_PER_HOST)
42
43/**
44 * Shorthand for Relative time in seconds
45 */
46#define TIME_REL_SECS(sec) \
47 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)
48
49/**
50 * Structure for holding peer's sockets and IO Handles
51 */
52struct PeerData
53{
54 /**
55 * Handle to testbed peer
56 */
57 struct GNUNET_TESTBED_Peer *peer;
58
59 /**
60 * Peer's stream socket
61 */
62 struct GNUNET_STREAM_Socket *socket;
63
64 /**
65 * Peer's io write handle
66 */
67 struct GNUNET_STREAM_IOWriteHandle *io_write_handle;
68
69 /**
70 * Peer's io read handle
71 */
72 struct GNUNET_STREAM_IOReadHandle *io_read_handle;
73
74 /**
75 * Peer's shutdown handle
76 */
77 struct GNUNET_STREAM_ShutdownHandle *shutdown_handle;
78
79 /**
80 * The service connect operation to stream
81 */
82 struct GNUNET_TESTBED_Operation *op;
83
84 /**
85 * Our Peer id
86 */
87 struct GNUNET_PeerIdentity our_id;
88
89 /**
90 * Bytes the peer has written
91 */
92 unsigned int bytes_wrote;
93
94 /**
95 * Byte the peer has read
96 */
97 unsigned int bytes_read;
98};
99
100
101/**
102 * Different states in test setup
103 */
104enum SetupState
105{
106 /**
107 * The initial state
108 */
109 INIT,
110
111 /**
112 * Connecting to slave controller
113 */
114 LINKING,
115
116 CREATING_PEER,
117
118 STARTING_PEER
119};
120
121
122/**
123 * Event Mask for operation callbacks
124 */
125uint64_t event_mask;
126
127/**
128 * Testbed operation handle
129 */
130static struct GNUNET_TESTBED_Operation *op[NUM_HOSTS];
131
132static enum SetupState state[NUM_HOSTS];
133
134static GNUNET_SCHEDULER_TaskIdentifier abort_task;
135
136/**
137 * Global test result
138 */
139static int result;
140
141/**
142 * Hosts successfully registered
143 */
144static unsigned int host_registered;
145
146/**
147 * Peers successfully started
148 */
149static unsigned int peers_started;
150
151/**
152 * The master controller host
153 */
154struct GNUNET_TESTBED_Host *master_host;
155
156/**
157 * The master controller process
158 */
159static struct GNUNET_TESTBED_ControllerProc *master_proc;
160
161/**
162 * Handle to master controller
163 */
164static struct GNUNET_TESTBED_Controller *master_ctrl;
165
166/**
167 * Slave host IP addresses
168 */
169
170static char *slave_ips[NUM_HOSTS] = { "192.168.1.33", "192.168.1.34" };
171
172/**
173 * The slave hosts
174 */
175struct GNUNET_TESTBED_Host *slave_hosts[NUM_HOSTS];
176
177/**
178 * Slave host registration handles
179 */
180static struct GNUNET_TESTBED_HostRegistrationHandle *rh;
181
182/**
183 * The peers
184 */
185struct GNUNET_TESTBED_Peer *peers[TOTAL_PEERS];
186
187/**
188 * Handle to global configuration
189 */
190static struct GNUNET_CONFIGURATION_Handle *cfg;
191
192
193/**
194 * Completion callback for shutdown
195 *
196 * @param cls the closure from GNUNET_STREAM_shutdown call
197 * @param operation the operation that was shutdown (SHUT_RD, SHUT_WR,
198 * SHUT_RDWR)
199 */
200// static void
201// shutdown_completion (void *cls,
202// int operation)
203// {
204// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "STREAM shutdown successful\n");
205// GNUNET_SCHEDULER_add_now (&do_close, cls);
206// }
207
208
209
210/**
211 * Shutdown sockets gracefully
212 */
213// static void
214// do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
215// {
216// result = GNUNET_OK;
217// peer1.shutdown_handle = GNUNET_STREAM_shutdown (peer1.socket, SHUT_RDWR,
218// &shutdown_completion, cls);
219// }
220
221
222/**
223 * Something went wrong and timed out. Kill everything and set error flag
224 */
225static void
226do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
227{
228 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: ABORT\n");
229 result = GNUNET_SYSERR;
230 abort_task = 0;
231}
232
233
234/**
235 * Adapter function called to destroy a connection to
236 * a service.
237 *
238 * @param cls closure
239 * @param op_result service handle returned from the connect adapter
240 */
241// static void
242// stream_da (void *cls, void *op_result)
243// {
244// struct GNUNET_STREAM_ListenSocket *lsocket;
245// struct GNUNET_STREAM_Socket *socket;
246//
247// if (&peer1 == cls)
248// {
249// lsocket = op_result;
250// GNUNET_STREAM_listen_close (lsocket);
251// GNUNET_TESTBED_operation_done (peer2.op);
252// return;
253// }
254// if (&peer2 == cls)
255// {
256// socket = op_result;
257// GNUNET_STREAM_close (socket);
258// GNUNET_SCHEDULER_shutdown (); /* Exit point of the test */
259// return;
260// }
261// GNUNET_assert (0);
262// }
263
264
265/**
266 * Adapter function called to establish a connection to
267 * a service.
268 *
269 * @param cls closure
270 * @param cfg configuration of the peer to connect to; will be available until
271 * GNUNET_TESTBED_operation_done() is called on the operation returned
272 * from GNUNET_TESTBED_service_connect()
273 * @return service handle to return in 'op_result', NULL on error
274 */
275// static void *
276// stream_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
277// {
278// struct GNUNET_STREAM_ListenSocket *lsocket;
279//
280// switch (setup_state)
281// {
282// case PEER1_STREAM_CONNECT:
283// lsocket = GNUNET_STREAM_listen (cfg, 10, &stream_listen_cb, NULL,
284// GNUNET_STREAM_OPTION_SIGNAL_LISTEN_SUCCESS,
285// &stream_connect, GNUNET_STREAM_OPTION_END);
286// return lsocket;
287// case PEER2_STREAM_CONNECT:
288// peer2.socket = GNUNET_STREAM_open (cfg, &peer1.our_id, 10, &stream_open_cb,
289// &peer2, GNUNET_STREAM_OPTION_END);
290// return peer2.socket;
291// default:
292// GNUNET_assert (0);
293// }
294// }
295
296
297/**
298 * Listen success callback; connects a peer to stream as client
299 */
300// static void
301// stream_connect (void)
302// {
303// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stream listen open successful\n");
304// peer2.op = GNUNET_TESTBED_service_connect (&peer2, peer2.peer, "stream",
305// NULL, NULL,
306// stream_ca, stream_da, &peer2);
307// setup_state = PEER2_STREAM_CONNECT;
308// }
309
310
311/**
312 * Callback to be called when the requested peer information is available
313 *
314 * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information()
315 * @param op the operation this callback corresponds to
316 * @param pinfo the result; will be NULL if the operation has failed
317 * @param emsg error message if the operation has failed; will be NULL if the
318 * operation is successfull
319 */
320// static void
321// peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_,
322// const struct GNUNET_TESTBED_PeerInformation *pinfo,
323// const char *emsg)
324// {
325// GNUNET_assert (NULL == emsg);
326// GNUNET_assert (op == op_);
327// switch (setup_state)
328// {
329// case PEER1_GET_IDENTITY:
330// memcpy (&peer1.our_id, pinfo->result.id,
331// sizeof (struct GNUNET_PeerIdentity));
332// GNUNET_TESTBED_operation_done (op);
333// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 id: %s\n", GNUNET_i2s
334// (&peer1.our_id));
335// op = GNUNET_TESTBED_peer_get_information (peer2.peer,
336// GNUNET_TESTBED_PIT_IDENTITY,
337// &peerinfo_cb, NULL);
338// setup_state = PEER2_GET_IDENTITY;
339// break;
340// case PEER2_GET_IDENTITY:
341// memcpy (&peer2.our_id, pinfo->result.id,
342// sizeof (struct GNUNET_PeerIdentity));
343// GNUNET_TESTBED_operation_done (op);
344// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 2 id: %s\n", GNUNET_i2s
345// (&peer2.our_id));
346// peer1.op = GNUNET_TESTBED_service_connect (&peer1, peer1.peer, "stream",
347// NULL, NULL, stream_ca,
348// stream_da, &peer1);
349// setup_state = PEER1_STREAM_CONNECT;
350// break;
351// default:
352// GNUNET_assert (0);
353// }
354// }
355
356
357/**
358 * Controller event callback
359 *
360 * @param cls NULL
361 * @param event the controller event
362 */
363// static void
364// controller_event_cb (void *cls,
365// const struct GNUNET_TESTBED_EventInformation *event)
366// {
367// switch (event->type)
368// {
369// case GNUNET_TESTBED_ET_CONNECT:
370// GNUNET_assert (INIT == setup_state);
371// GNUNET_TESTBED_operation_done (op);
372// /* Get the peer identity and configuration of peers */
373// op = GNUNET_TESTBED_peer_get_information (peer1.peer,
374// GNUNET_TESTBED_PIT_IDENTITY,
375// &peerinfo_cb, NULL);
376// setup_state = PEER1_GET_IDENTITY;
377// break;
378// case GNUNET_TESTBED_ET_OPERATION_FINISHED:
379// switch (setup_state)
380// {
381// case PEER1_STREAM_CONNECT:
382// case PEER2_STREAM_CONNECT:
383// GNUNET_assert (NULL == event->details.operation_finished.emsg);
384// break;
385// default:
386// GNUNET_assert (0);
387// }
388// break;
389// default:
390// GNUNET_assert (0);
391// }
392// }
393
394
395/**
396 * Signature of a main function for a testcase.
397 *
398 * @param cls closure
399 * @param num_peers number of peers in 'peers'
400 * @param peers handle to peers run in the testbed
401 */
402// static void
403// test_master (void *cls, unsigned int num_peers,
404// struct GNUNET_TESTBED_Peer **peers)
405// {
406// GNUNET_assert (NULL != peers);
407// GNUNET_assert (NULL != peers[0]);
408// GNUNET_assert (NULL != peers[1]);
409// peer1.peer = peers[0];
410// peer2.peer = peers[1];
411// op = GNUNET_TESTBED_overlay_connect (NULL, NULL, NULL, peer2.peer, peer1.peer);
412// setup_state = INIT;
413// abort_task =
414// GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
415// (GNUNET_TIME_UNIT_SECONDS, 40), &do_abort,
416// NULL);
417// }
418
419/**
420 * Functions of this signature are called when a peer has been successfully
421 * started or stopped.
422 *
423 * @param cls the closure from GNUNET_TESTBED_peer_start/stop()
424 * @param emsg NULL on success; otherwise an error description
425 */
426static void
427peer_start_cb (void *cls, const char *emsg)
428{
429 long i = (long) cls;
430
431 GNUNET_TESTBED_operation_done (op[i]);
432 peers_started++;
433 // FIXME create and start rest of PEERS_PER_HOST
434 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u peer(s) started\n", peers_started);
435
436 if (TOTAL_PEERS == peers_started)
437 {
438 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ok\n");
439 }
440}
441
442
443/**
444 * Functions of this signature are called when a peer has been successfully
445 * created
446 *
447 * @param cls the closure from GNUNET_TESTBED_peer_create()
448 * @param peer the handle for the created peer; NULL on any error during
449 * creation
450 * @param emsg NULL if peer is not NULL; else MAY contain the error description
451 */
452static void
453peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
454{
455 long i = (long) cls;
456 long peer_id;
457
458// GNUNET_TESTBED_operation_done(op[i]);
459 peer_id = i; // FIXME A * i + B
460 peers[peer_id] = peer;
461 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer %i created\n", peer_id);
462 op[i] = GNUNET_TESTBED_peer_start (NULL, peer, peer_start_cb, (void *) i);
463}
464
465
466/**
467 * Signature of the event handler function called by the
468 * respective event controller.
469 *
470 * @param cls closure
471 * @param event information about the event
472 */
473static void
474controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
475{
476 long i;
477
478 switch (event->type)
479 {
480 case GNUNET_TESTBED_ET_PEER_START:
481 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer started\n");
482 /* event->details.peer_start.peer; */
483 /* event->details.peer_start.host; */
484
485 break;
486 case GNUNET_TESTBED_ET_PEER_STOP:
487 case GNUNET_TESTBED_ET_CONNECT:
488 break;
489 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
490 if (NULL != event->details.operation_finished.emsg)
491 {
492 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Testbed error: %s\n",
493 event->details.operation_finished.emsg);
494 GNUNET_assert (0);
495 }
496 GNUNET_TESTBED_operation_done (event->details.operation_finished.operation);
497 //GNUNET_assert (NULL != event->details.operation_finished.op_cls);
498 i = (long) event->details.operation_finished.op_cls;
499 op[i] = NULL;
500 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i);
501 switch (state[i])
502 {
503 case INIT:
504 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Init: %u\n", i);
505 break;
506 case LINKING:
507 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linked host %i\n", i);
508 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Creating peer...\n");
509
510 state[i] = CREATING_PEER;
511 op[i] =
512 GNUNET_TESTBED_peer_create (master_ctrl, slave_hosts[i], cfg,
513 peer_create_cb, (void *) i);
514 break;
515 case CREATING_PEER:
516 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer create\n");
517 break;
518 default:
519 GNUNET_break (0);
520 }
521 break;
522 default:
523 GNUNET_break (0);
524 }
525}
526
527/**
528 * Callback which will be called to after a host registration succeeded or failed
529 *
530 * @param cls the host which has been registered
531 * @param emsg the error message; NULL if host registration is successful
532 */
533static void
534registration_cont (void *cls, const char *emsg)
535{
536 if (NULL != emsg)
537 {
538 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
539 GNUNET_assert (0);
540 }
541 state[host_registered] = LINKING;
542 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linking host %u\n", host_registered);
543 op[host_registered] =
544 GNUNET_TESTBED_controller_link ((void *) (long) host_registered,
545 master_ctrl, slave_hosts[host_registered],
546 NULL, cfg, GNUNET_YES);
547 host_registered++;
548 if (NUM_HOSTS != host_registered)
549 {
550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Registering host %u\n",
551 host_registered);
552 rh = GNUNET_TESTBED_register_host (master_ctrl,
553 slave_hosts[host_registered],
554 &registration_cont, NULL);
555 return;
556 }
557}
558
559/**
560 * Callback to signal successfull startup of the controller process
561 *
562 * @param cls the closure from GNUNET_TESTBED_controller_start()
563 * @param cfg the configuration with which the controller has been started;
564 * NULL if status is not GNUNET_OK
565 * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not,
566 * GNUNET_TESTBED_controller_stop() shouldn't be called in this case
567 */
568static void
569status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
570 int status)
571{
572 unsigned int i;
573
574 if (NULL == config || GNUNET_OK != status)
575 return;
576
577 event_mask = 0;
578 event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START);
579 event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP);
580 event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT);
581 event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED);
582 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to master controller\n");
583 master_ctrl =
584 GNUNET_TESTBED_controller_connect (config, master_host, event_mask,
585 &controller_cb, NULL);
586 GNUNET_assert (NULL != master_ctrl);
587
588 for (i = 0; i < NUM_HOSTS; i++)
589 {
590 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Creating host %u\n", i);
591 slave_hosts[i] = GNUNET_TESTBED_host_create (slave_ips[i], NULL, 0);
592 GNUNET_assert (NULL != slave_hosts[i]);
593 }
594 host_registered = 0;
595 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Registering host %u\n",
596 host_registered);
597 rh = GNUNET_TESTBED_register_host (master_ctrl, slave_hosts[0],
598 &registration_cont, NULL);
599 GNUNET_assert (NULL != rh);
600}
601
602
603/**
604 * Main run function.
605 *
606 * @param cls NULL
607 * @param args arguments passed to GNUNET_PROGRAM_run
608 * @param cfgfile the path to configuration file
609 * @param cfg the configuration file handle
610 */
611static void
612run (void *cls, char *const *args, const char *cfgfile,
613 const struct GNUNET_CONFIGURATION_Handle *config)
614{
615 master_host = GNUNET_TESTBED_host_create ("192.168.1.33", NULL, 0);
616 GNUNET_assert (NULL != master_host);
617 cfg = GNUNET_CONFIGURATION_dup (config);
618 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting master controller\n");
619 master_proc =
620 GNUNET_TESTBED_controller_start ("192.168.1.33", master_host, cfg,
621 status_cb, NULL);
622 abort_task =
623 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
624 (GNUNET_TIME_UNIT_MINUTES, 60), &do_abort,
625 NULL);
626}
627
628/**
629 * Main function
630 */
631int
632main (int argc, char **argv)
633{
634 int ret;
635 int test_hosts;
636 unsigned int i;
637
638 struct GNUNET_GETOPT_CommandLineOption options[] = {
639 GNUNET_GETOPT_OPTION_END
640 };
641 char *const argv2[] = { "gnunet-regex-profiler",
642 "-c", "regex_profiler_test.conf",
643 NULL
644 };
645
646 test_hosts = GNUNET_OK;
647 for (i = 0; i < NUM_HOSTS; i++)
648 {
649 char *const remote_args[] = {
650 "ssh", "-o", "BatchMode=yes", slave_ips[i],
651 "gnunet-helper-testbed --help > /dev/null", NULL
652 };
653 struct GNUNET_OS_Process *auxp;
654 enum GNUNET_OS_ProcessStatusType type;
655 unsigned long code;
656
657 fprintf (stderr, "Testing host %i\n", i);
658 auxp =
659 GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
660 NULL, "ssh", remote_args);
661 GNUNET_assert (NULL != auxp);
662 do
663 {
664 ret = GNUNET_OS_process_status (auxp, &type, &code);
665 GNUNET_assert (GNUNET_SYSERR != ret);
666 (void) usleep (300);
667 }
668 while (GNUNET_NO == ret);
669 (void) GNUNET_OS_process_wait (auxp);
670 GNUNET_OS_process_destroy (auxp);
671 if (0 != code)
672 {
673 fprintf (stderr,
674 "Unable to run the test as this system is not configured "
675 "to use password less SSH logins to host %s.\n", slave_ips[i]);
676 test_hosts = GNUNET_SYSERR;
677 }
678 }
679 if (test_hosts != GNUNET_OK)
680 {
681 fprintf (stderr, "Some hosts have failed the ssh check. Exiting.\n");
682 return 1;
683 }
684 fprintf (stderr, "START.\n");
685
686 result = GNUNET_SYSERR;
687
688 ret =
689 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
690 "test_regex_big", "nohelp", options, &run, NULL);
691
692 fprintf (stderr, "END.\n");
693
694 if (GNUNET_SYSERR == result || GNUNET_OK != ret)
695 return 1;
696 return 0;
697}
diff --git a/src/regex/regex.c b/src/regex/regex.c
index c92726096..024e26e0e 100644
--- a/src/regex/regex.c
+++ b/src/regex/regex.c
@@ -30,12 +30,6 @@
30 30
31 31
32/** 32/**
33 * Constant for how many bits the initial string regex should have.
34 */
35#define INITIAL_BITS 8
36
37
38/**
39 * Set of states. 33 * Set of states.
40 */ 34 */
41struct GNUNET_REGEX_StateSet 35struct GNUNET_REGEX_StateSet
@@ -148,6 +142,7 @@ state_remove_transition (struct GNUNET_REGEX_State *state,
148 state->transition_count--; 142 state->transition_count--;
149 GNUNET_CONTAINER_DLL_remove (state->transitions_head, state->transitions_tail, 143 GNUNET_CONTAINER_DLL_remove (state->transitions_head, state->transitions_tail,
150 transition); 144 transition);
145
151 GNUNET_free (transition); 146 GNUNET_free (transition);
152} 147}
153 148
@@ -526,29 +521,6 @@ GNUNET_REGEX_automaton_traverse (const struct GNUNET_REGEX_Automaton *a,
526 521
527 522
528/** 523/**
529 * Context for adding strided transitions to a DFA.
530 */
531struct GNUNET_REGEX_Strided_Context
532{
533 /**
534 * Length of the strides.
535 */
536 const unsigned int stride;
537
538 /**
539 * Strided transitions DLL. New strided transitions will be stored in this DLL
540 * and afterwards added to the DFA.
541 */
542 struct GNUNET_REGEX_Transition *transitions_head;
543
544 /**
545 * Strided transitions DLL.
546 */
547 struct GNUNET_REGEX_Transition *transitions_tail;
548};
549
550
551/**
552 * Check if the given string 'str' needs parentheses around it when 524 * Check if the given string 'str' needs parentheses around it when
553 * using it to generate a regex. 525 * using it to generate a regex.
554 * 526 *
@@ -1555,6 +1527,29 @@ dfa_minimize (struct GNUNET_REGEX_Context *ctx,
1555 1527
1556 1528
1557/** 1529/**
1530 * Context for adding strided transitions to a DFA.
1531 */
1532struct GNUNET_REGEX_Strided_Context
1533{
1534 /**
1535 * Length of the strides.
1536 */
1537 const unsigned int stride;
1538
1539 /**
1540 * Strided transitions DLL. New strided transitions will be stored in this DLL
1541 * and afterwards added to the DFA.
1542 */
1543 struct GNUNET_REGEX_Transition *transitions_head;
1544
1545 /**
1546 * Strided transitions DLL.
1547 */
1548 struct GNUNET_REGEX_Transition *transitions_tail;
1549};
1550
1551
1552/**
1558 * Recursive helper function to add strides to a DFA. 1553 * Recursive helper function to add strides to a DFA.
1559 * 1554 *
1560 * @param cls context, contains stride length and strided transitions DLL. 1555 * @param cls context, contains stride length and strided transitions DLL.
@@ -1664,15 +1659,19 @@ GNUNET_REGEX_dfa_add_multi_strides (struct GNUNET_REGEX_Context *regex_ctx,
1664 * and adds new transitions to the given transitions DLL and marks states that 1659 * and adds new transitions to the given transitions DLL and marks states that
1665 * should be removed by setting state->contained to GNUNET_YES. 1660 * should be removed by setting state->contained to GNUNET_YES.
1666 * 1661 *
1662 * @param dfa DFA for which the paths should be compressed.
1667 * @param start starting state for linear path search. 1663 * @param start starting state for linear path search.
1668 * @param cur current state in the recursive DFS. 1664 * @param cur current state in the recursive DFS.
1669 * @param label current label (string of traversed labels). 1665 * @param label current label (string of traversed labels).
1666 * @param max_len maximal path compression length.
1670 * @param transitions_head transitions DLL. 1667 * @param transitions_head transitions DLL.
1671 * @param transitions_tail transitions DLL. 1668 * @param transitions_tail transitions DLL.
1672 */ 1669 */
1673void 1670void
1674dfa_compress_paths_helper (struct GNUNET_REGEX_State *start, 1671dfa_compress_paths_helper (struct GNUNET_REGEX_Automaton *dfa,
1672 struct GNUNET_REGEX_State *start,
1675 struct GNUNET_REGEX_State *cur, char *label, 1673 struct GNUNET_REGEX_State *cur, char *label,
1674 unsigned int max_len,
1676 struct GNUNET_REGEX_Transition **transitions_head, 1675 struct GNUNET_REGEX_Transition **transitions_head,
1677 struct GNUNET_REGEX_Transition **transitions_tail) 1676 struct GNUNET_REGEX_Transition **transitions_tail)
1678{ 1677{
@@ -1681,8 +1680,11 @@ dfa_compress_paths_helper (struct GNUNET_REGEX_State *start,
1681 1680
1682 1681
1683 if (NULL != label && 1682 if (NULL != label &&
1684 (cur->incoming_transition_count > 1 || GNUNET_YES == cur->accepting || 1683 ((cur->incoming_transition_count > 1 || GNUNET_YES == cur->accepting
1685 cur->transition_count > 1 || GNUNET_YES == cur->marked)) 1684// || cur->transition_count > 1
1685 || GNUNET_YES == cur->marked) || (start != dfa->start && max_len > 0 &&
1686 max_len == strlen (label)) ||
1687 (start == dfa->start && GNUNET_REGEX_INITIAL_BITS == strlen (label))))
1686 { 1688 {
1687 t = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Transition)); 1689 t = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Transition));
1688 t->label = GNUNET_strdup (label); 1690 t->label = GNUNET_strdup (label);
@@ -1692,7 +1694,7 @@ dfa_compress_paths_helper (struct GNUNET_REGEX_State *start,
1692 1694
1693 if (GNUNET_NO == cur->marked) 1695 if (GNUNET_NO == cur->marked)
1694 { 1696 {
1695 dfa_compress_paths_helper (cur, cur, NULL, transitions_head, 1697 dfa_compress_paths_helper (dfa, cur, cur, NULL, max_len, transitions_head,
1696 transitions_tail); 1698 transitions_tail);
1697 } 1699 }
1698 return; 1700 return;
@@ -1715,7 +1717,7 @@ dfa_compress_paths_helper (struct GNUNET_REGEX_State *start,
1715 1717
1716 if (t->to_state != cur) 1718 if (t->to_state != cur)
1717 { 1719 {
1718 dfa_compress_paths_helper (start, t->to_state, new_label, 1720 dfa_compress_paths_helper (dfa, start, t->to_state, new_label, max_len,
1719 transitions_head, transitions_tail); 1721 transitions_head, transitions_tail);
1720 } 1722 }
1721 GNUNET_free (new_label); 1723 GNUNET_free (new_label);
@@ -1728,10 +1730,11 @@ dfa_compress_paths_helper (struct GNUNET_REGEX_State *start,
1728 * 1730 *
1729 * @param regex_ctx context for adding new transitions. 1731 * @param regex_ctx context for adding new transitions.
1730 * @param dfa DFA representation, will directly modify the given DFA. 1732 * @param dfa DFA representation, will directly modify the given DFA.
1733 * @param max_len maximal length of the compressed paths.
1731 */ 1734 */
1732static void 1735static void
1733dfa_compress_paths (struct GNUNET_REGEX_Context *regex_ctx, 1736dfa_compress_paths (struct GNUNET_REGEX_Context *regex_ctx,
1734 struct GNUNET_REGEX_Automaton *dfa) 1737 struct GNUNET_REGEX_Automaton *dfa, unsigned int max_len)
1735{ 1738{
1736 struct GNUNET_REGEX_State *s; 1739 struct GNUNET_REGEX_State *s;
1737 struct GNUNET_REGEX_State *s_next; 1740 struct GNUNET_REGEX_State *s_next;
@@ -1761,8 +1764,8 @@ dfa_compress_paths (struct GNUNET_REGEX_Context *regex_ctx,
1761 } 1764 }
1762 1765
1763 // Add strides and mark states that can be deleted. 1766 // Add strides and mark states that can be deleted.
1764 dfa_compress_paths_helper (dfa->start, dfa->start, NULL, &transitions_head, 1767 dfa_compress_paths_helper (dfa, dfa->start, dfa->start, NULL, max_len,
1765 &transitions_tail); 1768 &transitions_head, &transitions_tail);
1766 1769
1767 // Add all the new transitions to the automaton. 1770 // Add all the new transitions to the automaton.
1768 for (t = transitions_head; NULL != t; t = t_next) 1771 for (t = transitions_head; NULL != t; t = t_next)
@@ -2101,6 +2104,14 @@ nfa_add_plus_op (struct GNUNET_REGEX_Context *ctx)
2101 struct GNUNET_REGEX_Automaton *a; 2104 struct GNUNET_REGEX_Automaton *a;
2102 2105
2103 a = ctx->stack_tail; 2106 a = ctx->stack_tail;
2107
2108 if (NULL == a)
2109 {
2110 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2111 "nfa_add_plus_op failed, because there was no element on the stack");
2112 return;
2113 }
2114
2104 GNUNET_CONTAINER_DLL_remove (ctx->stack_head, ctx->stack_tail, a); 2115 GNUNET_CONTAINER_DLL_remove (ctx->stack_head, ctx->stack_tail, a);
2105 2116
2106 state_add_transition (ctx, a->end, NULL, a->start); 2117 state_add_transition (ctx, a->end, NULL, a->start);
@@ -2518,12 +2529,12 @@ GNUNET_REGEX_construct_dfa (const char *regex, const size_t len)
2518 // Minimize DFA 2529 // Minimize DFA
2519 dfa_minimize (&ctx, dfa); 2530 dfa_minimize (&ctx, dfa);
2520 2531
2521 // Compress DFA paths
2522 dfa_compress_paths (&ctx, dfa);
2523
2524 // Create proofs for all states 2532 // Create proofs for all states
2525 automaton_create_proofs (dfa); 2533 automaton_create_proofs (dfa);
2526 2534
2535 // Compress DFA paths
2536 dfa_compress_paths (&ctx, dfa, 8);
2537
2527 // Add strides to DFA 2538 // Add strides to DFA
2528 //GNUNET_REGEX_dfa_add_multi_strides (&ctx, dfa, 2); 2539 //GNUNET_REGEX_dfa_add_multi_strides (&ctx, dfa, 2);
2529 2540
@@ -2730,10 +2741,9 @@ GNUNET_REGEX_get_transition_count (struct GNUNET_REGEX_Automaton *a)
2730 if (NULL == a) 2741 if (NULL == a)
2731 return 0; 2742 return 0;
2732 2743
2733 for (t_count = 0, s = a->states_head; NULL != s; s = s->next) 2744 t_count = 0;
2734 { 2745 for (s = a->states_head; NULL != s; s = s->next)
2735 t_count += s->transition_count; 2746 t_count += s->transition_count;
2736 }
2737 2747
2738 return t_count; 2748 return t_count;
2739} 2749}
@@ -2756,7 +2766,9 @@ GNUNET_REGEX_get_first_key (const char *input_string, size_t string_len,
2756{ 2766{
2757 unsigned int size; 2767 unsigned int size;
2758 2768
2759 size = string_len < INITIAL_BITS ? string_len : INITIAL_BITS; 2769 size =
2770 string_len <
2771 GNUNET_REGEX_INITIAL_BITS ? string_len : GNUNET_REGEX_INITIAL_BITS;
2760 2772
2761 if (NULL == input_string) 2773 if (NULL == input_string)
2762 { 2774 {
@@ -2796,8 +2808,7 @@ GNUNET_REGEX_check_proof (const char *proof, const struct GNUNET_HashCode *key)
2796 2808
2797 2809
2798/** 2810/**
2799 * Recursive helper function for iterate_initial_edges. Will call iterator 2811 * Recursive function that calls the iterator for each synthetic start state.
2800 * function for each initial state.
2801 * 2812 *
2802 * @param min_len minimum length of the path in the graph. 2813 * @param min_len minimum length of the path in the graph.
2803 * @param max_len maximum length of the path in the graph. 2814 * @param max_len maximum length of the path in the graph.
@@ -2831,22 +2842,24 @@ iterate_initial_edge (const unsigned int min_len, const unsigned int max_len,
2831 { 2842 {
2832 if (cur_len <= max_len) 2843 if (cur_len <= max_len)
2833 { 2844 {
2834 for (i = 0, t = state->transitions_head; NULL != t && i < num_edges; 2845 if (state->proof != NULL && 0 != strcmp (consumed_string, state->proof))
2835 t = t->next, i++)
2836 { 2846 {
2837 edges[i].label = t->label; 2847 for (i = 0, t = state->transitions_head; NULL != t && i < num_edges;
2838 edges[i].destination = t->to_state->hash; 2848 t = t->next, i++)
2849 {
2850 edges[i].label = t->label;
2851 edges[i].destination = t->to_state->hash;
2852 }
2853 GNUNET_CRYPTO_hash (consumed_string, strlen (consumed_string), &hash);
2854 iterator (iterator_cls, &hash, consumed_string, state->accepting,
2855 num_edges, edges);
2839 } 2856 }
2840 2857
2841 GNUNET_CRYPTO_hash (consumed_string, strlen (consumed_string), &hash);
2842 iterator (iterator_cls, &hash, consumed_string, state->accepting,
2843 num_edges, edges);
2844
2845 // Special case for regex consisting of just a string that is shorter than
2846 // max_len
2847 if (GNUNET_YES == state->accepting && cur_len > 1 && 2858 if (GNUNET_YES == state->accepting && cur_len > 1 &&
2848 state->transition_count < 1 && cur_len < max_len) 2859 state->transition_count < 1 && cur_len < max_len)
2849 { 2860 {
2861 // Special case for regex consisting of just a string that is shorter than
2862 // max_len
2850 edge[0].label = &consumed_string[cur_len - 1]; 2863 edge[0].label = &consumed_string[cur_len - 1];
2851 edge[0].destination = state->hash; 2864 edge[0].destination = state->hash;
2852 temp = GNUNET_strdup (consumed_string); 2865 temp = GNUNET_strdup (consumed_string);
@@ -2858,6 +2871,7 @@ iterate_initial_edge (const unsigned int min_len, const unsigned int max_len,
2858 } 2871 }
2859 else if (max_len < cur_len) 2872 else if (max_len < cur_len)
2860 { 2873 {
2874 // Case where the concatenated labels are longer than max_len, then split.
2861 edge[0].label = &consumed_string[max_len]; 2875 edge[0].label = &consumed_string[max_len];
2862 edge[0].destination = state->hash; 2876 edge[0].destination = state->hash;
2863 temp = GNUNET_strdup (consumed_string); 2877 temp = GNUNET_strdup (consumed_string);
@@ -2886,38 +2900,6 @@ iterate_initial_edge (const unsigned int min_len, const unsigned int max_len,
2886 2900
2887 2901
2888/** 2902/**
2889 * Iterate over all edges helper function starting from state 's', calling
2890 * iterator function for each edge if the automaton.
2891 *
2892 * @param s state.
2893 * @param iterator iterator function called for each edge.
2894 * @param iterator_cls closure.
2895 */
2896static void
2897iterate_edge (struct GNUNET_REGEX_State *s, GNUNET_REGEX_KeyIterator iterator,
2898 void *iterator_cls)
2899{
2900 struct GNUNET_REGEX_Transition *t;
2901 struct GNUNET_REGEX_Edge edges[s->transition_count];
2902 unsigned int num_edges;
2903
2904 if (GNUNET_YES != s->marked)
2905 {
2906 s->marked = GNUNET_YES;
2907
2908 num_edges = state_get_edges (s, edges);
2909
2910 if ((NULL != s->proof && 0 < strlen (s->proof)) || s->accepting)
2911 iterator (iterator_cls, &s->hash, s->proof, s->accepting, num_edges,
2912 edges);
2913
2914 for (t = s->transitions_head; NULL != t; t = t->next)
2915 iterate_edge (t->to_state, iterator, iterator_cls);
2916 }
2917}
2918
2919
2920/**
2921 * Iterate over all edges starting from start state of automaton 'a'. Calling 2903 * Iterate over all edges starting from start state of automaton 'a'. Calling
2922 * iterator for each edge. 2904 * iterator for each edge.
2923 * 2905 *
@@ -2933,11 +2915,21 @@ GNUNET_REGEX_iterate_all_edges (struct GNUNET_REGEX_Automaton *a,
2933 struct GNUNET_REGEX_State *s; 2915 struct GNUNET_REGEX_State *s;
2934 2916
2935 for (s = a->states_head; NULL != s; s = s->next) 2917 for (s = a->states_head; NULL != s; s = s->next)
2918 {
2919 struct GNUNET_REGEX_Edge edges[s->transition_count];
2920 unsigned int num_edges;
2921
2922 num_edges = state_get_edges (s, edges);
2923
2924 if ((NULL != s->proof && 0 < strlen (s->proof)) || s->accepting)
2925 iterator (iterator_cls, &s->hash, s->proof, s->accepting, num_edges,
2926 edges);
2927
2936 s->marked = GNUNET_NO; 2928 s->marked = GNUNET_NO;
2929 }
2937 2930
2938 iterate_initial_edge (0, INITIAL_BITS, NULL, a->start, iterator, 2931 iterate_initial_edge (GNUNET_REGEX_INITIAL_BITS, GNUNET_REGEX_INITIAL_BITS,
2939 iterator_cls); 2932 NULL, a->start, iterator, iterator_cls);
2940 iterate_edge (a->start, iterator, iterator_cls);
2941} 2933}
2942 2934
2943 2935
diff --git a/src/regex/regex_internal.h b/src/regex/regex_internal.h
index 3e4d0ca0e..49e5dd022 100644
--- a/src/regex/regex_internal.h
+++ b/src/regex/regex_internal.h
@@ -142,7 +142,7 @@ struct GNUNET_REGEX_State
142 int lowlink; 142 int lowlink;
143 143
144 /** 144 /**
145 * Human readable name of the automaton. Used for debugging and graph 145 * Human readable name of the state. Used for debugging and graph
146 * creation. 146 * creation.
147 */ 147 */
148 char *name; 148 char *name;
diff --git a/src/regex/regex_profiler_test.conf b/src/regex/regex_profiler_test.conf
new file mode 100644
index 000000000..f21a2ba57
--- /dev/null
+++ b/src/regex/regex_profiler_test.conf
@@ -0,0 +1,87 @@
1[lockmanager]
2AUTOSTART = NO
3ACCEPT_FROM = 127.0.0.1;
4HOSTNAME = localhost
5PORT = 12101
6
7[fs]
8AUTOSTART = NO
9
10[resolver]
11AUTOSTART = NO
12
13[mesh]
14AUTOSTART = YES
15ACCEPT_FROM = 127.0.0.1;
16HOSTNAME = localhost
17PORT = 10700
18# PREFIX = valgrind --leak-check=full
19# PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
20
21[dht]
22DEBUG = NO
23AUTOSTART = YES
24ACCEPT_FROM6 = ::1;
25ACCEPT_FROM = 127.0.0.1;
26HOSTNAME = localhost
27PORT = 12100
28
29[block]
30plugins = dht test
31
32[dhtcache]
33QUOTA = 1 MB
34DATABASE = sqlite
35
36[transport]
37PLUGINS = tcp
38DEBUG = NO
39ACCEPT_FROM6 = ::1;
40ACCEPT_FROM = 127.0.0.1;
41NEIGHBOUR_LIMIT = 50
42PORT = 12365
43
44[ats]
45WAN_QUOTA_OUT = 3932160
46WAN_QUOTA_IN = 3932160
47
48[core]
49PORT = 12092
50
51[arm]
52DEFAULTSERVICES = core lockmanager statistics
53PORT = 12366
54DEBUG = NO
55
56[transport-tcp]
57TIMEOUT = 300 s
58PORT = 12368
59
60[TESTING]
61WEAKRANDOM = YES
62
63[testing_old]
64NUM_PEERS = 5
65DEBUG = YES
66HOSTKEYSFILE = ${DATADIR}/testing_hostkeys.dat
67MAX_CONCURRENT_SSH = 10
68USE_PROGRESSBARS = YES
69PEERGROUP_TIMEOUT = 2400 s
70
71[gnunetd]
72HOSTKEY = $SERVICEHOME/.hostkey
73
74[PATHS]
75SERVICEHOME = /tmp/test-stream/
76
77[dns]
78AUTOSTART = NO
79
80[nse]
81AUTOSTART = NO
82
83[vpn]
84AUTOSTART = NO
85
86[testbed]
87PORT = 12099
diff --git a/src/regex/test_regex_graph_api.c b/src/regex/test_regex_graph_api.c
index ea1c7fb78..b57c79edd 100644
--- a/src/regex/test_regex_graph_api.c
+++ b/src/regex/test_regex_graph_api.c
@@ -86,7 +86,7 @@ main (int argc, char *argv[])
86 86
87 error = 0; 87 error = 0;
88 88
89 const char *regex[10] = { 89 const char *regex[12] = {
90 "ab(c|d)+c*(a(b|c)+d)+(bla)+", 90 "ab(c|d)+c*(a(b|c)+d)+(bla)+",
91 "(bla)*", 91 "(bla)*",
92 "b(lab)*la", 92 "b(lab)*la",
@@ -96,10 +96,13 @@ main (int argc, char *argv[])
96 "1*0(0|1)*", 96 "1*0(0|1)*",
97 "a*b*", 97 "a*b*",
98 "a+X*y+c|p|R|Z*K*y*R+w|Y*6+n+h*k*w+V*F|W*B*e*", 98 "a+X*y+c|p|R|Z*K*y*R+w|Y*6+n+h*k*w+V*F|W*B*e*",
99 "a" 99 "a",
100 "a|b",
101// "abc(d+|e)fgh"
102 "PADPADPADPADPADPabcdefghixxxxxxxxxxxxxjklmnop*qstoisdjfguisdfguihsdfgbdsuivggsd"
100 }; 103 };
101 104
102 for (i = 0; i < 10; i++) 105 for (i = 0; i < 12; i++)
103 { 106 {
104 // Check NFA graph creation 107 // Check NFA graph creation
105 a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i])); 108 a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i]));
@@ -152,10 +155,9 @@ main (int argc, char *argv[])
152 155
153 156
154 a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i])); 157 a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]));
155 GNUNET_REGEX_automaton_save_graph (a, filename, 158 GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); //|
156 GNUNET_REGEX_GRAPH_DEFAULT | 159 // GNUNET_REGEX_GRAPH_VERBOSE |
157 GNUNET_REGEX_GRAPH_VERBOSE | 160 //GNUNET_REGEX_GRAPH_COLORING);
158 GNUNET_REGEX_GRAPH_COLORING);
159 GNUNET_REGEX_automaton_destroy (a); 161 GNUNET_REGEX_automaton_destroy (a);
160 error += filecheck (filename); 162 error += filecheck (filename);
161 163
diff --git a/src/regex/test_regex_iptoregex.c b/src/regex/test_regex_iptoregex.c
index 004d79041..e33e7929a 100644
--- a/src/regex/test_regex_iptoregex.c
+++ b/src/regex/test_regex_iptoregex.c
@@ -77,9 +77,10 @@ main (int argc, char *argv[])
77 "1111111111111111(0|1)+"); 77 "1111111111111111(0|1)+");
78 78
79 error += 79 error +=
80 test_iptoregex ("187.238.225.0", "255.255.255.128", 80 test_iptoregex ("187.238.225.0", "255.255.255.128",
81 "1011101111101110111000010(0|1)+", "E1E1:73F9:51BE::0", 49, 81 "1011101111101110111000010(0|1)+", "E1E1:73F9:51BE::0",
82 "1110000111100001011100111111100101010001101111100(0|1)+"); 82 49,
83 "1110000111100001011100111111100101010001101111100(0|1)+");
83 84
84 error += 85 error +=
85 test_iptoregex ("255.255.255.255", "255.255.255.255", 86 test_iptoregex ("255.255.255.255", "255.255.255.255",
diff --git a/src/regex/test_regex_iterate_api.c b/src/regex/test_regex_iterate_api.c
index 8dce07615..fc60853f4 100644
--- a/src/regex/test_regex_iterate_api.c
+++ b/src/regex/test_regex_iterate_api.c
@@ -28,6 +28,7 @@
28#include "gnunet_regex_lib.h" 28#include "gnunet_regex_lib.h"
29#include "regex_internal.h" 29#include "regex_internal.h"
30 30
31#define INITIAL_PADDING "PADPADPADPADPADP"
31#define GNUNET_REGEX_ITERATE_SAVE_DEBUG_GRAPH GNUNET_NO 32#define GNUNET_REGEX_ITERATE_SAVE_DEBUG_GRAPH GNUNET_NO
32 33
33static unsigned int transition_counter; 34static unsigned int transition_counter;
@@ -115,30 +116,41 @@ main (int argc, char *argv[])
115 116
116 error = 0; 117 error = 0;
117 118
118 const struct RegexStringPair rxstr[14] = { 119 const struct RegexStringPair rxstr[13] = {
119 {"ab(c|d)+c*(a(b|c)+d)+(bla)+", 2, {"abcdcdca", "abcabdbl"}}, 120 {INITIAL_PADDING "ab(c|d)+c*(a(b|c)+d)+(bla)+", 2,
120 {"abcdefghijklmnop*qst", 1, {"abcdefgh"}}, 121 {INITIAL_PADDING "abcdcdca", INITIAL_PADDING "abcabdbl"}},
121 {"VPN-4-1(0|1)*", 2, {"VPN-4-10", "VPN-4-11"}}, 122 {INITIAL_PADDING
122 {"a+X*y+c|p|R|Z*K*y*R+w|Y*6+n+h*k*w+V*F|W*B*e*", 4, 123 "abcdefghixxxxxxxxxxxxxjklmnop*qstoisdjfguisdfguihsdfgbdsuivggsd", 1,
123 {"aaaaaaaa", "aaXXyyyc", "p", "Y"}}, 124 {INITIAL_PADDING "abcdefgh"}},
124 {"a*", 8, 125 {INITIAL_PADDING "VPN-4-1(0|1)*", 2,
125 {"a", "aa", "aaa", "aaaa", "aaaaa", "aaaaaa", "aaaaaaa", "aaaaaaaa"}}, 126 {INITIAL_PADDING "VPN-4-10", INITIAL_PADDING "VPN-4-11"}},
126 {"xzxzxzxzxz", 1, {"xzxzxzxz"}}, 127 {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,
127 {"xyz*", 2, {"xy", "xyz"}}, 128 {INITIAL_PADDING "aaaaaaaa", INITIAL_PADDING "aaXXyyyc"}},
128 {"ab", 1, {"a"}}, 129 {INITIAL_PADDING "a*", 1, {INITIAL_PADDING "aaaaaaaa"}},
129 {"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"}}, 130 {INITIAL_PADDING "xzxzxzxzxz", 1, {INITIAL_PADDING "xzxzxzxz"}},
130 {"x*|(0|1|2)(a|b|c|d)", 2, {"xxxxxxxx", "0a"}}, 131 {INITIAL_PADDING "xyz*", 1, {INITIAL_PADDING "xyzzzzzz"}},
131 {"(0|1)(0|1)23456789ABC", 1, {"11234567"}}, 132 {INITIAL_PADDING
132 {"0*123456789ABC*", 3, {"00123456", "00000000", "12345678"}}, 133 "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)",
133 {"0123456789A*BC", 1, {"01234567"}}, 134 2, {INITIAL_PADDING "abcd:000", INITIAL_PADDING "abcd:101"}},
134 {"GNUNETVPN000100000IPEX6-fc5a:4e1:c2ba::1", 1, {"GNUNETVP"}} 135 {INITIAL_PADDING "(x*|(0|1|2)(a|b|c|d)+)", 2,
136 {INITIAL_PADDING "xxxxxxxx", INITIAL_PADDING "0abcdbad"}},
137 {INITIAL_PADDING "(0|1)(0|1)23456789ABC", 1, {INITIAL_PADDING "11234567"}},
138 {INITIAL_PADDING "0*123456789ABC*", 3,
139 {INITIAL_PADDING "00123456", INITIAL_PADDING "00000000",
140 INITIAL_PADDING "12345678"}},
141 {INITIAL_PADDING "0123456789A*BC", 1, {INITIAL_PADDING "01234567"}},
142 {"GNUNETVPN000100000IPEX6-fc5a:4e1:c2ba::1", 1, {"GNUNETVPN000100000IPEX6-"}}
135 }; 143 };
136 144
137 const char *graph_start_str = "digraph G {\nrankdir=LR\n"; 145 const char *graph_start_str = "digraph G {\nrankdir=LR\n";
138 const char *graph_end_str = "\n}\n"; 146 const char *graph_end_str = "\n}\n";
139 147
140 for (i = 0; i < 14; i++) 148 for (i = 0; i < 13; i++)
141 { 149 {
150 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iterating DFA for regex %s\n",
151 rxstr[i].regex);
152
153
142 // Create graph 154 // Create graph
143 if (GNUNET_YES == GNUNET_REGEX_ITERATE_SAVE_DEBUG_GRAPH) 155 if (GNUNET_YES == GNUNET_REGEX_ITERATE_SAVE_DEBUG_GRAPH)
144 { 156 {
@@ -171,7 +183,8 @@ main (int argc, char *argv[])
171 ctx.match_count = 0; 183 ctx.match_count = 0;
172 dfa = GNUNET_REGEX_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex)); 184 dfa = GNUNET_REGEX_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex));
173 GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &ctx); 185 GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &ctx);
174 num_transitions = GNUNET_REGEX_get_transition_count (dfa); 186 num_transitions =
187 GNUNET_REGEX_get_transition_count (dfa) - dfa->start->transition_count;
175 188
176 if (transition_counter < num_transitions) 189 if (transition_counter < num_transitions)
177 { 190 {
@@ -179,7 +192,6 @@ main (int argc, char *argv[])
179 "Automaton has %d transitions, iterated over %d transitions\n", 192 "Automaton has %d transitions, iterated over %d transitions\n",
180 num_transitions, transition_counter); 193 num_transitions, transition_counter);
181 error += 1; 194 error += 1;
182 break;
183 } 195 }
184 196
185 if (ctx.match_count < ctx.string_count) 197 if (ctx.match_count < ctx.string_count)
@@ -209,7 +221,7 @@ main (int argc, char *argv[])
209 } 221 }
210 222
211 223
212 for (i = 0; i < 10; i++) 224 for (i = 0; i < 13; i++)
213 { 225 {
214 ctx.string_count = rxstr[i].string_count; 226 ctx.string_count = rxstr[i].string_count;
215 ctx.strings = rxstr[i].strings; 227 ctx.strings = rxstr[i].strings;