diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-10-17 17:39:07 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-10-17 17:39:07 +0000 |
commit | 01781755ebd04188e8059184eb328a9c375d4da6 (patch) | |
tree | 90f9e1daf0642d1f30a2ea73e5ef0c139a0e110b /src/regex | |
parent | f9e6c67a3f1bf54c892cafa5aae454d9d0883d6e (diff) | |
download | gnunet-01781755ebd04188e8059184eb328a9c375d4da6.tar.gz gnunet-01781755ebd04188e8059184eb328a9c375d4da6.zip |
Moved regex profiler to mesh, because of dependencies.
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/Makefile.am | 13 | ||||
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 761 | ||||
-rw-r--r-- | src/regex/regex_profiler_test.conf | 87 |
3 files changed, 0 insertions, 861 deletions
diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am index a0595fccb..212e2ffcd 100644 --- a/src/regex/Makefile.am +++ b/src/regex/Makefile.am | |||
@@ -19,19 +19,6 @@ libgnunetregex_la_LDFLAGS = \ | |||
19 | $(GN_LIB_LDFLAGS) \ | 19 | $(GN_LIB_LDFLAGS) \ |
20 | -version-info 0:0:0 | 20 | -version-info 0:0:0 |
21 | 21 | ||
22 | noinst_PROGRAMS = \ | ||
23 | gnunet-regex-profiler | ||
24 | |||
25 | gnunet_regex_profiler_SOURCES = \ | ||
26 | gnunet-regex-profiler.c | ||
27 | gnunet_regex_profiler_LDADD = \ | ||
28 | $(top_builddir)/src/regex/libgnunetregex.la \ | ||
29 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
30 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
31 | $(top_builddir)/src/mesh/libgnunetmesh.la | ||
32 | gnunet_regex_profiler_DEPENDENCIES = \ | ||
33 | libgnunetregex.la | ||
34 | |||
35 | check_PROGRAMS = \ | 22 | check_PROGRAMS = \ |
36 | test_regex_eval_api \ | 23 | test_regex_eval_api \ |
37 | test_regex_iterate_api \ | 24 | test_regex_iterate_api \ |
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c deleted file mode 100644 index 2dc369841..000000000 --- a/src/regex/gnunet-regex-profiler.c +++ /dev/null | |||
@@ -1,761 +0,0 @@ | |||
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 Regex profiler for testing distributed regex use. | ||
24 | * @author Bart Polot | ||
25 | * @author Max Szengel | ||
26 | */ | ||
27 | |||
28 | #include <string.h> | ||
29 | |||
30 | #include "platform.h" | ||
31 | #include "gnunet_applications.h" | ||
32 | #include "gnunet_util_lib.h" | ||
33 | #include "gnunet_mesh_service.h" | ||
34 | #include "gnunet_stream_lib.h" | ||
35 | #include "gnunet_testbed_service.h" | ||
36 | |||
37 | |||
38 | /** | ||
39 | * Total number of hosts. | ||
40 | */ | ||
41 | #define NUM_HOSTS 2 | ||
42 | |||
43 | /** | ||
44 | * Number of peers per host. | ||
45 | */ | ||
46 | #define PEER_PER_HOST 1 | ||
47 | |||
48 | /** | ||
49 | * Total number of peers. | ||
50 | */ | ||
51 | #define TOTAL_PEERS (NUM_HOSTS * PEER_PER_HOST) | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Different states in test setup | ||
56 | */ | ||
57 | enum SetupState | ||
58 | { | ||
59 | /** | ||
60 | * The initial state | ||
61 | */ | ||
62 | INIT, | ||
63 | |||
64 | /** | ||
65 | * Connecting to slave controller | ||
66 | */ | ||
67 | LINKING, | ||
68 | |||
69 | LINKING_SLAVES, | ||
70 | |||
71 | LINKING_SLAVES_SUCCESS, | ||
72 | |||
73 | CONNECTING_PEERS, | ||
74 | |||
75 | CREATING_PEER, | ||
76 | |||
77 | STARTING_PEER | ||
78 | }; | ||
79 | |||
80 | |||
81 | /** | ||
82 | * Event Mask for operation callbacks | ||
83 | */ | ||
84 | uint64_t event_mask; | ||
85 | |||
86 | /** | ||
87 | * Testbed operation handle | ||
88 | */ | ||
89 | static struct GNUNET_TESTBED_Operation *op[NUM_HOSTS]; | ||
90 | |||
91 | /** | ||
92 | * Setup state. | ||
93 | */ | ||
94 | static enum SetupState state[NUM_HOSTS]; | ||
95 | |||
96 | /** | ||
97 | * Abort task. | ||
98 | */ | ||
99 | static GNUNET_SCHEDULER_TaskIdentifier abort_task; | ||
100 | |||
101 | /** | ||
102 | * Global test result | ||
103 | */ | ||
104 | static int result; | ||
105 | |||
106 | /** | ||
107 | * Hosts successfully registered | ||
108 | */ | ||
109 | static unsigned int host_registered; | ||
110 | |||
111 | /** | ||
112 | * Peers successfully started | ||
113 | */ | ||
114 | static unsigned int peers_started; | ||
115 | |||
116 | /** | ||
117 | * The master controller host | ||
118 | */ | ||
119 | struct GNUNET_TESTBED_Host *master_host; | ||
120 | |||
121 | /** | ||
122 | * The master controller process | ||
123 | */ | ||
124 | static struct GNUNET_TESTBED_ControllerProc *master_proc; | ||
125 | |||
126 | /** | ||
127 | * Handle to master controller | ||
128 | */ | ||
129 | static struct GNUNET_TESTBED_Controller *master_ctrl; | ||
130 | |||
131 | |||
132 | /** | ||
133 | * Slave host registration handles | ||
134 | */ | ||
135 | static struct GNUNET_TESTBED_HostRegistrationHandle *rh; | ||
136 | |||
137 | |||
138 | /** | ||
139 | * Handle to global configuration | ||
140 | */ | ||
141 | static struct GNUNET_CONFIGURATION_Handle *cfg; | ||
142 | |||
143 | /** | ||
144 | * Structure for storing host handles | ||
145 | */ | ||
146 | struct Host | ||
147 | { | ||
148 | /** | ||
149 | * IP address of this host. | ||
150 | */ | ||
151 | char *ip; | ||
152 | |||
153 | /** | ||
154 | * Host handle. | ||
155 | */ | ||
156 | struct GNUNET_TESTBED_Host *host; | ||
157 | |||
158 | /** | ||
159 | * Registration state of this host. | ||
160 | */ | ||
161 | int host_registered; | ||
162 | |||
163 | /** | ||
164 | * Operation handle. | ||
165 | */ | ||
166 | struct GNUNET_TESTBED_Operation *op; | ||
167 | |||
168 | /** | ||
169 | * Host state. | ||
170 | */ | ||
171 | enum SetupState state; | ||
172 | }; | ||
173 | |||
174 | /** | ||
175 | * List of slaves. | ||
176 | */ | ||
177 | static struct Host slaves[NUM_HOSTS] = { {"192.168.1.33", NULL, 0, NULL, INIT}, | ||
178 | {"192.168.1.34", NULL, 0, NULL, INIT} | ||
179 | }; | ||
180 | |||
181 | /** | ||
182 | * Structure for holding peer's handles. | ||
183 | */ | ||
184 | struct PeerData | ||
185 | { | ||
186 | /** | ||
187 | * Handle to testbed peer. | ||
188 | */ | ||
189 | struct GNUNET_TESTBED_Peer *peer; | ||
190 | |||
191 | /** | ||
192 | * Peer's mesh handle. | ||
193 | */ | ||
194 | struct GNUNET_MESH_Handle *mesh_handle; | ||
195 | |||
196 | /** | ||
197 | * The service connect operation to stream | ||
198 | */ | ||
199 | struct GNUNET_TESTBED_Operation *op; | ||
200 | |||
201 | /** | ||
202 | * Peer setup state. | ||
203 | */ | ||
204 | enum SetupState state; | ||
205 | |||
206 | /** | ||
207 | * Our Peer id | ||
208 | */ | ||
209 | struct GNUNET_PeerIdentity our_id; | ||
210 | }; | ||
211 | |||
212 | /** | ||
213 | * The peers | ||
214 | */ | ||
215 | struct PeerData peers[TOTAL_PEERS]; | ||
216 | |||
217 | |||
218 | |||
219 | /** | ||
220 | * Close sockets and stop testing deamons nicely | ||
221 | */ | ||
222 | void | ||
223 | do_close (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
224 | { | ||
225 | unsigned int i; | ||
226 | |||
227 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) | ||
228 | GNUNET_SCHEDULER_cancel (abort_task); | ||
229 | |||
230 | for (i = 0; i < TOTAL_PEERS; i++) | ||
231 | { | ||
232 | if (NULL != peers[i].mesh_handle) | ||
233 | GNUNET_MESH_disconnect (peers[i].mesh_handle); | ||
234 | if (NULL != peers[i].op) | ||
235 | GNUNET_TESTBED_operation_done (peers[i].op); | ||
236 | } | ||
237 | |||
238 | GNUNET_SCHEDULER_shutdown (); /* For shutting down testbed */ | ||
239 | } | ||
240 | |||
241 | |||
242 | /** | ||
243 | * Something went wrong and timed out. Kill everything and set error flag. | ||
244 | * | ||
245 | * @param cls close. | ||
246 | * @param tc task context. | ||
247 | */ | ||
248 | static void | ||
249 | do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
250 | { | ||
251 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: ABORT\n"); | ||
252 | result = GNUNET_SYSERR; | ||
253 | abort_task = 0; | ||
254 | } | ||
255 | |||
256 | |||
257 | /** | ||
258 | * Method called whenever another peer has added us to a tunnel | ||
259 | * the other peer initiated. | ||
260 | * Only called (once) upon reception of data with a message type which was | ||
261 | * subscribed to in GNUNET_MESH_connect. A call to GNUNET_MESH_tunnel_destroy | ||
262 | * causes te tunnel to be ignored and no further notifications are sent about | ||
263 | * the same tunnel. | ||
264 | * | ||
265 | * @param cls closure | ||
266 | * @param tunnel new handle to the tunnel | ||
267 | * @param initiator peer that started the tunnel | ||
268 | * @param atsi performance information for the tunnel | ||
269 | * @return initial tunnel context for the tunnel | ||
270 | * (can be NULL -- that's not an error) | ||
271 | */ | ||
272 | void * | ||
273 | mesh_inbound_tunnel_handler (void *cls, struct GNUNET_MESH_Tunnel *tunnel, | ||
274 | const struct GNUNET_PeerIdentity *initiator, | ||
275 | const struct GNUNET_ATS_Information *atsi) | ||
276 | { | ||
277 | return NULL; | ||
278 | } | ||
279 | |||
280 | |||
281 | /** | ||
282 | * Function called whenever an inbound tunnel is destroyed. Should clean up | ||
283 | * any associated state. This function is NOT called if the client has | ||
284 | * explicitly asked for the tunnel to be destroyed using | ||
285 | * GNUNET_MESH_tunnel_destroy. It must NOT call GNUNET_MESH_tunnel_destroy on | ||
286 | * the tunnel. | ||
287 | * | ||
288 | * @param cls closure (set from GNUNET_MESH_connect) | ||
289 | * @param tunnel connection to the other end (henceforth invalid) | ||
290 | * @param tunnel_ctx place where local state associated | ||
291 | * with the tunnel is stored | ||
292 | */ | ||
293 | void | ||
294 | mesh_tunnel_end_handler (void *cls, const struct GNUNET_MESH_Tunnel *tunnel, | ||
295 | void *tunnel_ctx) | ||
296 | { | ||
297 | |||
298 | } | ||
299 | |||
300 | |||
301 | /** | ||
302 | * Mesh connect callback. | ||
303 | * | ||
304 | * @param cls internal peer id. | ||
305 | * @param op operation handle. | ||
306 | * @param ca_result connect adapter result. | ||
307 | * @param emsg error message. | ||
308 | */ | ||
309 | void | ||
310 | mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | ||
311 | void *ca_result, const char *emsg) | ||
312 | { | ||
313 | long i = (long) cls; | ||
314 | |||
315 | if (NULL != emsg) | ||
316 | { | ||
317 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Mesh connect failed: %s\n", emsg); | ||
318 | GNUNET_assert (0); | ||
319 | } | ||
320 | |||
321 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh connect callback for peer %i\n", | ||
322 | i); | ||
323 | } | ||
324 | |||
325 | |||
326 | /** | ||
327 | * Mesh connect adapter. | ||
328 | * | ||
329 | * @param cls not used. | ||
330 | * @param cfg configuration handle. | ||
331 | * | ||
332 | * @return | ||
333 | */ | ||
334 | void * | ||
335 | mesh_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
336 | { | ||
337 | struct PeerData *peer = (struct PeerData *) cls; | ||
338 | |||
339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh connect adapter\n"); | ||
340 | |||
341 | static struct GNUNET_MESH_MessageHandler handlers[] = { | ||
342 | {NULL, 0, 0} | ||
343 | }; | ||
344 | |||
345 | static GNUNET_MESH_ApplicationType apptypes[] = { | ||
346 | GNUNET_APPLICATION_TYPE_END | ||
347 | }; | ||
348 | |||
349 | peer->mesh_handle = | ||
350 | GNUNET_MESH_connect (cfg, cls, &mesh_inbound_tunnel_handler, | ||
351 | &mesh_tunnel_end_handler, handlers, apptypes); | ||
352 | |||
353 | return NULL; | ||
354 | } | ||
355 | |||
356 | |||
357 | /** | ||
358 | * Adapter function called to destroy a connection to | ||
359 | * the mesh service | ||
360 | * | ||
361 | * @param cls closure | ||
362 | * @param op_result service handle returned from the connect adapter | ||
363 | */ | ||
364 | void | ||
365 | mesh_da (void *cls, void *op_result) | ||
366 | { | ||
367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh disconnect adapter\n"); | ||
368 | } | ||
369 | |||
370 | |||
371 | /** | ||
372 | * Functions of this signature are called when a peer has been successfully | ||
373 | * started or stopped. | ||
374 | * | ||
375 | * @param cls the closure from GNUNET_TESTBED_peer_start/stop() | ||
376 | * @param emsg NULL on success; otherwise an error description | ||
377 | */ | ||
378 | static void | ||
379 | peer_start_cb (void *cls, const char *emsg) | ||
380 | { | ||
381 | unsigned int cnt; | ||
382 | long i = (long) cls; | ||
383 | |||
384 | GNUNET_TESTBED_operation_done (op[i]); | ||
385 | peers_started++; | ||
386 | // FIXME create and start rest of PEERS_PER_HOST | ||
387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u peer(s) started\n", peers_started); | ||
388 | |||
389 | if (TOTAL_PEERS == peers_started) | ||
390 | { | ||
391 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started.\n"); | ||
392 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Linking slave controllers\n"); | ||
393 | |||
394 | for (cnt = 0; cnt < NUM_HOSTS - 1; cnt++) | ||
395 | { | ||
396 | state[cnt] = LINKING_SLAVES; | ||
397 | op[cnt] = | ||
398 | GNUNET_TESTBED_get_slave_config ((void *) (long) cnt, master_ctrl, | ||
399 | slaves[cnt + 1].host); | ||
400 | } | ||
401 | } | ||
402 | } | ||
403 | |||
404 | |||
405 | /** | ||
406 | * Functions of this signature are called when a peer has been successfully | ||
407 | * created | ||
408 | * | ||
409 | * @param cls the closure from GNUNET_TESTBED_peer_create() | ||
410 | * @param peer the handle for the created peer; NULL on any error during | ||
411 | * creation | ||
412 | * @param emsg NULL if peer is not NULL; else MAY contain the error description | ||
413 | */ | ||
414 | static void | ||
415 | peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | ||
416 | { | ||
417 | long i = (long) cls; | ||
418 | long peer_id; | ||
419 | |||
420 | // GNUNET_TESTBED_operation_done(op[i]); | ||
421 | peer_id = i; // FIXME A * i + B | ||
422 | peers[peer_id].peer = peer; | ||
423 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer %i created\n", peer_id); | ||
424 | op[i] = GNUNET_TESTBED_peer_start (NULL, peer, peer_start_cb, (void *) i); | ||
425 | } | ||
426 | |||
427 | |||
428 | /** | ||
429 | * Signature of the event handler function called by the | ||
430 | * respective event controller. | ||
431 | * | ||
432 | * @param cls closure | ||
433 | * @param event information about the event | ||
434 | */ | ||
435 | static void | ||
436 | controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | ||
437 | { | ||
438 | long i; | ||
439 | |||
440 | switch (event->type) | ||
441 | { | ||
442 | case GNUNET_TESTBED_ET_PEER_START: | ||
443 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer started\n"); | ||
444 | /* event->details.peer_start.peer; */ | ||
445 | /* event->details.peer_start.host; */ | ||
446 | |||
447 | break; | ||
448 | case GNUNET_TESTBED_ET_PEER_STOP: | ||
449 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer stopped\n"); | ||
450 | break; | ||
451 | case GNUNET_TESTBED_ET_CONNECT: | ||
452 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Overlay Connected\n"); | ||
453 | for (i = 0; i < TOTAL_PEERS; i++) | ||
454 | { | ||
455 | GNUNET_TESTBED_service_connect (NULL, peers[i].peer, "mesh", | ||
456 | &mesh_connect_cb, (void *) i, &mesh_ca, | ||
457 | &mesh_da, NULL); | ||
458 | } | ||
459 | break; | ||
460 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: | ||
461 | if (NULL != event->details.operation_finished.emsg) | ||
462 | { | ||
463 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Testbed error: %s\n", | ||
464 | event->details.operation_finished.emsg); | ||
465 | GNUNET_assert (0); | ||
466 | } | ||
467 | |||
468 | i = (long) event->details.operation_finished.op_cls; | ||
469 | switch (state[i]) | ||
470 | { | ||
471 | case INIT: | ||
472 | { | ||
473 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Init: %u\n", i); | ||
474 | GNUNET_TESTBED_operation_done (event->details. | ||
475 | operation_finished.operation); | ||
476 | op[i] = NULL; | ||
477 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); | ||
478 | break; | ||
479 | } | ||
480 | case LINKING: | ||
481 | { | ||
482 | GNUNET_assert (NULL != slaves[i].op); | ||
483 | |||
484 | GNUNET_TESTBED_operation_done (slaves[i].op); | ||
485 | slaves[i].op = NULL; | ||
486 | |||
487 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); | ||
488 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linked host %i\n", i); | ||
489 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Creating peer...\n"); | ||
490 | |||
491 | state[i] = CREATING_PEER; | ||
492 | op[i] = | ||
493 | GNUNET_TESTBED_peer_create (master_ctrl, slaves[i].host, cfg, | ||
494 | peer_create_cb, (void *) i); | ||
495 | break; | ||
496 | } | ||
497 | case CREATING_PEER: | ||
498 | { | ||
499 | GNUNET_TESTBED_operation_done (event->details. | ||
500 | operation_finished.operation); | ||
501 | op[i] = NULL; | ||
502 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); | ||
503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer create\n"); | ||
504 | break; | ||
505 | } | ||
506 | case LINKING_SLAVES: | ||
507 | { | ||
508 | struct GNUNET_CONFIGURATION_Handle *slave_cfg; | ||
509 | |||
510 | GNUNET_assert (NULL != event->details.operation_finished.generic); | ||
511 | slave_cfg = | ||
512 | GNUNET_CONFIGURATION_dup ((struct GNUNET_CONFIGURATION_Handle *) | ||
513 | event->details.operation_finished.generic); | ||
514 | GNUNET_TESTBED_operation_done (event->details. | ||
515 | operation_finished.operation); | ||
516 | op[i] = NULL; | ||
517 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); | ||
518 | state[i] = LINKING_SLAVES_SUCCESS; | ||
519 | op[i] = | ||
520 | GNUNET_TESTBED_controller_link ((void *) (long) i, master_ctrl, | ||
521 | slaves[i + 1].host, slaves[i].host, | ||
522 | slave_cfg, GNUNET_NO); | ||
523 | GNUNET_CONFIGURATION_destroy (slave_cfg); | ||
524 | break; | ||
525 | } | ||
526 | case LINKING_SLAVES_SUCCESS: | ||
527 | { | ||
528 | unsigned int peer_cnt; | ||
529 | struct GNUNET_TESTBED_Peer *peer_handles[TOTAL_PEERS]; | ||
530 | |||
531 | GNUNET_TESTBED_operation_done (event->details. | ||
532 | operation_finished.operation); | ||
533 | op[i] = NULL; | ||
534 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); | ||
535 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linking slave %i succeeded\n", i); | ||
536 | state[0] = CONNECTING_PEERS; | ||
537 | |||
538 | for (peer_cnt = 0; peer_cnt < TOTAL_PEERS; peer_cnt++) | ||
539 | { | ||
540 | peer_handles[peer_cnt] = peers[peer_cnt].peer; | ||
541 | } | ||
542 | op[0] = | ||
543 | GNUNET_TESTBED_overlay_configure_topology (NULL, TOTAL_PEERS, | ||
544 | peer_handles, | ||
545 | GNUNET_TESTBED_TOPOLOGY_LINE); | ||
546 | GNUNET_assert (NULL != op[0]); | ||
547 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peers...\n"); | ||
548 | break; | ||
549 | } | ||
550 | case CONNECTING_PEERS: | ||
551 | { | ||
552 | GNUNET_TESTBED_operation_done (event->details. | ||
553 | operation_finished.operation); | ||
554 | op[i] = NULL; | ||
555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Operation %u finished\n", i); | ||
556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); | ||
557 | break; | ||
558 | } | ||
559 | default: | ||
560 | GNUNET_break (0); | ||
561 | } | ||
562 | break; | ||
563 | default: | ||
564 | GNUNET_break (0); | ||
565 | } | ||
566 | } | ||
567 | |||
568 | |||
569 | /** | ||
570 | * Callback which will be called to after a host registration succeeded or | ||
571 | * failed. Registration of all slave hosts is continued and linking of the hosts | ||
572 | * is started. | ||
573 | * | ||
574 | * @param cls not used. | ||
575 | * @param emsg the error message; NULL if host registration is successful. | ||
576 | */ | ||
577 | static void | ||
578 | registration_cont (void *cls, const char *emsg) | ||
579 | { | ||
580 | struct Host *slave = (struct Host *) cls; | ||
581 | |||
582 | if (NULL != emsg || NULL == slave) | ||
583 | { | ||
584 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); | ||
585 | GNUNET_assert (0); | ||
586 | } | ||
587 | |||
588 | state[host_registered] = LINKING; | ||
589 | slave->state = LINKING; | ||
590 | |||
591 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linking host %u\n", host_registered); | ||
592 | slave->op = | ||
593 | GNUNET_TESTBED_controller_link ((void *) (long) host_registered, | ||
594 | master_ctrl, slave->host, NULL, cfg, | ||
595 | GNUNET_YES); | ||
596 | host_registered++; | ||
597 | if (NUM_HOSTS != host_registered) | ||
598 | { | ||
599 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Registering host %u with ip %s\n", | ||
600 | host_registered, slaves[host_registered].ip); | ||
601 | rh = GNUNET_TESTBED_register_host (master_ctrl, | ||
602 | slaves[host_registered].host, | ||
603 | ®istration_cont, | ||
604 | &slaves[host_registered]); | ||
605 | return; | ||
606 | } | ||
607 | } | ||
608 | |||
609 | |||
610 | /** | ||
611 | * Callback to signal successfull startup of the controller process. If the | ||
612 | * startup was successfull the master controller and all slave hosts are | ||
613 | * created. Registering the slave hosts is started and continued in | ||
614 | * registration_cont. | ||
615 | * | ||
616 | * @param cls not used. | ||
617 | * @param config the configuration with which the controller has been started; | ||
618 | * NULL if status is not GNUNET_OK | ||
619 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, | ||
620 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case | ||
621 | */ | ||
622 | static void | ||
623 | status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, | ||
624 | int status) | ||
625 | { | ||
626 | unsigned int i; | ||
627 | |||
628 | if (NULL == config || GNUNET_OK != status) | ||
629 | return; | ||
630 | |||
631 | event_mask = 0; | ||
632 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START); | ||
633 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); | ||
634 | event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT); | ||
635 | event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED); | ||
636 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to master controller\n"); | ||
637 | master_ctrl = | ||
638 | GNUNET_TESTBED_controller_connect (config, master_host, event_mask, | ||
639 | &controller_cb, NULL); | ||
640 | GNUNET_assert (NULL != master_ctrl); | ||
641 | |||
642 | for (i = 0; i < NUM_HOSTS; i++) | ||
643 | { | ||
644 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Creating host %u with ip %s\n", i, | ||
645 | slaves[i].ip); | ||
646 | slaves[i].host = GNUNET_TESTBED_host_create (slaves[i].ip, NULL, 0); | ||
647 | GNUNET_assert (NULL != slaves[i].host); | ||
648 | } | ||
649 | host_registered = 0; | ||
650 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Registering host %u with ip %s\n", | ||
651 | host_registered, slaves[0].ip); | ||
652 | rh = GNUNET_TESTBED_register_host (master_ctrl, slaves[0].host, | ||
653 | ®istration_cont, &slaves[0]); | ||
654 | GNUNET_assert (NULL != rh); | ||
655 | } | ||
656 | |||
657 | |||
658 | /** | ||
659 | * Main run function. | ||
660 | * | ||
661 | * @param cls not used. | ||
662 | * @param args arguments passed to GNUNET_PROGRAM_run | ||
663 | * @param cfgfile the path to configuration file | ||
664 | * @param config the configuration file handle | ||
665 | */ | ||
666 | static void | ||
667 | run (void *cls, char *const *args, const char *cfgfile, | ||
668 | const struct GNUNET_CONFIGURATION_Handle *config) | ||
669 | { | ||
670 | master_host = GNUNET_TESTBED_host_create ("192.168.1.33", NULL, 0); | ||
671 | GNUNET_assert (NULL != master_host); | ||
672 | cfg = GNUNET_CONFIGURATION_dup (config); | ||
673 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting master controller\n"); | ||
674 | master_proc = | ||
675 | GNUNET_TESTBED_controller_start ("192.168.1.33", master_host, cfg, | ||
676 | status_cb, NULL); | ||
677 | abort_task = | ||
678 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | ||
679 | (GNUNET_TIME_UNIT_MINUTES, 60), &do_abort, | ||
680 | NULL); | ||
681 | } | ||
682 | |||
683 | |||
684 | /** | ||
685 | * Main function for profiling the regex/mesh implementation. Checks if all ssh | ||
686 | * connections to each of the hosts in 'slave_ips' is possible before setting up | ||
687 | * the testbed. | ||
688 | * | ||
689 | * @param argc argument count. | ||
690 | * @param argv argument values. | ||
691 | * | ||
692 | * @return 0 on success. | ||
693 | */ | ||
694 | int | ||
695 | main (int argc, char **argv) | ||
696 | { | ||
697 | int ret; | ||
698 | int test_hosts; | ||
699 | unsigned int i; | ||
700 | |||
701 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
702 | GNUNET_GETOPT_OPTION_END | ||
703 | }; | ||
704 | char *const argv2[] = { "gnunet-regex-profiler", | ||
705 | "-c", "regex_profiler_test.conf", | ||
706 | NULL | ||
707 | }; | ||
708 | |||
709 | test_hosts = GNUNET_OK; | ||
710 | for (i = 0; i < NUM_HOSTS; i++) | ||
711 | { | ||
712 | char *const remote_args[] = { | ||
713 | "ssh", "-o", "BatchMode=yes", slaves[i].ip, | ||
714 | "gnunet-helper-testbed --help > /dev/null", NULL | ||
715 | }; | ||
716 | struct GNUNET_OS_Process *auxp; | ||
717 | enum GNUNET_OS_ProcessStatusType type; | ||
718 | unsigned long code; | ||
719 | |||
720 | fprintf (stderr, "Testing host %i\n", i); | ||
721 | auxp = | ||
722 | GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, | ||
723 | NULL, "ssh", remote_args); | ||
724 | GNUNET_assert (NULL != auxp); | ||
725 | do | ||
726 | { | ||
727 | ret = GNUNET_OS_process_status (auxp, &type, &code); | ||
728 | GNUNET_assert (GNUNET_SYSERR != ret); | ||
729 | (void) usleep (300); | ||
730 | } | ||
731 | while (GNUNET_NO == ret); | ||
732 | (void) GNUNET_OS_process_wait (auxp); | ||
733 | GNUNET_OS_process_destroy (auxp); | ||
734 | if (0 != code) | ||
735 | { | ||
736 | fprintf (stderr, | ||
737 | "Unable to run the test as this system is not configured " | ||
738 | "to use password less SSH logins to host %s.\n", slaves[i].ip); | ||
739 | test_hosts = GNUNET_SYSERR; | ||
740 | } | ||
741 | } | ||
742 | if (test_hosts != GNUNET_OK) | ||
743 | { | ||
744 | fprintf (stderr, "Some hosts have failed the ssh check. Exiting.\n"); | ||
745 | return 1; | ||
746 | } | ||
747 | fprintf (stderr, "START.\n"); | ||
748 | |||
749 | result = GNUNET_SYSERR; | ||
750 | |||
751 | ret = | ||
752 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | ||
753 | "gnunet-regex-profiler", "nohelp", options, &run, | ||
754 | NULL); | ||
755 | |||
756 | fprintf (stderr, "END.\n"); | ||
757 | |||
758 | if (GNUNET_SYSERR == result || GNUNET_OK != ret) | ||
759 | return 1; | ||
760 | return 0; | ||
761 | } | ||
diff --git a/src/regex/regex_profiler_test.conf b/src/regex/regex_profiler_test.conf deleted file mode 100644 index f21a2ba57..000000000 --- a/src/regex/regex_profiler_test.conf +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | [lockmanager] | ||
2 | AUTOSTART = NO | ||
3 | ACCEPT_FROM = 127.0.0.1; | ||
4 | HOSTNAME = localhost | ||
5 | PORT = 12101 | ||
6 | |||
7 | [fs] | ||
8 | AUTOSTART = NO | ||
9 | |||
10 | [resolver] | ||
11 | AUTOSTART = NO | ||
12 | |||
13 | [mesh] | ||
14 | AUTOSTART = YES | ||
15 | ACCEPT_FROM = 127.0.0.1; | ||
16 | HOSTNAME = localhost | ||
17 | PORT = 10700 | ||
18 | # PREFIX = valgrind --leak-check=full | ||
19 | # PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args | ||
20 | |||
21 | [dht] | ||
22 | DEBUG = NO | ||
23 | AUTOSTART = YES | ||
24 | ACCEPT_FROM6 = ::1; | ||
25 | ACCEPT_FROM = 127.0.0.1; | ||
26 | HOSTNAME = localhost | ||
27 | PORT = 12100 | ||
28 | |||
29 | [block] | ||
30 | plugins = dht test | ||
31 | |||
32 | [dhtcache] | ||
33 | QUOTA = 1 MB | ||
34 | DATABASE = sqlite | ||
35 | |||
36 | [transport] | ||
37 | PLUGINS = tcp | ||
38 | DEBUG = NO | ||
39 | ACCEPT_FROM6 = ::1; | ||
40 | ACCEPT_FROM = 127.0.0.1; | ||
41 | NEIGHBOUR_LIMIT = 50 | ||
42 | PORT = 12365 | ||
43 | |||
44 | [ats] | ||
45 | WAN_QUOTA_OUT = 3932160 | ||
46 | WAN_QUOTA_IN = 3932160 | ||
47 | |||
48 | [core] | ||
49 | PORT = 12092 | ||
50 | |||
51 | [arm] | ||
52 | DEFAULTSERVICES = core lockmanager statistics | ||
53 | PORT = 12366 | ||
54 | DEBUG = NO | ||
55 | |||
56 | [transport-tcp] | ||
57 | TIMEOUT = 300 s | ||
58 | PORT = 12368 | ||
59 | |||
60 | [TESTING] | ||
61 | WEAKRANDOM = YES | ||
62 | |||
63 | [testing_old] | ||
64 | NUM_PEERS = 5 | ||
65 | DEBUG = YES | ||
66 | HOSTKEYSFILE = ${DATADIR}/testing_hostkeys.dat | ||
67 | MAX_CONCURRENT_SSH = 10 | ||
68 | USE_PROGRESSBARS = YES | ||
69 | PEERGROUP_TIMEOUT = 2400 s | ||
70 | |||
71 | [gnunetd] | ||
72 | HOSTKEY = $SERVICEHOME/.hostkey | ||
73 | |||
74 | [PATHS] | ||
75 | SERVICEHOME = /tmp/test-stream/ | ||
76 | |||
77 | [dns] | ||
78 | AUTOSTART = NO | ||
79 | |||
80 | [nse] | ||
81 | AUTOSTART = NO | ||
82 | |||
83 | [vpn] | ||
84 | AUTOSTART = NO | ||
85 | |||
86 | [testbed] | ||
87 | PORT = 12099 | ||