diff options
Diffstat (limited to 'src/regex/test_regex_integration.c')
-rw-r--r-- | src/regex/test_regex_integration.c | 186 |
1 files changed, 93 insertions, 93 deletions
diff --git a/src/regex/test_regex_integration.c b/src/regex/test_regex_integration.c index f264c4fae..b107c6d09 100644 --- a/src/regex/test_regex_integration.c +++ b/src/regex/test_regex_integration.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file regex/test_regex_integration.c | 21 | * @file regex/test_regex_integration.c |
22 | * @brief base test case for regex integration with VPN; | 22 | * @brief base test case for regex integration with VPN; |
@@ -35,12 +35,12 @@ | |||
35 | /** | 35 | /** |
36 | * How long until we really give up on a particular testcase portion? | 36 | * How long until we really give up on a particular testcase portion? |
37 | */ | 37 | */ |
38 | #define TOTAL_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) | 38 | #define TOTAL_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 600) |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * How long until we give up on any particular operation (and retry)? | 41 | * How long until we give up on any particular operation (and retry)? |
42 | */ | 42 | */ |
43 | #define BASE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) | 43 | #define BASE_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3) |
44 | 44 | ||
45 | 45 | ||
46 | static struct GNUNET_REGEX_Announcement *a4; | 46 | static struct GNUNET_REGEX_Announcement *a4; |
@@ -57,26 +57,26 @@ static struct GNUNET_SCHEDULER_Task *die_task; | |||
57 | 57 | ||
58 | 58 | ||
59 | static void | 59 | static void |
60 | end (void *cls) | 60 | end(void *cls) |
61 | { | 61 | { |
62 | die_task = NULL; | 62 | die_task = NULL; |
63 | GNUNET_REGEX_announce_cancel (a4); | 63 | GNUNET_REGEX_announce_cancel(a4); |
64 | a4 = NULL; | 64 | a4 = NULL; |
65 | GNUNET_REGEX_search_cancel (s4); | 65 | GNUNET_REGEX_search_cancel(s4); |
66 | s4 = NULL; | 66 | s4 = NULL; |
67 | GNUNET_REGEX_announce_cancel (a6); | 67 | GNUNET_REGEX_announce_cancel(a6); |
68 | a6 = NULL; | 68 | a6 = NULL; |
69 | GNUNET_REGEX_search_cancel (s6); | 69 | GNUNET_REGEX_search_cancel(s6); |
70 | s6 = NULL; | 70 | s6 = NULL; |
71 | ok = 0; | 71 | ok = 0; |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | static void | 75 | static void |
76 | end_badly () | 76 | end_badly() |
77 | { | 77 | { |
78 | fprintf (stderr, "%s", "Testcase failed (timeout).\n"); | 78 | fprintf(stderr, "%s", "Testcase failed (timeout).\n"); |
79 | end (NULL); | 79 | end(NULL); |
80 | ok = 1; | 80 | ok = 1; |
81 | } | 81 | } |
82 | 82 | ||
@@ -92,36 +92,36 @@ end_badly () | |||
92 | * @param put_path_length Length of the @a put_path. | 92 | * @param put_path_length Length of the @a put_path. |
93 | */ | 93 | */ |
94 | static void | 94 | static void |
95 | found_cb (void *cls, | 95 | found_cb(void *cls, |
96 | const struct GNUNET_PeerIdentity *id, | 96 | const struct GNUNET_PeerIdentity *id, |
97 | const struct GNUNET_PeerIdentity *get_path, | 97 | const struct GNUNET_PeerIdentity *get_path, |
98 | unsigned int get_path_length, | 98 | unsigned int get_path_length, |
99 | const struct GNUNET_PeerIdentity *put_path, | 99 | const struct GNUNET_PeerIdentity *put_path, |
100 | unsigned int put_path_length) | 100 | unsigned int put_path_length) |
101 | { | 101 | { |
102 | const char *str = cls; | 102 | const char *str = cls; |
103 | static int found; | 103 | static int found; |
104 | 104 | ||
105 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 105 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
106 | "IPv%s-exit found\n", | 106 | "IPv%s-exit found\n", |
107 | str); | 107 | str); |
108 | if (0 == strcmp (str, "4")) | 108 | if (0 == strcmp(str, "4")) |
109 | found |= 4; | 109 | found |= 4; |
110 | if (0 == strcmp (str, "6")) | 110 | if (0 == strcmp(str, "6")) |
111 | found |= 2; | 111 | found |= 2; |
112 | if ((4|2) == found) | 112 | if ((4 | 2) == found) |
113 | { | 113 | { |
114 | GNUNET_SCHEDULER_cancel (die_task); | 114 | GNUNET_SCHEDULER_cancel(die_task); |
115 | die_task = | 115 | die_task = |
116 | GNUNET_SCHEDULER_add_now (&end, NULL); | 116 | GNUNET_SCHEDULER_add_now(&end, NULL); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | static void | 121 | static void |
122 | run (void *cls, | 122 | run(void *cls, |
123 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 123 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
124 | struct GNUNET_TESTING_Peer *peer) | 124 | struct GNUNET_TESTING_Peer *peer) |
125 | { | 125 | { |
126 | char rxstr4[GNUNET_TUN_IPV4_REGEXLEN]; | 126 | char rxstr4[GNUNET_TUN_IPV4_REGEXLEN]; |
127 | char rxstr6[GNUNET_TUN_IPV6_REGEXLEN]; | 127 | char rxstr6[GNUNET_TUN_IPV6_REGEXLEN]; |
@@ -135,72 +135,72 @@ run (void *cls, | |||
135 | struct in6_addr i6; | 135 | struct in6_addr i6; |
136 | 136 | ||
137 | die_task = | 137 | die_task = |
138 | GNUNET_SCHEDULER_add_delayed (TOTAL_TIMEOUT, | 138 | GNUNET_SCHEDULER_add_delayed(TOTAL_TIMEOUT, |
139 | &end_badly, NULL); | 139 | &end_badly, NULL); |
140 | GNUNET_assert (1 == | 140 | GNUNET_assert(1 == |
141 | inet_pton (AF_INET, | 141 | inet_pton(AF_INET, |
142 | "127.0.0.1", | 142 | "127.0.0.1", |
143 | &i4)); | 143 | &i4)); |
144 | GNUNET_assert (1 == | 144 | GNUNET_assert(1 == |
145 | inet_pton (AF_INET6, | 145 | inet_pton(AF_INET6, |
146 | "::1:5", | 146 | "::1:5", |
147 | &i6)); | 147 | &i6)); |
148 | GNUNET_TUN_ipv4toregexsearch (&i4, | 148 | GNUNET_TUN_ipv4toregexsearch(&i4, |
149 | 8080, | 149 | 8080, |
150 | rxstr4); | 150 | rxstr4); |
151 | GNUNET_TUN_ipv6toregexsearch (&i6, | 151 | GNUNET_TUN_ipv6toregexsearch(&i6, |
152 | 8686, | 152 | 8686, |
153 | rxstr6); | 153 | rxstr6); |
154 | GNUNET_asprintf (&ss4, | 154 | GNUNET_asprintf(&ss4, |
155 | "%s%s", | 155 | "%s%s", |
156 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, | 156 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, |
157 | rxstr4); | 157 | rxstr4); |
158 | GNUNET_asprintf (&ss6, | 158 | GNUNET_asprintf(&ss6, |
159 | "%s%s", | 159 | "%s%s", |
160 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, | 160 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, |
161 | rxstr6); | 161 | rxstr6); |
162 | p4r = GNUNET_TUN_ipv4policy2regex ("0.0.0.0/0:!25;"); | 162 | p4r = GNUNET_TUN_ipv4policy2regex("0.0.0.0/0:!25;"); |
163 | p6r = GNUNET_TUN_ipv6policy2regex ("::/0:!25;"); | 163 | p6r = GNUNET_TUN_ipv6policy2regex("::/0:!25;"); |
164 | GNUNET_asprintf (&p4, | 164 | GNUNET_asprintf(&p4, |
165 | "%s%s", | 165 | "%s%s", |
166 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, | 166 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, |
167 | p4r); | 167 | p4r); |
168 | GNUNET_asprintf (&p6, | 168 | GNUNET_asprintf(&p6, |
169 | "%s%s", | 169 | "%s%s", |
170 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, | 170 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, |
171 | p6r); | 171 | p6r); |
172 | GNUNET_free (p4r); | 172 | GNUNET_free(p4r); |
173 | GNUNET_free (p6r); | 173 | GNUNET_free(p6r); |
174 | a4 = GNUNET_REGEX_announce (cfg, | 174 | a4 = GNUNET_REGEX_announce(cfg, |
175 | p4, | 175 | p4, |
176 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 176 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, |
177 | 5), | 177 | 5), |
178 | 1); | 178 | 1); |
179 | a6 = GNUNET_REGEX_announce (cfg, | 179 | a6 = GNUNET_REGEX_announce(cfg, |
180 | p6, | 180 | p6, |
181 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 181 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, |
182 | 5), | 182 | 5), |
183 | 1); | 183 | 1); |
184 | GNUNET_free (p4); | 184 | GNUNET_free(p4); |
185 | GNUNET_free (p6); | 185 | GNUNET_free(p6); |
186 | 186 | ||
187 | s4 = GNUNET_REGEX_search (cfg, | 187 | s4 = GNUNET_REGEX_search(cfg, |
188 | ss4, | 188 | ss4, |
189 | &found_cb, "4"); | 189 | &found_cb, "4"); |
190 | s6 = GNUNET_REGEX_search (cfg, | 190 | s6 = GNUNET_REGEX_search(cfg, |
191 | ss6, | 191 | ss6, |
192 | &found_cb, "6"); | 192 | &found_cb, "6"); |
193 | GNUNET_free (ss4); | 193 | GNUNET_free(ss4); |
194 | GNUNET_free (ss6); | 194 | GNUNET_free(ss6); |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | int | 198 | int |
199 | main (int argc, char *argv[]) | 199 | main(int argc, char *argv[]) |
200 | { | 200 | { |
201 | if (0 != GNUNET_TESTING_peer_run ("test-regex-integration", | 201 | if (0 != GNUNET_TESTING_peer_run("test-regex-integration", |
202 | "test_regex_api_data.conf", | 202 | "test_regex_api_data.conf", |
203 | &run, NULL)) | 203 | &run, NULL)) |
204 | return 1; | 204 | return 1; |
205 | return ok; | 205 | return ok; |
206 | } | 206 | } |