aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-06-20 08:55:56 +0000
committerChristian Grothoff <christian@grothoff.org>2013-06-20 08:55:56 +0000
commit5f7a6c8f6816a826a2dd93eadc5039733f7db606 (patch)
tree3c22c8ff3436cc3140dfb1b24813ed4362330879 /src
parent21a2b4f95b4488645ba5a6254fcb8919c4915f73 (diff)
downloadgnunet-5f7a6c8f6816a826a2dd93eadc5039733f7db606.tar.gz
gnunet-5f7a6c8f6816a826a2dd93eadc5039733f7db606.zip
moving functions for testing and evaluation and experiments to the test library, minimizing the internal library, renaming files according to which library they belong to
Diffstat (limited to 'src')
-rw-r--r--src/regex/Makefile.am13
-rw-r--r--src/regex/regex_internal.c (renamed from src/regex/regex.c)2
-rw-r--r--src/regex/regex_internal.h29
-rw-r--r--src/regex/regex_internal_dht.c (renamed from src/regex/regex_dht.c)10
-rw-r--r--src/regex/regex_internal_lib.h43
-rw-r--r--src/regex/regex_test_graph.c (renamed from src/regex/regex_graph.c)3
-rw-r--r--src/regex/regex_test_lib.h79
-rw-r--r--src/regex/regex_test_random.c (renamed from src/regex/regex_random.c)7
-rw-r--r--src/regex/test_regex_eval_api.c1
-rw-r--r--src/regex/test_regex_graph_api.c1
-rw-r--r--src/regex/test_regex_proofs.c1
11 files changed, 99 insertions, 90 deletions
diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am
index 6e6fd443a..34ef90ca0 100644
--- a/src/regex/Makefile.am
+++ b/src/regex/Makefile.am
@@ -55,9 +55,9 @@ libgnunetregexblock_la_LDFLAGS = \
55 55
56 56
57libgnunetregex_internal_a_SOURCES = \ 57libgnunetregex_internal_a_SOURCES = \
58 regex_internal.h regex.c \ 58 regex_internal_lib.h \
59 regex_graph.c regex_random.c \ 59 regex_internal.h regex_internal.c \
60 regex_dht.c 60 regex_internal_dht.c
61libgnunetregex_internal_a_DEPENDENCIES = \ 61libgnunetregex_internal_a_DEPENDENCIES = \
62 libgnunetregexblock.la 62 libgnunetregexblock.la
63 63
@@ -100,7 +100,9 @@ gnunet_regex_simulation_profiler_DEPENDENCIES = \
100endif 100endif
101 101
102libgnunetregextest_a_SOURCES = \ 102libgnunetregextest_a_SOURCES = \
103 regex_test_lib.c regex_test_lib.h 103 regex_test_lib.c regex_test_lib.h \
104 regex_test_graph.c \
105 regex_test_random.c
104libgnunetregextest_a_LIBADD = \ 106libgnunetregextest_a_LIBADD = \
105 $(top_builddir)/src/util/libgnunetutil.la \ 107 $(top_builddir)/src/util/libgnunetutil.la \
106 $(top_builddir)/src/regex/libgnunetregex_internal.a 108 $(top_builddir)/src/regex/libgnunetregex_internal.a
@@ -172,6 +174,7 @@ test_regex_eval_api_SOURCES = \
172 test_regex_eval_api.c 174 test_regex_eval_api.c
173test_regex_eval_api_LDADD = -lm \ 175test_regex_eval_api_LDADD = -lm \
174 $(top_builddir)/src/regex/libgnunetregex_internal.a \ 176 $(top_builddir)/src/regex/libgnunetregex_internal.a \
177 $(top_builddir)/src/regex/libgnunetregextest.a \
175 $(top_builddir)/src/regex/libgnunetregexblock.la \ 178 $(top_builddir)/src/regex/libgnunetregexblock.la \
176 $(top_builddir)/src/util/libgnunetutil.la 179 $(top_builddir)/src/util/libgnunetutil.la
177 180
@@ -186,6 +189,7 @@ test_regex_proofs_SOURCES = \
186 test_regex_proofs.c 189 test_regex_proofs.c
187test_regex_proofs_LDADD = -lm \ 190test_regex_proofs_LDADD = -lm \
188 $(top_builddir)/src/regex/libgnunetregex_internal.a \ 191 $(top_builddir)/src/regex/libgnunetregex_internal.a \
192 $(top_builddir)/src/regex/libgnunetregextest.a \
189 $(top_builddir)/src/regex/libgnunetregexblock.la \ 193 $(top_builddir)/src/regex/libgnunetregexblock.la \
190 $(top_builddir)/src/util/libgnunetutil.la 194 $(top_builddir)/src/util/libgnunetutil.la
191 195
@@ -193,6 +197,7 @@ test_regex_graph_api_SOURCES = \
193 test_regex_graph_api.c 197 test_regex_graph_api.c
194test_regex_graph_api_LDADD = -lm \ 198test_regex_graph_api_LDADD = -lm \
195 $(top_builddir)/src/regex/libgnunetregex_internal.a \ 199 $(top_builddir)/src/regex/libgnunetregex_internal.a \
200 $(top_builddir)/src/regex/libgnunetregextest.a \
196 $(top_builddir)/src/regex/libgnunetregexblock.la \ 201 $(top_builddir)/src/regex/libgnunetregexblock.la \
197 $(top_builddir)/src/util/libgnunetutil.la 202 $(top_builddir)/src/util/libgnunetutil.la
198 203
diff --git a/src/regex/regex.c b/src/regex/regex_internal.c
index ecb3044e3..e66835134 100644
--- a/src/regex/regex.c
+++ b/src/regex/regex_internal.c
@@ -18,7 +18,7 @@
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20/** 20/**
21 * @file src/regex/regex.c 21 * @file src/regex/regex_internal.c
22 * @brief library to create Deterministic Finite Automatons (DFAs) from regular 22 * @brief library to create Deterministic Finite Automatons (DFAs) from regular
23 * expressions (regexes). 23 * expressions (regexes).
24 * @author Maximilian Szengel 24 * @author Maximilian Szengel
diff --git a/src/regex/regex_internal.h b/src/regex/regex_internal.h
index 17f5f8419..cd76c1c73 100644
--- a/src/regex/regex_internal.h
+++ b/src/regex/regex_internal.h
@@ -444,35 +444,6 @@ REGEX_ITERNAL_dfa_add_multi_strides (struct REGEX_ITERNAL_Context *regex_ctx,
444 const unsigned int stride_len); 444 const unsigned int stride_len);
445 445
446 446
447/**
448 * Generate a (pseudo) random regular expression of length 'rx_length', as well
449 * as a (optional) string that will be matched by the generated regex. The
450 * returned regex needs to be freed.
451 *
452 * @param rx_length length of the random regex.
453 * @param matching_str (optional) pointer to a string that will contain a string
454 * that will be matched by the generated regex, if
455 * 'matching_str' pointer was not NULL.
456 *
457 * @return NULL if 'rx_length' is 0, a random regex of length 'rx_length', which
458 * needs to be freed, otherwise.
459 */
460char *
461REGEX_ITERNAL_generate_random_regex (size_t rx_length, char *matching_str);
462
463
464/**
465 * Generate a random string of maximum length 'max_len' that only contains literals allowed
466 * in a regular expression. The string might be 0 chars long but is garantueed
467 * to be shorter or equal to 'max_len'.
468 *
469 * @param max_len maximum length of the string that should be generated.
470 *
471 * @return random string that needs to be freed.
472 */
473char *
474REGEX_ITERNAL_generate_random_string (size_t max_len);
475
476 447
477#if 0 /* keep Emacsens' auto-indent happy */ 448#if 0 /* keep Emacsens' auto-indent happy */
478{ 449{
diff --git a/src/regex/regex_dht.c b/src/regex/regex_internal_dht.c
index 1cc4107e8..0b5d99928 100644
--- a/src/regex/regex_dht.c
+++ b/src/regex/regex_internal_dht.c
@@ -18,7 +18,7 @@
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20/** 20/**
21 * @file src/regex/regex_dht.c 21 * @file src/regex/regex_internal_dht.c
22 * @brief library to announce regexes in the network and match strings 22 * @brief library to announce regexes in the network and match strings
23 * against published regexes. 23 * against published regexes.
24 * @author Bartlomiej Polot 24 * @author Bartlomiej Polot
@@ -204,6 +204,7 @@ REGEX_ITERNAL_announce (struct GNUNET_DHT_Handle *dht,
204 return h; 204 return h;
205} 205}
206 206
207
207void 208void
208REGEX_ITERNAL_reannounce (struct REGEX_ITERNAL_Announcement *h) 209REGEX_ITERNAL_reannounce (struct REGEX_ITERNAL_Announcement *h)
209{ 210{
@@ -213,6 +214,7 @@ REGEX_ITERNAL_reannounce (struct REGEX_ITERNAL_Announcement *h)
213 REGEX_ITERNAL_iterate_all_edges (h->dfa, &regex_iterator, h); 214 REGEX_ITERNAL_iterate_all_edges (h->dfa, &regex_iterator, h);
214} 215}
215 216
217
216void 218void
217REGEX_ITERNAL_announce_cancel (struct REGEX_ITERNAL_Announcement *h) 219REGEX_ITERNAL_announce_cancel (struct REGEX_ITERNAL_Announcement *h)
218{ 220{
@@ -365,10 +367,9 @@ dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp,
365 &block->id, 367 &block->id,
366 get_path, get_path_length, 368 get_path, get_path_length,
367 put_path, put_path_length); 369 put_path, put_path_length);
368
369 return;
370} 370}
371 371
372
372/** 373/**
373 * Find a path to a peer that offers a regex servcie compatible 374 * Find a path to a peer that offers a regex servcie compatible
374 * with a given string. 375 * with a given string.
@@ -485,10 +486,7 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp,
485 } 486 }
486 return; 487 return;
487 } 488 }
488
489 regex_next_edge (block, size, ctx); 489 regex_next_edge (block, size, ctx);
490
491 return;
492} 490}
493 491
494 492
diff --git a/src/regex/regex_internal_lib.h b/src/regex/regex_internal_lib.h
index f14665538..e138535d4 100644
--- a/src/regex/regex_internal_lib.h
+++ b/src/regex/regex_internal_lib.h
@@ -21,7 +21,6 @@
21 * @file regex/regex_internal_lib.h 21 * @file regex/regex_internal_lib.h
22 * @brief library to parse regular expressions into dfa 22 * @brief library to parse regular expressions into dfa
23 * @author Maximilian Szengel 23 * @author Maximilian Szengel
24 *
25 */ 24 */
26 25
27#ifndef REGEX_INTERNAL_LIB_H 26#ifndef REGEX_INTERNAL_LIB_H
@@ -40,11 +39,9 @@ extern "C"
40#endif 39#endif
41 40
42 41
43
44
45/** 42/**
46 * Automaton (NFA/DFA) representation. 43 * Automaton (NFA/DFA) representation.
47- */ 44 */
48struct REGEX_ITERNAL_Automaton; 45struct REGEX_ITERNAL_Automaton;
49 46
50 47
@@ -98,44 +95,6 @@ REGEX_ITERNAL_automaton_destroy (struct REGEX_ITERNAL_Automaton *a);
98 95
99 96
100/** 97/**
101 * Options for graph creation function
102 * REGEX_ITERNAL_automaton_save_graph.
103 */
104enum REGEX_ITERNAL_GraphSavingOptions
105{
106 /**
107 * Default. Do nothing special.
108 */
109 REGEX_ITERNAL_GRAPH_DEFAULT = 0,
110
111 /**
112 * The generated graph will include extra information such as the NFA states
113 * that were used to generate the DFA state.
114 */
115 REGEX_ITERNAL_GRAPH_VERBOSE = 1,
116
117 /**
118 * Enable graph coloring. Will color each SCC in a different color.
119 */
120 REGEX_ITERNAL_GRAPH_COLORING = 2
121};
122
123
124/**
125 * Save the given automaton as a GraphViz dot file.
126 *
127 * @param a the automaton to be saved.
128 * @param filename where to save the file.
129 * @param options options for graph generation that include coloring or verbose
130 * mode
131 */
132void
133REGEX_ITERNAL_automaton_save_graph (struct REGEX_ITERNAL_Automaton *a,
134 const char *filename,
135 enum REGEX_ITERNAL_GraphSavingOptions options);
136
137
138/**
139 * Evaluates the given 'string' against the given compiled regex. 98 * Evaluates the given 'string' against the given compiled regex.
140 * 99 *
141 * @param a automaton. 100 * @param a automaton.
diff --git a/src/regex/regex_graph.c b/src/regex/regex_test_graph.c
index 4789fd635..369356aa1 100644
--- a/src/regex/regex_graph.c
+++ b/src/regex/regex_test_graph.c
@@ -18,12 +18,13 @@
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20/** 20/**
21 * @file src/regex/regex_graph.c 21 * @file src/regex/regex_test_graph.c
22 * @brief functions for creating .dot graphs from regexes 22 * @brief functions for creating .dot graphs from regexes
23 * @author Maximilian Szengel 23 * @author Maximilian Szengel
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "regex_internal_lib.h" 26#include "regex_internal_lib.h"
27#include "regex_test_lib.h"
27#include "regex_internal.h" 28#include "regex_internal.h"
28 29
29/** 30/**
diff --git a/src/regex/regex_test_lib.h b/src/regex/regex_test_lib.h
index 418f47dba..107c2ffce 100644
--- a/src/regex/regex_test_lib.h
+++ b/src/regex/regex_test_lib.h
@@ -20,15 +20,15 @@
20/** 20/**
21 * @file src/regex/regex_test_lib.h 21 * @file src/regex/regex_test_lib.h
22 * @brief library to read regexes representing IP networks from a file. 22 * @brief library to read regexes representing IP networks from a file.
23 * and simplyfinying the into one big regex, in order to run 23 * and simplifying the into one big regex, in order to run
24 * tests (regex performance, mesh profiler). 24 * tests (regex performance, regex profiler).
25 * @author Bertlomiej Polot 25 * @author Bertlomiej Polot
26 *
27 */ 26 */
28 27
29#ifndef REGEX_ITERNAL_TEST_LIB_H 28#ifndef REGEX_ITERNAL_TEST_LIB_H
30#define REGEX_ITERNAL_TEST_LIB_H 29#define REGEX_ITERNAL_TEST_LIB_H
31 30
31#include "regex_internal_lib.h"
32 32
33#ifdef __cplusplus 33#ifdef __cplusplus
34extern "C" 34extern "C"
@@ -48,6 +48,7 @@ extern "C"
48char * 48char *
49REGEX_ITERNAL_combine(char * const regexes[]); 49REGEX_ITERNAL_combine(char * const regexes[]);
50 50
51
51/** 52/**
52 * Read a set of regexes from a file, one per line and return them in an array 53 * Read a set of regexes from a file, one per line and return them in an array
53 * suitable for REGEX_ITERNAL_combine. 54 * suitable for REGEX_ITERNAL_combine.
@@ -69,6 +70,76 @@ REGEX_ITERNAL_read_from_file (const char *filename);
69void 70void
70REGEX_ITERNAL_free_from_file (char **regexes); 71REGEX_ITERNAL_free_from_file (char **regexes);
71 72
73
74/**
75 * Generate a (pseudo) random regular expression of length 'rx_length', as well
76 * as a (optional) string that will be matched by the generated regex. The
77 * returned regex needs to be freed.
78 *
79 * @param rx_length length of the random regex.
80 * @param matching_str (optional) pointer to a string that will contain a string
81 * that will be matched by the generated regex, if
82 * 'matching_str' pointer was not NULL.
83 *
84 * @return NULL if 'rx_length' is 0, a random regex of length 'rx_length', which
85 * needs to be freed, otherwise.
86 */
87char *
88REGEX_ITERNAL_generate_random_regex (size_t rx_length, char *matching_str);
89
90
91/**
92 * Generate a random string of maximum length 'max_len' that only contains literals allowed
93 * in a regular expression. The string might be 0 chars long but is garantueed
94 * to be shorter or equal to 'max_len'.
95 *
96 * @param max_len maximum length of the string that should be generated.
97 *
98 * @return random string that needs to be freed.
99 */
100char *
101REGEX_ITERNAL_generate_random_string (size_t max_len);
102
103
104/**
105 * Options for graph creation function
106 * REGEX_ITERNAL_automaton_save_graph.
107 */
108enum REGEX_ITERNAL_GraphSavingOptions
109{
110 /**
111 * Default. Do nothing special.
112 */
113 REGEX_ITERNAL_GRAPH_DEFAULT = 0,
114
115 /**
116 * The generated graph will include extra information such as the NFA states
117 * that were used to generate the DFA state.
118 */
119 REGEX_ITERNAL_GRAPH_VERBOSE = 1,
120
121 /**
122 * Enable graph coloring. Will color each SCC in a different color.
123 */
124 REGEX_ITERNAL_GRAPH_COLORING = 2
125};
126
127
128/**
129 * Save the given automaton as a GraphViz dot file.
130 *
131 * @param a the automaton to be saved.
132 * @param filename where to save the file.
133 * @param options options for graph generation that include coloring or verbose
134 * mode
135 */
136void
137REGEX_ITERNAL_automaton_save_graph (struct REGEX_ITERNAL_Automaton *a,
138 const char *filename,
139 enum REGEX_ITERNAL_GraphSavingOptions options);
140
141
142
72#if 0 /* keep Emacsens' auto-indent happy */ 143#if 0 /* keep Emacsens' auto-indent happy */
73{ 144{
74 #endif 145 #endif
@@ -77,4 +148,4 @@ REGEX_ITERNAL_free_from_file (char **regexes);
77#endif 148#endif
78 149
79/* end of regex_internal_lib.h */ 150/* end of regex_internal_lib.h */
80#endif \ No newline at end of file 151#endif
diff --git a/src/regex/regex_random.c b/src/regex/regex_test_random.c
index 6093ed2eb..00e4c21b3 100644
--- a/src/regex/regex_random.c
+++ b/src/regex/regex_test_random.c
@@ -18,12 +18,12 @@
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20/** 20/**
21 * @file src/regex/regex_random.c 21 * @file src/regex/regex_test_random.c
22 * @brief functions for creating random regular expressions and strings 22 * @brief functions for creating random regular expressions and strings
23 * @author Maximilian Szengel 23 * @author Maximilian Szengel
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "regex_internal_lib.h" 26#include "regex_test_lib.h"
27#include "gnunet_crypto_lib.h" 27#include "gnunet_crypto_lib.h"
28#include "regex_internal.h" 28#include "regex_internal.h"
29 29
@@ -33,7 +33,7 @@
33 * 33 *
34 * @return random valid literal 34 * @return random valid literal
35 */ 35 */
36char 36static char
37get_random_literal () 37get_random_literal ()
38{ 38{
39 uint32_t ridx; 39 uint32_t ridx;
@@ -137,6 +137,7 @@ REGEX_ITERNAL_generate_random_regex (size_t rx_length, char *matching_str)
137 return rx; 137 return rx;
138} 138}
139 139
140
140/** 141/**
141 * Generate a random string of maximum length 'max_len' that only contains literals allowed 142 * Generate a random string of maximum length 'max_len' that only contains literals allowed
142 * in a regular expression. The string might be 0 chars long but is garantueed 143 * in a regular expression. The string might be 0 chars long but is garantueed
diff --git a/src/regex/test_regex_eval_api.c b/src/regex/test_regex_eval_api.c
index 8cdefb17d..3ab914dc1 100644
--- a/src/regex/test_regex_eval_api.c
+++ b/src/regex/test_regex_eval_api.c
@@ -26,6 +26,7 @@
26#include <time.h> 26#include <time.h>
27#include "platform.h" 27#include "platform.h"
28#include "regex_internal_lib.h" 28#include "regex_internal_lib.h"
29#include "regex_test_lib.h"
29#include "regex_internal.h" 30#include "regex_internal.h"
30 31
31enum Match_Result 32enum Match_Result
diff --git a/src/regex/test_regex_graph_api.c b/src/regex/test_regex_graph_api.c
index 303a0ce07..a0d44fb2f 100644
--- a/src/regex/test_regex_graph_api.c
+++ b/src/regex/test_regex_graph_api.c
@@ -26,6 +26,7 @@
26#include <time.h> 26#include <time.h>
27#include "platform.h" 27#include "platform.h"
28#include "regex_internal_lib.h" 28#include "regex_internal_lib.h"
29#include "regex_test_lib.h"
29#include "regex_internal.h" 30#include "regex_internal.h"
30 31
31#define KEEP_FILES 1 32#define KEEP_FILES 1
diff --git a/src/regex/test_regex_proofs.c b/src/regex/test_regex_proofs.c
index f5bac0ad7..d7c743c77 100644
--- a/src/regex/test_regex_proofs.c
+++ b/src/regex/test_regex_proofs.c
@@ -24,6 +24,7 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "regex_internal_lib.h" 26#include "regex_internal_lib.h"
27#include "regex_test_lib.h"
27#include "regex_internal.h" 28#include "regex_internal.h"
28 29
29 30