aboutsummaryrefslogtreecommitdiff
path: root/src/regex/test_regex_graph_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/regex/test_regex_graph_api.c')
-rw-r--r--src/regex/test_regex_graph_api.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/regex/test_regex_graph_api.c b/src/regex/test_regex_graph_api.c
index d429025d9..c2c1c74e1 100644
--- a/src/regex/test_regex_graph_api.c
+++ b/src/regex/test_regex_graph_api.c
@@ -37,56 +37,47 @@
37 * 37 *
38 * @return 0 if ok, non 0 on error. 38 * @return 0 if ok, non 0 on error.
39 */ 39 */
40int 40static int
41filecheck (const char *filename) 41filecheck (const char *filename)
42{ 42{
43 int error = 0; 43 int error = 0;
44 FILE *fp = NULL; 44 FILE *fp;
45 45
46 // Check if file was created and delete it again 46 // Check if file was created and delete it again
47 fp = fopen (filename, "r"); 47 if (NULL == (fp = fopen (filename, "r")))
48
49 if (NULL == fp)
50 { 48 {
51 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not find graph %s\n", filename); 49 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not find graph %s\n", filename);
52 return ++error; 50 return 1;
53 } 51 }
54 52
55 fseek (fp, 0L, SEEK_END); 53 GNUNET_break (0 == fseek (fp, 0L, SEEK_END));
56 if (1 > ftell (fp)) 54 if (1 > ftell (fp))
57 { 55 {
58 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 56 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
59 "Graph writing failed, got empty file (%s)!\n", filename); 57 "Graph writing failed, got empty file (%s)!\n",
60 error++; 58 filename);
59 error = 2;
61 } 60 }
62 61
63 error += fclose (fp); 62 GNUNET_assert (0 == fclose (fp));
64 63
65 if (!KEEP_FILES) 64 if (!KEEP_FILES)
66 { 65 {
67 if (0 != unlink (filename)) 66 if (0 != unlink (filename))
68 { 67 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
69 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not remove temp files (%s)\n", 68 "unlink", filename);
70 filename);
71 }
72 } 69 }
73
74
75 return error; 70 return error;
76} 71}
77 72
73
78int 74int
79main (int argc, char *argv[]) 75main (int argc, char *argv[])
80{ 76{
81 GNUNET_log_setup ("test-regex", "WARNING", NULL);
82
83 int error; 77 int error;
84 struct GNUNET_REGEX_Automaton *a; 78 struct GNUNET_REGEX_Automaton *a;
85 unsigned int i; 79 unsigned int i;
86 const char *filename = "test_graph.dot"; 80 const char *filename = "test_graph.dot";
87
88 error = 0;
89
90 const char *regex[12] = { 81 const char *regex[12] = {
91 "ab(c|d)+c*(a(b|c)+d)+(bla)+", 82 "ab(c|d)+c*(a(b|c)+d)+(bla)+",
92 "(bla)*", 83 "(bla)*",
@@ -103,6 +94,8 @@ main (int argc, char *argv[])
103 "PADPADPADPADPADPabcdefghixxxxxxxxxxxxxjklmnop*qstoisdjfguisdfguihsdfgbdsuivggsd" 94 "PADPADPADPADPADPabcdefghixxxxxxxxxxxxxjklmnop*qstoisdjfguisdfguihsdfgbdsuivggsd"
104 }; 95 };
105 96
97 GNUNET_log_setup ("test-regex", "WARNING", NULL);
98 error = 0;
106 for (i = 0; i < 12; i++) 99 for (i = 0; i < 12; i++)
107 { 100 {
108 // Check NFA graph creation 101 // Check NFA graph creation