aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-07-03 11:01:56 +0000
committerBart Polot <bart@net.in.tum.de>2012-07-03 11:01:56 +0000
commit8829518fefd8621b85140b794ab33215dc7ee1d8 (patch)
treee6fb4970674a7b40a036765a72c366cbe3f221f1 /src/mesh
parent568d10629e917224cb77e7eecde0c4c619334f7f (diff)
downloadgnunet-8829518fefd8621b85140b794ab33215dc7ee1d8.tar.gz
gnunet-8829518fefd8621b85140b794ab33215dc7ee1d8.zip
- added mesh regex testcase, fixed bugs
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/Makefile.am11
-rw-r--r--src/mesh/gnunet-service-mesh_new.c33
-rw-r--r--src/mesh/mesh_api.c2
-rw-r--r--src/mesh/plugin_block_mesh.c2
-rw-r--r--src/mesh/test_mesh_regex.c521
5 files changed, 567 insertions, 2 deletions
diff --git a/src/mesh/Makefile.am b/src/mesh/Makefile.am
index 419ef40f9..77e305b02 100644
--- a/src/mesh/Makefile.am
+++ b/src/mesh/Makefile.am
@@ -98,6 +98,7 @@ check_PROGRAMS = \
98 test_mesh_local_1 \ 98 test_mesh_local_1 \
99 test_mesh_local_2 \ 99 test_mesh_local_2 \
100 test_mesh_2dtorus \ 100 test_mesh_2dtorus \
101 test_mesh_regex \
101 test_mesh_small_unicast \ 102 test_mesh_small_unicast \
102 test_mesh_small_multicast \ 103 test_mesh_small_multicast \
103 test_mesh_small_speed \ 104 test_mesh_small_speed \
@@ -146,6 +147,16 @@ test_mesh_2dtorus_LDADD = \
146 $(top_builddir)/src/util/libgnunetutil.la \ 147 $(top_builddir)/src/util/libgnunetutil.la \
147 $(top_builddir)/src/testing_old/libgnunettesting_old.la 148 $(top_builddir)/src/testing_old/libgnunettesting_old.la
148 149
150test_mesh_regex_SOURCES = \
151 test_mesh_regex.c
152test_mesh_regex_LDADD = \
153 $(top_builddir)/src/mesh/libgnunetmesh.la \
154 $(top_builddir)/src/util/libgnunetutil.la \
155 $(top_builddir)/src/testing_old/libgnunettesting_old.la
156test_mesh_regex_DEPENDENCIES = \
157 libgnunetmesh.la
158
159
149test_mesh_small_unicast_SOURCES = \ 160test_mesh_small_unicast_SOURCES = \
150 test_mesh_small.c 161 test_mesh_small.c
151test_mesh_small_unicast_LDADD = \ 162test_mesh_small_unicast_LDADD = \
diff --git a/src/mesh/gnunet-service-mesh_new.c b/src/mesh/gnunet-service-mesh_new.c
index abec7de1c..0e1eda15c 100644
--- a/src/mesh/gnunet-service-mesh_new.c
+++ b/src/mesh/gnunet-service-mesh_new.c
@@ -708,13 +708,24 @@ regex_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof,
708 size_t size; 708 size_t size;
709 size_t len; 709 size_t len;
710 unsigned int i; 710 unsigned int i;
711 unsigned int offset;
711 char *aux; 712 char *aux;
712 713
714 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
715 " regex dht put for state %s\n",
716 GNUNET_h2s(key));
717 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
718 " proof: %s\n",
719 proof);
720
713 opt = GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE; 721 opt = GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE;
714 if (GNUNET_YES == accepting) 722 if (GNUNET_YES == accepting)
715 { 723 {
716 struct MeshRegexAccept block; 724 struct MeshRegexAccept block;
717 725
726 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
727 " state %s is accepting, putting own id\n",
728 GNUNET_h2s(key));
718 size = sizeof (block); 729 size = sizeof (block);
719 block.key = *key; 730 block.key = *key;
720 block.id = my_full_id; 731 block.id = my_full_id;
@@ -749,11 +760,19 @@ regex_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof,
749 */ 760 */
750 for (i = 0; i < num_edges; i++) 761 for (i = 0; i < num_edges; i++)
751 { 762 {
763 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
764 " edge %s towards %s\n",
765 edges[i].label,
766 GNUNET_h2s(&edges[i].destination));
767
752 /* aux points at the end of the last block */ 768 /* aux points at the end of the last block */
753 block_edge = (struct MeshRegexEdge *) aux;
754 len = strlen (edges[i].label); 769 len = strlen (edges[i].label);
755 size += sizeof (struct MeshRegexEdge) + len; 770 size += sizeof (struct MeshRegexEdge) + len;
771 // Calculate offset FIXME is this ok? use size instead?
772 offset = aux - (char *) block;
756 block = GNUNET_realloc (block, size); 773 block = GNUNET_realloc (block, size);
774 aux = &((char *) block)[offset];
775 block_edge = (struct MeshRegexEdge *) aux;
757 block_edge->key = edges[i].destination; 776 block_edge->key = edges[i].destination;
758 block_edge->n_token = htonl (len); 777 block_edge->n_token = htonl (len);
759 aux = (char *) &block_edge[1]; 778 aux = (char *) &block_edge[1];
@@ -784,9 +803,11 @@ regex_put (const char *regex)
784{ 803{
785 struct GNUNET_REGEX_Automaton *dfa; 804 struct GNUNET_REGEX_Automaton *dfa;
786 805
806 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "regex_put (%s) start\n", regex);
787 dfa = GNUNET_REGEX_construct_dfa (regex, strlen(regex)); 807 dfa = GNUNET_REGEX_construct_dfa (regex, strlen(regex));
788 GNUNET_REGEX_iterate_all_edges (dfa, &regex_iterator, NULL); 808 GNUNET_REGEX_iterate_all_edges (dfa, &regex_iterator, NULL);
789 GNUNET_REGEX_automaton_destroy (dfa); 809 GNUNET_REGEX_automaton_destroy (dfa);
810 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "regex_put (%s) end\n", regex);
790 811
791} 812}
792 813
@@ -4184,6 +4205,14 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp,
4184 size_t len; 4205 size_t len;
4185 4206
4186 // FIXME: does proof have to be NULL terminated? 4207 // FIXME: does proof have to be NULL terminated?
4208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4209 "*******************************\n");
4210 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4211 "DHT GET STRING RETURNED RESULTS\n");
4212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4213 " key: %s\n");
4214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4215 "DHT GET STRING RETURNED RESULTS\n");
4187 proof = (char *) &block[1]; 4216 proof = (char *) &block[1];
4188 if (GNUNET_OK != GNUNET_REGEX_check_proof (proof, key)) 4217 if (GNUNET_OK != GNUNET_REGEX_check_proof (proof, key))
4189 { 4218 {
@@ -4973,7 +5002,7 @@ handle_local_connect_by_string (void *cls, struct GNUNET_SERVER_Client *client,
4973 size_t size; 5002 size_t size;
4974 size_t len; 5003 size_t len;
4975 5004
4976 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connect by string started\n"); 5005 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connect by string started\n");
4977 msg = (struct GNUNET_MESH_ConnectPeerByString *) message; 5006 msg = (struct GNUNET_MESH_ConnectPeerByString *) message;
4978 size = htons (message->size); 5007 size = htons (message->size);
4979 5008
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c
index 8b4efce70..b12fdc1fe 100644
--- a/src/mesh/mesh_api.c
+++ b/src/mesh/mesh_api.c
@@ -27,6 +27,8 @@
27 * - RECEIVE HANDLERS 27 * - RECEIVE HANDLERS
28 * - SEND FUNCTIONS 28 * - SEND FUNCTIONS
29 * - API CALL DEFINITIONS 29 * - API CALL DEFINITIONS
30 *
31 * TODO: add regex to reconnect
30 */ 32 */
31#include "platform.h" 33#include "platform.h"
32#include "gnunet_common.h" 34#include "gnunet_common.h"
diff --git a/src/mesh/plugin_block_mesh.c b/src/mesh/plugin_block_mesh.c
index 6f024845b..1a530cdc0 100644
--- a/src/mesh/plugin_block_mesh.c
+++ b/src/mesh/plugin_block_mesh.c
@@ -209,6 +209,8 @@ libgnunet_plugin_block_mesh_init (void *cls)
209 { 209 {
210 GNUNET_BLOCK_TYPE_MESH_PEER, 210 GNUNET_BLOCK_TYPE_MESH_PEER,
211 GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE, 211 GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE,
212 GNUNET_BLOCK_TYPE_MESH_REGEX,
213 GNUNET_BLOCK_TYPE_MESH_REGEX_ACCEPT,
212 GNUNET_BLOCK_TYPE_ANY /* end of list */ 214 GNUNET_BLOCK_TYPE_ANY /* end of list */
213 }; 215 };
214 struct GNUNET_BLOCK_PluginFunctions *api; 216 struct GNUNET_BLOCK_PluginFunctions *api;
diff --git a/src/mesh/test_mesh_regex.c b/src/mesh/test_mesh_regex.c
new file mode 100644
index 000000000..89539042c
--- /dev/null
+++ b/src/mesh/test_mesh_regex.c
@@ -0,0 +1,521 @@
1/*
2 This file is part of GNUnet.
3 (C) 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 * @file mesh/test_mesh_regex.c
22 *
23 * @brief Test for regex announce / by_string connect.
24 * based on the 2dtorus testcase
25 */
26#include "platform.h"
27#include "gnunet_testing_lib.h"
28#include "gnunet_mesh_service.h"
29
30#define VERBOSE GNUNET_YES
31#define REMOVE_DIR GNUNET_YES
32
33/**
34 * How long until we give up on connecting the peers?
35 */
36#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1500)
37
38/**
39 * Time to wait for stuff that should be rather fast
40 */
41#define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
42
43
44/**
45 * How many events have happened
46 */
47static int ok;
48
49/**
50 * Be verbose
51 */
52static int verbose;
53
54/**
55 * Total number of peers in the test.
56 */
57static unsigned long long num_peers;
58
59/**
60 * Global configuration file
61 */
62static struct GNUNET_CONFIGURATION_Handle *testing_cfg;
63
64/**
65 * Total number of currently running peers.
66 */
67static unsigned long long peers_running;
68
69/**
70 * Total number of successful connections in the whole network.
71 */
72static unsigned int total_connections;
73
74/**
75 * Total number of failed connections in the whole network.
76 */
77static unsigned int failed_connections;
78
79/**
80 * The currently running peer group.
81 */
82static struct GNUNET_TESTING_PeerGroup *pg;
83
84/**
85 * Task called to disconnect peers
86 */
87static GNUNET_SCHEDULER_TaskIdentifier disconnect_task;
88
89/**
90 * Task called to shutdown test.
91 */
92static GNUNET_SCHEDULER_TaskIdentifier shutdown_handle;
93
94
95static struct GNUNET_TESTING_Daemon *d1;
96
97static struct GNUNET_TESTING_Daemon *d2;
98
99static struct GNUNET_MESH_Handle *h1;
100
101static struct GNUNET_MESH_Handle *h2;
102
103static struct GNUNET_MESH_Tunnel *t;
104
105static struct GNUNET_MESH_Tunnel *incoming_t;
106
107/**
108 * Check whether peers successfully shut down.
109 *
110 * @param cls Closure (unused).
111 * @param emsg Error message, NULL on success.
112 */
113static void
114shutdown_callback (void *cls, const char *emsg)
115{
116 if (emsg != NULL)
117 {
118 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
119 "test: Shutdown of peers failed! (%s)\n", emsg);
120 ok--;
121 }
122#if VERBOSE
123 else
124 {
125 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
126 "test: All peers successfully shut down!\n");
127 }
128#endif
129 GNUNET_CONFIGURATION_destroy (testing_cfg);
130}
131
132
133/**
134 * Task to run for shutdown: stops peers, ends test.
135 *
136 * @param cls Closure (not used).
137 * @param tc TaskContext.
138 *
139 */
140static void
141shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
142{
143#if VERBOSE
144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Ending test.\n");
145#endif
146 shutdown_handle = GNUNET_SCHEDULER_NO_TASK;
147 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
148}
149
150
151/**
152 * Ends test: Disconnects peers and calls shutdown.
153 * @param cls Closure (not used).
154 * @param tc TaskContext.
155 */
156static void
157disconnect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
158{
159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: disconnecting peers\n");
160
161 GNUNET_MESH_tunnel_destroy (t);
162 GNUNET_MESH_disconnect (h1);
163 GNUNET_MESH_disconnect (h2);
164 if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle)
165 {
166 GNUNET_SCHEDULER_cancel (shutdown_handle);
167 }
168 shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
169}
170
171/**
172 * Function called whenever an inbound tunnel is destroyed. Should clean up
173 * any associated state.
174 *
175 * @param cls closure (set from GNUNET_MESH_connect)
176 * @param tunnel connection to the other end (henceforth invalid)
177 * @param tunnel_ctx place where local state associated
178 * with the tunnel is stored
179 */
180static void
181tunnel_cleaner (void *cls, const struct GNUNET_MESH_Tunnel *tunnel,
182 void *tunnel_ctx)
183{
184 long i = (long) cls;
185
186 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
187 "Incoming tunnel disconnected at peer %d\n",
188 i);
189 return;
190}
191
192
193/**
194 * Method called whenever a tunnel falls apart.
195 *
196 * @param cls closure
197 * @param peer peer identity the tunnel stopped working with
198 */
199static void
200dh (void *cls, const struct GNUNET_PeerIdentity *peer)
201{
202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
203 "peer %s disconnected\n",
204 GNUNET_i2s (peer));
205 return;
206}
207
208
209/**
210 * Method called whenever a peer connects to a tunnel.
211 *
212 * @param cls closure
213 * @param peer peer identity the tunnel was created to, NULL on timeout
214 * @param atsi performance data for the connection
215 */
216static void
217ch (void *cls, const struct GNUNET_PeerIdentity *peer,
218 const struct GNUNET_ATS_Information *atsi)
219{
220 long i = (long) cls;
221
222 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
223 "************************************************************\n");
224 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
225 "Peer connected: %s\n",
226 GNUNET_i2s (peer));
227
228 if (i != 1L || peer == NULL)
229 ok = 0;
230 else
231 ok = 1;
232 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
233 {
234 GNUNET_SCHEDULER_cancel (disconnect_task);
235 disconnect_task =
236 GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
237 }
238}
239
240/**
241 * Method called whenever another peer has added us to a tunnel
242 * the other peer initiated.
243 *
244 * @param cls closure
245 * @param tunnel new handle to the tunnel
246 * @param initiator peer that started the tunnel
247 * @param atsi performance information for the tunnel
248 * @return initial tunnel context for the tunnel
249 * (can be NULL -- that's not an error)
250 */
251static void *
252incoming_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel,
253 const struct GNUNET_PeerIdentity *initiator,
254 const struct GNUNET_ATS_Information *atsi)
255{
256 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
257 "Incoming tunnel from %s to peer %d\n",
258 GNUNET_i2s (initiator), (long) cls);
259 ok++;
260 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
261 if ((long) cls == 2L)
262 incoming_t = tunnel;
263 else
264 {
265 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
266 "Incoming tunnel for unknown client %lu\n", (long) cls);
267 }
268 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
269 {
270 GNUNET_SCHEDULER_cancel (disconnect_task);
271 disconnect_task =
272 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_peers, NULL);
273 }
274 return NULL;
275}
276
277/**
278 * Function is called whenever a message is received.
279 *
280 * @param cls closure (set from GNUNET_MESH_connect)
281 * @param tunnel connection to the other end
282 * @param tunnel_ctx place to store local state associated with the tunnel
283 * @param sender who sent the message
284 * @param message the actual message
285 * @param atsi performance data for the connection
286 * @return GNUNET_OK to keep the connection open,
287 * GNUNET_SYSERR to close it (signal serious error)
288 */
289int
290data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx,
291 const struct GNUNET_PeerIdentity *sender,
292 const struct GNUNET_MessageHeader *message,
293 const struct GNUNET_ATS_Information *atsi)
294{
295
296 return GNUNET_OK;
297}
298
299/**
300 * Handlers, for diverse services
301 */
302static struct GNUNET_MESH_MessageHandler handlers[] = {
303 {&data_callback, 1, sizeof (struct GNUNET_MessageHeader)},
304 {NULL, 0, 0}
305};
306
307
308/**
309 * peergroup_ready: start test when all peers are connected
310 * @param cls closure
311 * @param emsg error message
312 */
313static void
314peergroup_ready (void *cls, const char *emsg)
315{
316 GNUNET_MESH_ApplicationType app;
317
318 if (emsg != NULL)
319 {
320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
321 "test: Peergroup callback called with error, aborting test!\n");
322 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Error from testing: `%s'\n",
323 emsg);
324 ok--;
325 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
326 return;
327 }
328#if VERBOSE
329 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
330 "************************************************************\n");
331 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
332 "test: Peer Group started successfully!\n");
333 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "test: Have %u connections\n",
334 total_connections);
335#endif
336
337 peers_running = GNUNET_TESTING_daemons_running (pg);
338 if (0 < failed_connections)
339 {
340 ok = GNUNET_SYSERR;
341 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "test: %u connections have FAILED!\n",
342 failed_connections);
343 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
344 return;
345 }
346 ok = 0;
347 disconnect_task =
348 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &disconnect_peers, NULL);
349 d1 = GNUNET_TESTING_daemon_get (pg, 1);
350 d2 = GNUNET_TESTING_daemon_get (pg, 10);
351 app = (GNUNET_MESH_ApplicationType) 0;
352
353 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
354 "************************************************************\n");
355 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
356 "Connect to mesh\n");
357 h1 = GNUNET_MESH_connect (d1->cfg, 5, (void *) 1L,
358 NULL,
359 NULL,
360 handlers,
361 &app);
362 h2 = GNUNET_MESH_connect (d2->cfg, 5, (void *) 2L,
363 &incoming_tunnel,
364 &tunnel_cleaner,
365 handlers,
366 &app);
367 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
368 "************************************************************\n");
369 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
370 "Announce REGEX\n");
371 GNUNET_MESH_announce_regex (h2, "abc");
372
373 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
374 "************************************************************\n");
375 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
376 "Create tunnel & connect by string\n");
377 t = GNUNET_MESH_tunnel_create (h1, NULL, &ch, &dh, NULL);
378 GNUNET_MESH_peer_request_connect_by_string (t, "abc");
379 /* connect handler = success, timeout = error */
380
381}
382
383
384/**
385 * Function that will be called whenever two daemons are connected by
386 * the testing library.
387 *
388 * @param cls closure
389 * @param first peer id for first daemon
390 * @param second peer id for the second daemon
391 * @param distance distance between the connected peers
392 * @param first_cfg config for the first daemon
393 * @param second_cfg config for the second daemon
394 * @param first_daemon handle for the first daemon
395 * @param second_daemon handle for the second daemon
396 * @param emsg error message (NULL on success)
397 */
398static void
399connect_cb (void *cls, const struct GNUNET_PeerIdentity *first,
400 const struct GNUNET_PeerIdentity *second, uint32_t distance,
401 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
402 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
403 struct GNUNET_TESTING_Daemon *first_daemon,
404 struct GNUNET_TESTING_Daemon *second_daemon, const char *emsg)
405{
406 if (emsg == NULL)
407 {
408 total_connections++;
409 }
410 else
411 {
412 failed_connections++;
413 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
414 "test: Problem with new connection (%s)\n", emsg);
415 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: (%s)\n", GNUNET_i2s (first));
416 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: (%s)\n", GNUNET_i2s (second));
417 }
418}
419
420
421/**
422 * run: load configuration options and schedule test to run (start peergroup)
423 * @param cls closure
424 * @param args argv
425 * @param cfgfile configuration file name (can be NULL)
426 * @param cfg configuration handle
427 */
428static void
429run (void *cls, char *const *args, const char *cfgfile,
430 const struct GNUNET_CONFIGURATION_Handle *cfg)
431{
432 struct GNUNET_TESTING_Host *hosts;
433
434 ok = GNUNET_NO;
435 total_connections = 0;
436 failed_connections = 0;
437 testing_cfg = GNUNET_CONFIGURATION_dup (cfg);
438
439 GNUNET_log_setup ("test_mesh_regex",
440#if VERBOSE
441 "DEBUG",
442#else
443 "WARNING",
444#endif
445 NULL);
446
447#if VERBOSE
448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Starting daemons.\n");
449 GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing_old",
450 "use_progressbars", "YES");
451#endif
452
453 if (GNUNET_OK !=
454 GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing_old",
455 "num_peers", &num_peers))
456 {
457 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
458 "Option TESTING:NUM_PEERS is required!\n");
459 return;
460 }
461
462 hosts = GNUNET_TESTING_hosts_load (testing_cfg);
463
464 pg = GNUNET_TESTING_peergroup_start (testing_cfg, num_peers, TIMEOUT,
465 &connect_cb, &peergroup_ready, NULL,
466 hosts);
467 GNUNET_assert (pg != NULL);
468 shutdown_handle =
469 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
470 &shutdown_task, NULL);
471}
472
473
474/**
475 * test_mesh_regex command line options
476 */
477static struct GNUNET_GETOPT_CommandLineOption options[] = {
478 {'V', "verbose", NULL,
479 gettext_noop ("be verbose (print progress information)"),
480 0, &GNUNET_GETOPT_set_one, &verbose},
481 GNUNET_GETOPT_OPTION_END
482};
483
484
485/**
486 * Main: start test
487 */
488int
489main (int argc, char *argv[])
490{
491 char *const argv2[] = {
492 argv[0],
493 "-c",
494 "test_mesh_2dtorus.conf",
495#if VERBOSE
496 "-L",
497 "DEBUG",
498#endif
499 NULL
500 };
501
502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Start\n");
503
504
505 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
506 "test_mesh_regex",
507 gettext_noop ("Test mesh regex integration."),
508 options, &run, NULL);
509#if REMOVE_DIR
510 GNUNET_DISK_directory_remove ("/tmp/test_mesh_2dtorus");
511#endif
512 if (GNUNET_OK != ok)
513 {
514 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "test: FAILED!\n");
515 return 1;
516 }
517 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: success\n");
518 return 0;
519}
520
521/* end of test_mesh_regex.c */