diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-07-06 15:45:29 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-07-06 15:45:29 +0000 |
commit | 53c1c40f7ea78892a3b3d8f95557ef53873565a7 (patch) | |
tree | ad58f71d3683cb3869bc7d33edd5aa53a8e1e8fc /src/transport | |
parent | a6341b90f152f7edecf5957d076c53998dff9699 (diff) | |
download | gnunet-53c1c40f7ea78892a3b3d8f95557ef53873565a7.tar.gz gnunet-53c1c40f7ea78892a3b3d8f95557ef53873565a7.zip |
new and modified testcases
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/test_transport_ats.c | 777 | ||||
-rw-r--r-- | src/transport/test_transport_ats_multiple_peers.c | 828 |
2 files changed, 869 insertions, 736 deletions
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c index 314d78172..41d1ff0d6 100644 --- a/src/transport/test_transport_ats.c +++ b/src/transport/test_transport_ats.c | |||
@@ -19,726 +19,56 @@ | |||
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file testing/test_transport_ats.c | 21 | * @file testing/test_transport_ats.c |
22 | * @brief testcase for ats functionality | 22 | * @brief testcase for ats functionality without starting peers |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_testing_lib.h" | 25 | #include "transport_ats.h" |
26 | #include "gnunet_transport_service.h" | 26 | #include "gnunet_configuration_lib.h" |
27 | #include "gnunet_scheduler_lib.h" | ||
28 | #include "gauger.h" | ||
29 | 27 | ||
30 | #define VERBOSE GNUNET_NO | 28 | #define VERBOSE GNUNET_YES |
31 | 29 | ||
32 | #define NUM_PEERS 11 | 30 | struct GNUNET_CONFIGURATION_Handle *cfg; |
33 | #define MEASUREMENTS 5 | ||
34 | 31 | ||
35 | #define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) | 32 | static struct ATS_Handle * ats; |
36 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) | ||
37 | #define SEND_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | ||
38 | 33 | ||
39 | #define ATS_NEW 0 | ||
40 | #define ATS_Q_UPDATED 1 | ||
41 | #define ATS_C_UPDATED 2 | ||
42 | #define ATS_QC_UPDATED 3 | ||
43 | #define ATS_UNMODIFIED 4 | ||
44 | 34 | ||
45 | static int ok; | 35 | int init_ats (void) |
46 | |||
47 | static int peers_left; | ||
48 | |||
49 | static int failed_peers; | ||
50 | |||
51 | static int measurement_started = GNUNET_NO; | ||
52 | static char * config_file; | ||
53 | |||
54 | static struct GNUNET_TESTING_PeerGroup *pg; | ||
55 | |||
56 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | ||
57 | static GNUNET_SCHEDULER_TaskIdentifier stats_task; | ||
58 | static GNUNET_SCHEDULER_TaskIdentifier send_task; | ||
59 | struct GNUNET_TESTING_Daemon * master_deamon; | ||
60 | struct GNUNET_TESTING_Daemon * ping_deamon; | ||
61 | |||
62 | struct GNUNET_STATISTICS_Handle * stats; | ||
63 | |||
64 | struct TEST_result | ||
65 | { | ||
66 | uint64_t timestamp; | ||
67 | uint64_t duration; | ||
68 | uint64_t mechs; | ||
69 | uint64_t peers; | ||
70 | uint64_t solution; | ||
71 | uint64_t state; | ||
72 | }; | ||
73 | |||
74 | struct TestMessage | ||
75 | { | ||
76 | struct GNUNET_MessageHeader header; | ||
77 | uint32_t num; | ||
78 | }; | ||
79 | |||
80 | |||
81 | static int count; | ||
82 | static int c_new; | ||
83 | static int c_unmodified; | ||
84 | static int c_modified; | ||
85 | static int connected; | ||
86 | static int peers; | ||
87 | |||
88 | static int force_q_updates; | ||
89 | static int force_rebuild; | ||
90 | static int send_msg; | ||
91 | static int machine_parsable; | ||
92 | |||
93 | static struct TEST_result results_new [MEASUREMENTS+1]; | ||
94 | static struct TEST_result results_modified [MEASUREMENTS+1]; | ||
95 | static struct TEST_result results_unmodified[MEASUREMENTS+1]; | ||
96 | static struct TEST_result current; | ||
97 | |||
98 | static struct GNUNET_STATISTICS_GetHandle * s_solution; | ||
99 | static struct GNUNET_STATISTICS_GetHandle * s_time; | ||
100 | static struct GNUNET_STATISTICS_GetHandle * s_peers; | ||
101 | static struct GNUNET_STATISTICS_GetHandle * s_mechs; | ||
102 | static struct GNUNET_STATISTICS_GetHandle * s_duration; | ||
103 | static struct GNUNET_STATISTICS_GetHandle * s_invalid; | ||
104 | static struct GNUNET_STATISTICS_GetHandle * s_state; | ||
105 | |||
106 | struct GNUNET_TRANSPORT_TransmitHandle * t; | ||
107 | struct GNUNET_TRANSPORT_Handle * th; | ||
108 | |||
109 | /** | ||
110 | * Check whether peers successfully shut down. | ||
111 | */ | ||
112 | static void | ||
113 | shutdown_callback (void *cls, const char *emsg) | ||
114 | { | ||
115 | if (emsg != NULL) | ||
116 | { | ||
117 | #if VERBOSE | ||
118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
119 | "Shutdown of peers failed!\n"); | ||
120 | #endif | ||
121 | if (ok == 0) | ||
122 | ok = 666; | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | #if VERBOSE | ||
127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
128 | "All peers successfully shut down!\n"); | ||
129 | if (stats != NULL) | ||
130 | GNUNET_STATISTICS_destroy(stats, GNUNET_NO); | ||
131 | stats = NULL; | ||
132 | #endif | ||
133 | } | ||
134 | } | ||
135 | |||
136 | static void | ||
137 | shutdown_peers() | ||
138 | { | ||
139 | if (shutdown_task != GNUNET_SCHEDULER_NO_TASK) | ||
140 | { | ||
141 | GNUNET_SCHEDULER_cancel(shutdown_task); | ||
142 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | ||
143 | } | ||
144 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | ||
145 | { | ||
146 | GNUNET_SCHEDULER_cancel(stats_task); | ||
147 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
148 | } | ||
149 | if (send_task != GNUNET_SCHEDULER_NO_TASK) | ||
150 | { | ||
151 | GNUNET_SCHEDULER_cancel(send_task); | ||
152 | send_task = GNUNET_SCHEDULER_NO_TASK; | ||
153 | } | ||
154 | |||
155 | if (t != NULL) | ||
156 | { | ||
157 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(t); | ||
158 | t = NULL; | ||
159 | } | ||
160 | GNUNET_TRANSPORT_disconnect(th); | ||
161 | if (s_time != NULL) | ||
162 | { | ||
163 | GNUNET_STATISTICS_get_cancel(s_time); | ||
164 | s_time = NULL; | ||
165 | } | ||
166 | if (s_peers != NULL) | ||
167 | { | ||
168 | GNUNET_STATISTICS_get_cancel(s_peers); | ||
169 | s_peers = NULL; | ||
170 | } | ||
171 | if (s_mechs != NULL) | ||
172 | { | ||
173 | GNUNET_STATISTICS_get_cancel(s_mechs); | ||
174 | s_mechs = NULL; | ||
175 | } | ||
176 | if (s_solution != NULL) | ||
177 | { | ||
178 | GNUNET_STATISTICS_get_cancel(s_solution); | ||
179 | s_solution = NULL; | ||
180 | } | ||
181 | if (s_duration != NULL) | ||
182 | { | ||
183 | GNUNET_STATISTICS_get_cancel(s_duration); | ||
184 | s_duration = NULL; | ||
185 | } | ||
186 | if (s_invalid != NULL) | ||
187 | { | ||
188 | GNUNET_STATISTICS_get_cancel(s_invalid); | ||
189 | s_invalid = NULL; | ||
190 | } | ||
191 | if (s_state != NULL) | ||
192 | { | ||
193 | GNUNET_STATISTICS_get_cancel(s_state); | ||
194 | s_state = NULL; | ||
195 | } | ||
196 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | ||
197 | } | ||
198 | |||
199 | static void | ||
200 | evaluate_measurements() | ||
201 | { | ||
202 | int c; | ||
203 | //int mechs = 0; | ||
204 | double average[3]; | ||
205 | double stddev[3]; | ||
206 | //char * output; | ||
207 | c = 1; | ||
208 | |||
209 | //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, results_modified[0].mechs, | ||
210 | |||
211 | average[0] = 0.0; | ||
212 | for (c=0; c<c_new;c++) | ||
213 | { | ||
214 | average[0] += (double) results_new[c].duration; | ||
215 | } | ||
216 | average[0] /= c_new; | ||
217 | |||
218 | stddev[0] = 0.0; | ||
219 | for (c=0; c<c_new;c++) | ||
220 | { | ||
221 | stddev[0] += (results_new[c].duration - average[0]) * (results_new[c].duration - average[0]); | ||
222 | } | ||
223 | stddev[0] /= c_new; | ||
224 | stddev[0] = sqrt (stddev[0]); | ||
225 | if (!machine_parsable) | ||
226 | fprintf (stderr, | ||
227 | "new, %i measurements, average: %f stddev: %f\n", | ||
228 | c_new, average[0], stddev[0]); | ||
229 | |||
230 | average[1] = 0.0; | ||
231 | for (c=0; c<c_modified;c++) | ||
232 | { | ||
233 | average[1] += (double) results_modified[c].duration; | ||
234 | } | ||
235 | average[1] /= c_modified; | ||
236 | |||
237 | stddev[1] = 0.0; | ||
238 | for (c=0; c<c_modified;c++) | ||
239 | { | ||
240 | stddev[1] += (results_modified[c].duration - average[1]) * (results_modified[c].duration - average[1]); | ||
241 | } | ||
242 | stddev[1] /= c_modified; | ||
243 | stddev[1] = sqrt (stddev[1]); | ||
244 | if (!machine_parsable) | ||
245 | fprintf (stderr, | ||
246 | "modified, %i measurements, average: %f stddev: %f\n", | ||
247 | c_modified, average[1], stddev[1]); | ||
248 | |||
249 | average[2] = 0.0; | ||
250 | for (c=0; c<c_unmodified;c++) | ||
251 | { | ||
252 | average[2] += (double) results_unmodified[c].duration; | ||
253 | } | ||
254 | average[2] /= c_unmodified; | ||
255 | stddev[2] = 0.0; | ||
256 | for (c=0; c<c_unmodified;c++) | ||
257 | { | ||
258 | stddev[2] += (results_unmodified[c].duration - average[2]) * (results_unmodified[c].duration - average[2]); | ||
259 | } | ||
260 | stddev[2] /= c_unmodified; | ||
261 | stddev[2] = sqrt (stddev[2]); | ||
262 | |||
263 | if (!machine_parsable) | ||
264 | fprintf (stderr, | ||
265 | "unmodified, %i measurements, average: %f stddev: %f\n", | ||
266 | c_unmodified, average[2], stddev[2]); | ||
267 | |||
268 | if (machine_parsable) | ||
269 | fprintf (stderr, | ||
270 | "peers,%i,mechs,%llu," | ||
271 | "new,%i,%f,%f," | ||
272 | "mod,%i,%f,%f," | ||
273 | "unmod,%i,%f,%f\n", | ||
274 | peers-1, (unsigned long long) results_unmodified[0].mechs, | ||
275 | c_new, average[0], stddev[0], | ||
276 | c_modified, average[1], stddev[1], | ||
277 | c_unmodified, average[2], stddev[2]); | ||
278 | shutdown_peers(); | ||
279 | } | ||
280 | |||
281 | |||
282 | static int | ||
283 | stats_cb (void *cls, | ||
284 | const char *subsystem, | ||
285 | const char *name, | ||
286 | uint64_t value, | ||
287 | int is_persistent) | ||
288 | { | ||
289 | static int printed = GNUNET_NO; | ||
290 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s = %llu\n", name ,value); | ||
291 | if (0 == strcmp (name,"ATS invalid solutions")) | ||
292 | { | ||
293 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | ||
294 | { | ||
295 | GNUNET_SCHEDULER_cancel(stats_task); | ||
296 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
297 | } | ||
298 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"MLP produced invalid %llu result(s)!\n", value); | ||
299 | shutdown_peers(); | ||
300 | return GNUNET_SYSERR; | ||
301 | } | ||
302 | |||
303 | if (0 == strcmp (name,"ATS solution")) | ||
304 | { | ||
305 | s_solution = NULL; | ||
306 | } | ||
307 | |||
308 | if (0 == strcmp (name,"ATS peers")) | ||
309 | { | ||
310 | s_peers = NULL; | ||
311 | } | ||
312 | |||
313 | if (0 == strcmp (name,"ATS mechanisms")) | ||
314 | { | ||
315 | s_mechs = NULL; | ||
316 | } | ||
317 | |||
318 | if (0 == strcmp (name,"ATS duration")) | ||
319 | { | ||
320 | s_duration = NULL; | ||
321 | } | ||
322 | if (0 == strcmp (name,"ATS timestamp")) | ||
323 | { | ||
324 | s_time = NULL; | ||
325 | } | ||
326 | if (0 == strcmp (name,"ATS state")) | ||
327 | { | ||
328 | s_state = NULL; | ||
329 | } | ||
330 | |||
331 | if ( (measurement_started == GNUNET_NO) && | ||
332 | (0 == strcmp (name, "ATS peers")) && | ||
333 | (value == peers-1) ) | ||
334 | { | ||
335 | measurement_started = GNUNET_YES; | ||
336 | count = 1; | ||
337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
338 | "All %llu peers connected\n", | ||
339 | value); | ||
340 | #if !VERBOSE | ||
341 | if (! machine_parsable) | ||
342 | fprintf(stderr, "%i", count); | ||
343 | #endif | ||
344 | } | ||
345 | |||
346 | if (measurement_started == GNUNET_YES) | ||
347 | { | ||
348 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value); | ||
349 | if (0 == strcmp (name,"ATS timestamp")) | ||
350 | { | ||
351 | if (current.timestamp == 0) | ||
352 | { | ||
353 | printed = GNUNET_NO; | ||
354 | current.timestamp = value; | ||
355 | } | ||
356 | if (current.timestamp == value) | ||
357 | { | ||
358 | printed = GNUNET_YES; | ||
359 | } | ||
360 | if (current.timestamp != value) | ||
361 | { | ||
362 | if (current.state == ATS_NEW) | ||
363 | { | ||
364 | if (c_new < MEASUREMENTS) | ||
365 | { | ||
366 | results_new[c_new] = current; | ||
367 | c_new++; | ||
368 | } | ||
369 | else | ||
370 | { | ||
371 | force_rebuild = GNUNET_NO; | ||
372 | force_q_updates = GNUNET_NO; | ||
373 | send_msg = GNUNET_NO; | ||
374 | } | ||
375 | } | ||
376 | if (current.state == ATS_UNMODIFIED) | ||
377 | { | ||
378 | if (c_unmodified < MEASUREMENTS) | ||
379 | { | ||
380 | results_unmodified[c_unmodified] = current; | ||
381 | c_unmodified++; | ||
382 | } | ||
383 | |||
384 | } | ||
385 | if (current.state == ATS_Q_UPDATED) | ||
386 | { | ||
387 | if (c_modified < MEASUREMENTS) | ||
388 | { | ||
389 | results_modified[c_modified] = current; | ||
390 | c_modified++; | ||
391 | } | ||
392 | else | ||
393 | { | ||
394 | force_q_updates = GNUNET_NO; | ||
395 | force_rebuild = GNUNET_YES; | ||
396 | } | ||
397 | } | ||
398 | count ++; | ||
399 | #if VERBOSE | ||
400 | fprintf (stderr, | ||
401 | "(new: %i / modified: %i / unmodified: %i) of %i \n", | ||
402 | c_new, c_modified, c_unmodified , MEASUREMENTS); | ||
403 | #endif | ||
404 | if ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS)) | ||
405 | { | ||
406 | #if !VERBOSE | ||
407 | if (!machine_parsable) | ||
408 | fprintf(stdout, "\n"); | ||
409 | #endif | ||
410 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | ||
411 | { | ||
412 | GNUNET_SCHEDULER_cancel(stats_task); | ||
413 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
414 | } | ||
415 | evaluate_measurements(); | ||
416 | return GNUNET_SYSERR; | ||
417 | } | ||
418 | |||
419 | printed = GNUNET_NO; | ||
420 | current.timestamp = value; | ||
421 | #if !VERBOSE | ||
422 | if (! machine_parsable) | ||
423 | fprintf(stderr, "..%i", count); | ||
424 | #endif | ||
425 | return GNUNET_OK; | ||
426 | } | ||
427 | } | ||
428 | |||
429 | if (0 == strcmp (name,"ATS solution")) | ||
430 | { | ||
431 | current.solution = value; | ||
432 | if (printed == GNUNET_NO) | ||
433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); | ||
434 | } | ||
435 | |||
436 | if (0 == strcmp (name,"ATS peers")) | ||
437 | { | ||
438 | current.peers = value; | ||
439 | if (printed == GNUNET_NO) | ||
440 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); | ||
441 | } | ||
442 | |||
443 | if (0 == strcmp (name,"ATS mechanisms")) | ||
444 | { | ||
445 | current.mechs = value; | ||
446 | if (printed == GNUNET_NO) | ||
447 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); | ||
448 | } | ||
449 | |||
450 | if (0 == strcmp (name,"ATS duration")) | ||
451 | { | ||
452 | current.duration = value; | ||
453 | if (printed == GNUNET_NO) | ||
454 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); | ||
455 | } | ||
456 | if (0 == strcmp (name,"ATS state")) | ||
457 | { | ||
458 | current.state = value; | ||
459 | char * cont; | ||
460 | if (value == ATS_NEW) | ||
461 | cont = "NEW"; | ||
462 | if (value == ATS_C_UPDATED) | ||
463 | cont = "C_UPDATED"; | ||
464 | if (value == ATS_Q_UPDATED) | ||
465 | cont = "Q_UPDATED"; | ||
466 | if (value == ATS_QC_UPDATED) | ||
467 | cont = "QC_UPDATED"; | ||
468 | if (value == ATS_UNMODIFIED) | ||
469 | cont = "UNMODIFIED"; | ||
470 | if (printed == GNUNET_NO) | ||
471 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
472 | "[%i] ATS state: %s\n", count, cont); | ||
473 | } | ||
474 | } | ||
475 | return GNUNET_OK; | ||
476 | } | ||
477 | |||
478 | |||
479 | static void | ||
480 | stats_get_task (void *cls, | ||
481 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
482 | { | 36 | { |
483 | stats_task = GNUNET_SCHEDULER_NO_TASK; | 37 | int ret = 0; |
484 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
485 | return; | ||
486 | |||
487 | s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL); | ||
488 | s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL); | ||
489 | s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL); | ||
490 | s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); | ||
491 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); | ||
492 | s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", TIMEOUT, NULL, &stats_cb, NULL); | ||
493 | s_state = GNUNET_STATISTICS_get (stats, "transport", "ATS state", TIMEOUT, NULL, &stats_cb, NULL); | ||
494 | |||
495 | stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), | ||
496 | &stats_get_task, NULL); | ||
497 | } | ||
498 | 38 | ||
39 | //ats = ats_init(cfg); | ||
40 | //GNUNET_assert (ats != NULL); | ||
499 | 41 | ||
500 | static void | 42 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
501 | delay (void *cls, | 43 | "Initializing ATS: %s \n", (ret==0)? "SUCCESFULL": "FAILED"); |
502 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 44 | return ret; |
503 | { | ||
504 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | ||
505 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
506 | return; | ||
507 | #if VERBOSE | ||
508 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
509 | "Delay over\n"); | ||
510 | #endif | ||
511 | shutdown_peers (); | ||
512 | } | ||
513 | |||
514 | static void | ||
515 | connect_peers() | ||
516 | { | ||
517 | shutdown_task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay, NULL); | ||
518 | } | ||
519 | |||
520 | static size_t | ||
521 | send_dummy_data_task (void *cls, size_t size, void *buf) | ||
522 | { | ||
523 | int s = sizeof (struct TestMessage); | ||
524 | struct TestMessage hdr; | ||
525 | |||
526 | hdr.header.size = htons (s); | ||
527 | hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ATS); | ||
528 | if (force_rebuild) | ||
529 | hdr.num = htonl (1); | ||
530 | if (force_q_updates) | ||
531 | hdr.num = htonl (2); | ||
532 | memcpy (buf,&hdr, s); | ||
533 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i of %i\n", s, s); | ||
534 | t = NULL; | ||
535 | return s; | ||
536 | } | ||
537 | |||
538 | |||
539 | static void | ||
540 | send_task_f (void *cls, | ||
541 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
542 | { | ||
543 | send_task = GNUNET_SCHEDULER_NO_TASK; | ||
544 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
545 | return; | ||
546 | |||
547 | if (t!=NULL) | ||
548 | { | ||
549 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(t); | ||
550 | t = NULL; | ||
551 | } | ||
552 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i to %s\n", size, GNUNET_i2s(&master_deamon->id)); | ||
553 | if (send_msg == GNUNET_YES) | ||
554 | t = GNUNET_TRANSPORT_notify_transmit_ready(th, | ||
555 | &master_deamon->id, | ||
556 | sizeof (struct TestMessage), 0, | ||
557 | SEND_TIMEOUT, | ||
558 | &send_dummy_data_task, NULL); | ||
559 | send_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,1000), | ||
560 | &send_task_f, NULL); | ||
561 | } | ||
562 | |||
563 | static void | ||
564 | notify_connect (void *cls, | ||
565 | const struct GNUNET_PeerIdentity *peer, | ||
566 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | ||
567 | uint32_t ats_count) | ||
568 | { | ||
569 | send_task = GNUNET_SCHEDULER_add_now(&send_task_f, NULL); | ||
570 | } | ||
571 | |||
572 | static void | ||
573 | notify_disconnect (void *cls, | ||
574 | const struct GNUNET_PeerIdentity *peer) | ||
575 | { | ||
576 | if (GNUNET_SCHEDULER_NO_TASK != send_task) | ||
577 | { | ||
578 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
579 | "Disconnect event before transmission request could be scheduled!\n"); | ||
580 | GNUNET_SCHEDULER_cancel (send_task); | ||
581 | send_task = GNUNET_SCHEDULER_NO_TASK; | ||
582 | } | ||
583 | if (NULL != t) | ||
584 | { | ||
585 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
586 | "Disconnect event before transmission request could be completed!\n"); | ||
587 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (t); | ||
588 | t = NULL; | ||
589 | } | ||
590 | } | ||
591 | |||
592 | static void | ||
593 | daemon_connect_cb(void *cls, | ||
594 | const struct GNUNET_PeerIdentity *first, | ||
595 | const struct GNUNET_PeerIdentity *second, | ||
596 | uint32_t distance, | ||
597 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | ||
598 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | ||
599 | struct GNUNET_TESTING_Daemon *first_daemon, | ||
600 | struct GNUNET_TESTING_Daemon *second_daemon, | ||
601 | const char *emsg) | ||
602 | { | ||
603 | char * firstc = strdup(GNUNET_i2s(first)); | ||
604 | char * secondc = strdup(GNUNET_i2s(second)); | ||
605 | connected++; | ||
606 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
607 | "Connected peers `%s'<->`%s' (%i/%i)\n", | ||
608 | firstc, secondc, connected, peers-1); | ||
609 | GNUNET_free(firstc); | ||
610 | GNUNET_free(secondc); | ||
611 | |||
612 | if ( ( (first_daemon == ping_deamon) || | ||
613 | (second_daemon == ping_deamon) ) && | ||
614 | (master_deamon != NULL) && | ||
615 | (ping_deamon != NULL) ) | ||
616 | { | ||
617 | th = GNUNET_TRANSPORT_connect (ping_deamon->cfg, | ||
618 | &ping_deamon->id, | ||
619 | NULL, NULL, | ||
620 | ¬ify_connect, | ||
621 | ¬ify_disconnect); | ||
622 | force_q_updates = GNUNET_YES; | ||
623 | send_msg = GNUNET_YES; | ||
624 | } | ||
625 | } | 45 | } |
626 | 46 | ||
627 | 47 | ||
628 | 48 | int shutdown_ats (void) | |
629 | static void | ||
630 | daemon_start_cb (void *cls, | ||
631 | const struct GNUNET_PeerIdentity *id, | ||
632 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
633 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | ||
634 | { | 49 | { |
635 | if (id == NULL) | 50 | int ret = 0; |
636 | { | ||
637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
638 | "Start callback called with error (too long starting peers), aborting test!\n"); | ||
639 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
640 | "Error from testing: `%s'\n"); | ||
641 | failed_peers++; | ||
642 | if (failed_peers == peers_left) | ||
643 | { | ||
644 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
645 | "Too many peers failed, ending test!\n"); | ||
646 | ok = 1; | ||
647 | shutdown_peers (); | ||
648 | } | ||
649 | return; | ||
650 | } | ||
651 | peers_left--; | ||
652 | 51 | ||
653 | if (master_deamon == NULL) | 52 | //ats_delete_problem (ats); |
654 | { | 53 | //ats_shutdown (ats); |
655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 54 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
656 | "Master peer `%s' '%s'\n", | 55 | "Shutdown ATS: %s \n", (ret==0)? "SUCCESFULL": "FAILED"); |
657 | GNUNET_i2s(id), d->cfgfile); | 56 | return ret; |
658 | master_deamon = d; | ||
659 | stats = GNUNET_STATISTICS_create("transport", master_deamon->cfg); | ||
660 | GNUNET_assert (stats != NULL); | ||
661 | stats_task = GNUNET_SCHEDULER_add_now(&stats_get_task, NULL); | ||
662 | } | ||
663 | else | ||
664 | { | ||
665 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
666 | "Connecting peer `%s'\n", | ||
667 | GNUNET_i2s(id), GNUNET_i2s(&master_deamon->id)); | ||
668 | GNUNET_TESTING_daemons_connect(d, master_deamon, TIMEOUT, 0, GNUNET_YES,&daemon_connect_cb, NULL); | ||
669 | } | ||
670 | |||
671 | if (peers_left == 0) | ||
672 | { | ||
673 | if (ping_deamon == NULL) | ||
674 | { | ||
675 | ping_deamon = d; | ||
676 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
677 | "Ping peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile); | ||
678 | } | ||
679 | |||
680 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
681 | "All peers started successfully!\n"); | ||
682 | connect_peers(); | ||
683 | ok = 0; | ||
684 | } | ||
685 | else if (failed_peers == peers_left) | ||
686 | { | ||
687 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
688 | "Too many peers failed, ending test!\n"); | ||
689 | shutdown_peers(); | ||
690 | ok = 1; | ||
691 | } | ||
692 | } | ||
693 | |||
694 | |||
695 | static void | ||
696 | run (void *cls, | ||
697 | char *const *args, | ||
698 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
699 | { | ||
700 | ok = 1; | ||
701 | measurement_started = GNUNET_NO; | ||
702 | #if VERBOSE | ||
703 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting %i peers.\n", peers); | ||
704 | #endif | ||
705 | peers_left = peers; | ||
706 | pg = GNUNET_TESTING_daemons_start (cfg, | ||
707 | peers_left, /* Total number of peers */ | ||
708 | peers_left, /* Number of outstanding connections */ | ||
709 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ | ||
710 | TIMEOUT, | ||
711 | NULL, NULL, | ||
712 | &daemon_start_cb, NULL, NULL, NULL, NULL); | ||
713 | GNUNET_assert (pg != NULL); | ||
714 | } | 57 | } |
715 | 58 | ||
716 | 59 | /* To make compiler happy */ | |
717 | static int | 60 | void dummy(void) |
718 | check () | ||
719 | { | 61 | { |
720 | char *const argv[] = { "test-testing", | 62 | struct ATS_quality_metric * q = qm; |
721 | "-c", | 63 | q = NULL; |
722 | config_file, | 64 | struct ATS_ressource * r = ressources; |
723 | #if VERBOSE | 65 | r = NULL; |
724 | "-L", "DEBUG", | ||
725 | #endif | ||
726 | NULL | ||
727 | }; | ||
728 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
729 | GNUNET_GETOPT_OPTION_END | ||
730 | }; | ||
731 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | ||
732 | argv, "test-transport-ats", "nohelp", | ||
733 | options, &run, &ok); | ||
734 | return ok; | ||
735 | } | 66 | } |
736 | 67 | ||
737 | |||
738 | int | 68 | int |
739 | main (int argc, char *argv[]) | 69 | main (int argc, char *argv[]) |
740 | { | 70 | { |
741 | int ret; | 71 | int ret = 0; |
742 | 72 | ||
743 | GNUNET_log_setup ("test-transport-ats", | 73 | GNUNET_log_setup ("test-transport-ats", |
744 | #if VERBOSE | 74 | #if VERBOSE |
@@ -747,53 +77,28 @@ main (int argc, char *argv[]) | |||
747 | "INFO", | 77 | "INFO", |
748 | #endif | 78 | #endif |
749 | NULL); | 79 | NULL); |
80 | #if !HAVE_LIBGLPK | ||
81 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
82 | "HAVE_LIBGLPK not set, exiting testcase\n"); | ||
83 | #endif | ||
750 | 84 | ||
751 | #if !HAVE_LIBGLPK | 85 | #if !HAVE_LIBGLPK |
752 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 86 | return ret; |
753 | "GLPK not installed, exiting testcase\n"); | ||
754 | return 0; | ||
755 | #endif | 87 | #endif |
756 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing"); | ||
757 | machine_parsable = GNUNET_NO; | ||
758 | peers = NUM_PEERS; | ||
759 | config_file = "test_transport_ats_4addr.conf"; | ||
760 | 88 | ||
761 | int c = 0; | ||
762 | if (argc >= 2) | ||
763 | { | ||
764 | for (c=0; c<argc; c++) | ||
765 | { | ||
766 | /* set peers */ | ||
767 | if ((strcmp(argv[c], "-p") == 0) && c < (argc-1)) | ||
768 | { | ||
769 | peers = atoi(argv[c+1]); | ||
770 | peers++; | ||
771 | } | ||
772 | /* set machine parsable */ | ||
773 | if (strcmp(argv[c], "-m") == 0) | ||
774 | { | ||
775 | machine_parsable = GNUNET_YES; | ||
776 | } | ||
777 | /* set config file */ | ||
778 | if ((strcmp(argv[c], "-c") == 0) && c < (argc-1)) | ||
779 | { | ||
780 | config_file = argv[c+1]; | ||
781 | } | ||
782 | } | ||
783 | } | ||
784 | 89 | ||
90 | cfg = GNUNET_CONFIGURATION_create(); | ||
91 | GNUNET_CONFIGURATION_load(cfg, "test_transport_ats_1addr.conf"); | ||
785 | 92 | ||
93 | /* Testing */ | ||
94 | ats = NULL; | ||
95 | ret += init_ats (); | ||
96 | ret += shutdown_ats (); | ||
786 | 97 | ||
787 | ret = check (); | 98 | /* Shutdown */ |
788 | /** | 99 | GNUNET_CONFIGURATION_destroy(cfg); |
789 | * Still need to remove the base testing directory here, | ||
790 | * because group starts will create subdirectories under this | ||
791 | * main dir. However, we no longer need to sleep, as the | ||
792 | * shutdown sequence won't return until everything is cleaned | ||
793 | * up. | ||
794 | */ | ||
795 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing"); | ||
796 | return ret; | 100 | return ret; |
101 | |||
797 | } | 102 | } |
798 | 103 | ||
799 | /* end of test_transport_ats.c*/ | 104 | /* end of test_transport_ats.c*/ |
diff --git a/src/transport/test_transport_ats_multiple_peers.c b/src/transport/test_transport_ats_multiple_peers.c new file mode 100644 index 000000000..e0cf58c6d --- /dev/null +++ b/src/transport/test_transport_ats_multiple_peers.c | |||
@@ -0,0 +1,828 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2009 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 testing/test_transport_ats_multiple_peers.c | ||
22 | * @brief testcase for ats functionality by starting multiple peers | ||
23 | */ | ||
24 | #include "platform.h" | ||
25 | #include "gnunet_testing_lib.h" | ||
26 | #include "gnunet_transport_service.h" | ||
27 | #include "gnunet_scheduler_lib.h" | ||
28 | #include "gauger.h" | ||
29 | |||
30 | #define VERBOSE GNUNET_NO | ||
31 | |||
32 | #define NUM_PEERS 11 | ||
33 | #define MEASUREMENTS 5 | ||
34 | |||
35 | #define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) | ||
36 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) | ||
37 | #define SEND_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | ||
38 | |||
39 | #define ATS_NEW 0 | ||
40 | #define ATS_Q_UPDATED 1 | ||
41 | #define ATS_C_UPDATED 2 | ||
42 | #define ATS_QC_UPDATED 3 | ||
43 | #define ATS_UNMODIFIED 4 | ||
44 | |||
45 | static int ok; | ||
46 | |||
47 | static int peers_left; | ||
48 | |||
49 | static int failed_peers; | ||
50 | |||
51 | static int measurement_started = GNUNET_NO; | ||
52 | static char * config_file; | ||
53 | |||
54 | static struct GNUNET_TESTING_PeerGroup *pg; | ||
55 | |||
56 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | ||
57 | static GNUNET_SCHEDULER_TaskIdentifier stats_task; | ||
58 | static GNUNET_SCHEDULER_TaskIdentifier send_task; | ||
59 | struct GNUNET_TESTING_Daemon * master_deamon; | ||
60 | struct GNUNET_TESTING_Daemon * ping_deamon; | ||
61 | |||
62 | struct GNUNET_STATISTICS_Handle * stats; | ||
63 | |||
64 | struct TEST_result | ||
65 | { | ||
66 | uint64_t timestamp; | ||
67 | uint64_t duration; | ||
68 | uint64_t mechs; | ||
69 | uint64_t peers; | ||
70 | uint64_t solution; | ||
71 | uint64_t state; | ||
72 | }; | ||
73 | |||
74 | struct TestMessage | ||
75 | { | ||
76 | struct GNUNET_MessageHeader header; | ||
77 | uint32_t num; | ||
78 | }; | ||
79 | |||
80 | |||
81 | static int count; | ||
82 | static int c_new; | ||
83 | static int c_unmodified; | ||
84 | static int c_modified; | ||
85 | static int connected; | ||
86 | static int peers; | ||
87 | |||
88 | static int force_q_updates; | ||
89 | static int force_rebuild; | ||
90 | static int send_msg; | ||
91 | static int machine_parsable; | ||
92 | |||
93 | static struct TEST_result results_new [MEASUREMENTS+1]; | ||
94 | static struct TEST_result results_modified [MEASUREMENTS+1]; | ||
95 | static struct TEST_result results_unmodified[MEASUREMENTS+1]; | ||
96 | static struct TEST_result current; | ||
97 | |||
98 | static struct GNUNET_STATISTICS_GetHandle * s_solution; | ||
99 | static struct GNUNET_STATISTICS_GetHandle * s_time; | ||
100 | static struct GNUNET_STATISTICS_GetHandle * s_peers; | ||
101 | static struct GNUNET_STATISTICS_GetHandle * s_mechs; | ||
102 | static struct GNUNET_STATISTICS_GetHandle * s_duration; | ||
103 | static struct GNUNET_STATISTICS_GetHandle * s_invalid; | ||
104 | static struct GNUNET_STATISTICS_GetHandle * s_state; | ||
105 | |||
106 | struct GNUNET_TRANSPORT_TransmitHandle * t; | ||
107 | struct GNUNET_TRANSPORT_Handle * th; | ||
108 | |||
109 | /** | ||
110 | * Check whether peers successfully shut down. | ||
111 | */ | ||
112 | static void | ||
113 | shutdown_callback (void *cls, const char *emsg) | ||
114 | { | ||
115 | if (emsg != NULL) | ||
116 | { | ||
117 | #if VERBOSE | ||
118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
119 | "Shutdown of peers failed!\n"); | ||
120 | #endif | ||
121 | if (ok == 0) | ||
122 | ok = 666; | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | #if VERBOSE | ||
127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
128 | "All peers successfully shut down!\n"); | ||
129 | if (stats != NULL) | ||
130 | GNUNET_STATISTICS_destroy(stats, GNUNET_NO); | ||
131 | stats = NULL; | ||
132 | #endif | ||
133 | } | ||
134 | } | ||
135 | |||
136 | static void | ||
137 | shutdown_peers() | ||
138 | { | ||
139 | if (shutdown_task != GNUNET_SCHEDULER_NO_TASK) | ||
140 | { | ||
141 | GNUNET_SCHEDULER_cancel(shutdown_task); | ||
142 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | ||
143 | } | ||
144 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | ||
145 | { | ||
146 | GNUNET_SCHEDULER_cancel(stats_task); | ||
147 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
148 | } | ||
149 | if (send_task != GNUNET_SCHEDULER_NO_TASK) | ||
150 | { | ||
151 | GNUNET_SCHEDULER_cancel(send_task); | ||
152 | send_task = GNUNET_SCHEDULER_NO_TASK; | ||
153 | } | ||
154 | |||
155 | if (t != NULL) | ||
156 | { | ||
157 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(t); | ||
158 | t = NULL; | ||
159 | } | ||
160 | GNUNET_TRANSPORT_disconnect(th); | ||
161 | if (s_time != NULL) | ||
162 | { | ||
163 | GNUNET_STATISTICS_get_cancel(s_time); | ||
164 | s_time = NULL; | ||
165 | } | ||
166 | if (s_peers != NULL) | ||
167 | { | ||
168 | GNUNET_STATISTICS_get_cancel(s_peers); | ||
169 | s_peers = NULL; | ||
170 | } | ||
171 | if (s_mechs != NULL) | ||
172 | { | ||
173 | GNUNET_STATISTICS_get_cancel(s_mechs); | ||
174 | s_mechs = NULL; | ||
175 | } | ||
176 | if (s_solution != NULL) | ||
177 | { | ||
178 | GNUNET_STATISTICS_get_cancel(s_solution); | ||
179 | s_solution = NULL; | ||
180 | } | ||
181 | if (s_duration != NULL) | ||
182 | { | ||
183 | GNUNET_STATISTICS_get_cancel(s_duration); | ||
184 | s_duration = NULL; | ||
185 | } | ||
186 | if (s_invalid != NULL) | ||
187 | { | ||
188 | GNUNET_STATISTICS_get_cancel(s_invalid); | ||
189 | s_invalid = NULL; | ||
190 | } | ||
191 | if (s_state != NULL) | ||
192 | { | ||
193 | GNUNET_STATISTICS_get_cancel(s_state); | ||
194 | s_state = NULL; | ||
195 | } | ||
196 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | ||
197 | } | ||
198 | |||
199 | static void | ||
200 | evaluate_measurements() | ||
201 | { | ||
202 | int c; | ||
203 | //int mechs = 0; | ||
204 | double average[3]; | ||
205 | double stddev[3]; | ||
206 | //char * output; | ||
207 | c = 1; | ||
208 | |||
209 | //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, results_modified[0].mechs, | ||
210 | |||
211 | average[0] = 0.0; | ||
212 | for (c=0; c<c_new;c++) | ||
213 | { | ||
214 | average[0] += (double) results_new[c].duration; | ||
215 | } | ||
216 | average[0] /= c_new; | ||
217 | |||
218 | stddev[0] = 0.0; | ||
219 | for (c=0; c<c_new;c++) | ||
220 | { | ||
221 | stddev[0] += (results_new[c].duration - average[0]) * | ||
222 | (results_new[c].duration - average[0]); | ||
223 | } | ||
224 | stddev[0] /= c_new; | ||
225 | stddev[0] = sqrt (stddev[0]); | ||
226 | if (!machine_parsable) | ||
227 | fprintf (stderr, | ||
228 | "new, %i measurements, average: %f stddev: %f\n", | ||
229 | c_new, average[0], stddev[0]); | ||
230 | |||
231 | average[1] = 0.0; | ||
232 | for (c=0; c<c_modified;c++) | ||
233 | { | ||
234 | average[1] += (double) results_modified[c].duration; | ||
235 | } | ||
236 | average[1] /= c_modified; | ||
237 | |||
238 | stddev[1] = 0.0; | ||
239 | for (c=0; c<c_modified;c++) | ||
240 | { | ||
241 | stddev[1] += (results_modified[c].duration - average[1]) * | ||
242 | (results_modified[c].duration - average[1]); | ||
243 | } | ||
244 | stddev[1] /= c_modified; | ||
245 | stddev[1] = sqrt (stddev[1]); | ||
246 | if (!machine_parsable) | ||
247 | fprintf (stderr, | ||
248 | "modified, %i measurements, average: %f stddev: %f\n", | ||
249 | c_modified, average[1], stddev[1]); | ||
250 | |||
251 | average[2] = 0.0; | ||
252 | for (c=0; c<c_unmodified;c++) | ||
253 | { | ||
254 | average[2] += (double) results_unmodified[c].duration; | ||
255 | } | ||
256 | average[2] /= c_unmodified; | ||
257 | stddev[2] = 0.0; | ||
258 | for (c=0; c<c_unmodified;c++) | ||
259 | { | ||
260 | stddev[2] += (results_unmodified[c].duration - average[2]) * | ||
261 | (results_unmodified[c].duration - average[2]); | ||
262 | } | ||
263 | stddev[2] /= c_unmodified; | ||
264 | stddev[2] = sqrt (stddev[2]); | ||
265 | |||
266 | if (!machine_parsable) | ||
267 | fprintf (stderr, | ||
268 | "unmodified, %i measurements, average: %f stddev: %f\n", | ||
269 | c_unmodified, average[2], stddev[2]); | ||
270 | |||
271 | if (machine_parsable) | ||
272 | fprintf (stderr, | ||
273 | "peers,%i,mechs,%llu," | ||
274 | "new,%i,%f,%f," | ||
275 | "mod,%i,%f,%f," | ||
276 | "unmod,%i,%f,%f\n", | ||
277 | peers-1, (unsigned long long) results_unmodified[0].mechs, | ||
278 | c_new, average[0], stddev[0], | ||
279 | c_modified, average[1], stddev[1], | ||
280 | c_unmodified, average[2], stddev[2]); | ||
281 | shutdown_peers(); | ||
282 | } | ||
283 | |||
284 | |||
285 | static int | ||
286 | stats_cb (void *cls, | ||
287 | const char *subsystem, | ||
288 | const char *name, | ||
289 | uint64_t value, | ||
290 | int is_persistent) | ||
291 | { | ||
292 | static int printed = GNUNET_NO; | ||
293 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s = %llu\n", name ,value); | ||
294 | if (0 == strcmp (name,"ATS invalid solutions")) | ||
295 | { | ||
296 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | ||
297 | { | ||
298 | GNUNET_SCHEDULER_cancel(stats_task); | ||
299 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
300 | } | ||
301 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"MLP produced invalid %llu result(s)!\n", | ||
302 | value); | ||
303 | shutdown_peers(); | ||
304 | return GNUNET_SYSERR; | ||
305 | } | ||
306 | |||
307 | if (0 == strcmp (name,"ATS solution")) | ||
308 | { | ||
309 | s_solution = NULL; | ||
310 | } | ||
311 | |||
312 | if (0 == strcmp (name,"ATS peers")) | ||
313 | { | ||
314 | s_peers = NULL; | ||
315 | } | ||
316 | |||
317 | if (0 == strcmp (name,"ATS mechanisms")) | ||
318 | { | ||
319 | s_mechs = NULL; | ||
320 | } | ||
321 | |||
322 | if (0 == strcmp (name,"ATS duration")) | ||
323 | { | ||
324 | s_duration = NULL; | ||
325 | } | ||
326 | if (0 == strcmp (name,"ATS timestamp")) | ||
327 | { | ||
328 | s_time = NULL; | ||
329 | } | ||
330 | if (0 == strcmp (name,"ATS state")) | ||
331 | { | ||
332 | s_state = NULL; | ||
333 | } | ||
334 | |||
335 | if ( (measurement_started == GNUNET_NO) && | ||
336 | (0 == strcmp (name, "ATS peers")) && | ||
337 | (value == peers-1) ) | ||
338 | { | ||
339 | measurement_started = GNUNET_YES; | ||
340 | count = 1; | ||
341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
342 | "All %llu peers connected\n", | ||
343 | value); | ||
344 | #if !VERBOSE | ||
345 | if (! machine_parsable) | ||
346 | fprintf(stderr, "%i", count); | ||
347 | #endif | ||
348 | } | ||
349 | |||
350 | if (measurement_started == GNUNET_YES) | ||
351 | { | ||
352 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value); | ||
353 | if (0 == strcmp (name,"ATS timestamp")) | ||
354 | { | ||
355 | if (current.timestamp == 0) | ||
356 | { | ||
357 | printed = GNUNET_NO; | ||
358 | current.timestamp = value; | ||
359 | } | ||
360 | if (current.timestamp == value) | ||
361 | { | ||
362 | printed = GNUNET_YES; | ||
363 | } | ||
364 | if (current.timestamp != value) | ||
365 | { | ||
366 | if (current.state == ATS_NEW) | ||
367 | { | ||
368 | if (c_new < MEASUREMENTS) | ||
369 | { | ||
370 | results_new[c_new] = current; | ||
371 | c_new++; | ||
372 | } | ||
373 | else | ||
374 | { | ||
375 | force_rebuild = GNUNET_NO; | ||
376 | force_q_updates = GNUNET_NO; | ||
377 | send_msg = GNUNET_NO; | ||
378 | } | ||
379 | } | ||
380 | if (current.state == ATS_UNMODIFIED) | ||
381 | { | ||
382 | if (c_unmodified < MEASUREMENTS) | ||
383 | { | ||
384 | results_unmodified[c_unmodified] = current; | ||
385 | c_unmodified++; | ||
386 | } | ||
387 | |||
388 | } | ||
389 | if (current.state == ATS_Q_UPDATED) | ||
390 | { | ||
391 | if (c_modified < MEASUREMENTS) | ||
392 | { | ||
393 | results_modified[c_modified] = current; | ||
394 | c_modified++; | ||
395 | } | ||
396 | else | ||
397 | { | ||
398 | force_q_updates = GNUNET_NO; | ||
399 | force_rebuild = GNUNET_YES; | ||
400 | } | ||
401 | } | ||
402 | count ++; | ||
403 | #if VERBOSE | ||
404 | fprintf (stderr, | ||
405 | "(new: %i / modified: %i / unmodified: %i) of %i \n", | ||
406 | c_new, c_modified, c_unmodified , MEASUREMENTS); | ||
407 | #endif | ||
408 | if ((c_modified >= MEASUREMENTS) && | ||
409 | (c_new >= MEASUREMENTS) && | ||
410 | (c_unmodified >= MEASUREMENTS)) | ||
411 | { | ||
412 | #if !VERBOSE | ||
413 | if (!machine_parsable) | ||
414 | fprintf(stdout, "\n"); | ||
415 | #endif | ||
416 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | ||
417 | { | ||
418 | GNUNET_SCHEDULER_cancel(stats_task); | ||
419 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
420 | } | ||
421 | evaluate_measurements(); | ||
422 | return GNUNET_SYSERR; | ||
423 | } | ||
424 | |||
425 | printed = GNUNET_NO; | ||
426 | current.timestamp = value; | ||
427 | #if !VERBOSE | ||
428 | if (! machine_parsable) | ||
429 | fprintf(stderr, "..%i", count); | ||
430 | #endif | ||
431 | return GNUNET_OK; | ||
432 | } | ||
433 | } | ||
434 | |||
435 | if (0 == strcmp (name,"ATS solution")) | ||
436 | { | ||
437 | current.solution = value; | ||
438 | if (printed == GNUNET_NO) | ||
439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | ||
440 | count, name, value); | ||
441 | } | ||
442 | |||
443 | if (0 == strcmp (name,"ATS peers")) | ||
444 | { | ||
445 | current.peers = value; | ||
446 | if (printed == GNUNET_NO) | ||
447 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | ||
448 | count, name, value); | ||
449 | } | ||
450 | |||
451 | if (0 == strcmp (name,"ATS mechanisms")) | ||
452 | { | ||
453 | current.mechs = value; | ||
454 | if (printed == GNUNET_NO) | ||
455 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | ||
456 | count, name, value); | ||
457 | } | ||
458 | |||
459 | if (0 == strcmp (name,"ATS duration")) | ||
460 | { | ||
461 | current.duration = value; | ||
462 | if (printed == GNUNET_NO) | ||
463 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", | ||
464 | count, name, value); | ||
465 | } | ||
466 | if (0 == strcmp (name,"ATS state")) | ||
467 | { | ||
468 | current.state = value; | ||
469 | char * cont; | ||
470 | if (value == ATS_NEW) | ||
471 | cont = "NEW"; | ||
472 | if (value == ATS_C_UPDATED) | ||
473 | cont = "C_UPDATED"; | ||
474 | if (value == ATS_Q_UPDATED) | ||
475 | cont = "Q_UPDATED"; | ||
476 | if (value == ATS_QC_UPDATED) | ||
477 | cont = "QC_UPDATED"; | ||
478 | if (value == ATS_UNMODIFIED) | ||
479 | cont = "UNMODIFIED"; | ||
480 | if (printed == GNUNET_NO) | ||
481 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
482 | "[%i] ATS state: %s\n", count, cont); | ||
483 | } | ||
484 | } | ||
485 | return GNUNET_OK; | ||
486 | } | ||
487 | |||
488 | |||
489 | static void | ||
490 | stats_get_task (void *cls, | ||
491 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
492 | { | ||
493 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
494 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
495 | return; | ||
496 | |||
497 | s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", | ||
498 | TIMEOUT, NULL, &stats_cb, NULL); | ||
499 | s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", | ||
500 | TIMEOUT, NULL, &stats_cb, NULL); | ||
501 | s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", | ||
502 | TIMEOUT, NULL, &stats_cb, NULL); | ||
503 | s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", | ||
504 | TIMEOUT, NULL, &stats_cb, NULL); | ||
505 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", | ||
506 | TIMEOUT, NULL, &stats_cb, NULL); | ||
507 | s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", | ||
508 | TIMEOUT, NULL, &stats_cb, NULL); | ||
509 | s_state = GNUNET_STATISTICS_get (stats, "transport", "ATS state", | ||
510 | TIMEOUT, NULL, &stats_cb, NULL); | ||
511 | |||
512 | stats_task = GNUNET_SCHEDULER_add_delayed( | ||
513 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), | ||
514 | &stats_get_task, | ||
515 | NULL); | ||
516 | } | ||
517 | |||
518 | |||
519 | static void | ||
520 | delay (void *cls, | ||
521 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
522 | { | ||
523 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | ||
524 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
525 | return; | ||
526 | #if VERBOSE | ||
527 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
528 | "Delay over\n"); | ||
529 | #endif | ||
530 | shutdown_peers (); | ||
531 | } | ||
532 | |||
533 | static void | ||
534 | connect_peers() | ||
535 | { | ||
536 | shutdown_task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay, NULL); | ||
537 | } | ||
538 | |||
539 | static size_t | ||
540 | send_dummy_data_task (void *cls, size_t size, void *buf) | ||
541 | { | ||
542 | int s = sizeof (struct TestMessage); | ||
543 | struct TestMessage hdr; | ||
544 | |||
545 | hdr.header.size = htons (s); | ||
546 | hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ATS); | ||
547 | if (force_rebuild) | ||
548 | hdr.num = htonl (1); | ||
549 | if (force_q_updates) | ||
550 | hdr.num = htonl (2); | ||
551 | memcpy (buf,&hdr, s); | ||
552 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i of %i\n", s, s); | ||
553 | t = NULL; | ||
554 | return s; | ||
555 | } | ||
556 | |||
557 | |||
558 | static void | ||
559 | send_task_f (void *cls, | ||
560 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
561 | { | ||
562 | send_task = GNUNET_SCHEDULER_NO_TASK; | ||
563 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
564 | return; | ||
565 | |||
566 | if (t!=NULL) | ||
567 | { | ||
568 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(t); | ||
569 | t = NULL; | ||
570 | } | ||
571 | |||
572 | if (send_msg == GNUNET_YES) | ||
573 | t = GNUNET_TRANSPORT_notify_transmit_ready(th, | ||
574 | &master_deamon->id, | ||
575 | sizeof (struct TestMessage), 0, | ||
576 | SEND_TIMEOUT, | ||
577 | &send_dummy_data_task, NULL); | ||
578 | send_task = GNUNET_SCHEDULER_add_delayed( | ||
579 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,1000), | ||
580 | &send_task_f, | ||
581 | NULL); | ||
582 | |||
583 | } | ||
584 | |||
585 | static void | ||
586 | notify_connect (void *cls, | ||
587 | const struct GNUNET_PeerIdentity *peer, | ||
588 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | ||
589 | uint32_t ats_count) | ||
590 | { | ||
591 | send_task = GNUNET_SCHEDULER_add_now(&send_task_f, NULL); | ||
592 | } | ||
593 | |||
594 | static void | ||
595 | notify_disconnect (void *cls, | ||
596 | const struct GNUNET_PeerIdentity *peer) | ||
597 | { | ||
598 | if (GNUNET_SCHEDULER_NO_TASK != send_task) | ||
599 | { | ||
600 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
601 | "Disconnect event before transmission request could be scheduled!\n"); | ||
602 | GNUNET_SCHEDULER_cancel (send_task); | ||
603 | send_task = GNUNET_SCHEDULER_NO_TASK; | ||
604 | } | ||
605 | if (NULL != t) | ||
606 | { | ||
607 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
608 | "Disconnect event before transmission request could be completed!\n"); | ||
609 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (t); | ||
610 | t = NULL; | ||
611 | } | ||
612 | } | ||
613 | |||
614 | static void | ||
615 | daemon_connect_cb(void *cls, | ||
616 | const struct GNUNET_PeerIdentity *first, | ||
617 | const struct GNUNET_PeerIdentity *second, | ||
618 | uint32_t distance, | ||
619 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | ||
620 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | ||
621 | struct GNUNET_TESTING_Daemon *first_daemon, | ||
622 | struct GNUNET_TESTING_Daemon *second_daemon, | ||
623 | const char *emsg) | ||
624 | { | ||
625 | char * firstc = strdup(GNUNET_i2s(first)); | ||
626 | char * secondc = strdup(GNUNET_i2s(second)); | ||
627 | connected++; | ||
628 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
629 | "Connected peers `%s'<->`%s' (%i/%i)\n", | ||
630 | firstc, secondc, connected, peers-1); | ||
631 | GNUNET_free(firstc); | ||
632 | GNUNET_free(secondc); | ||
633 | |||
634 | if ( ( (first_daemon == ping_deamon) || | ||
635 | (second_daemon == ping_deamon) ) && | ||
636 | (master_deamon != NULL) && | ||
637 | (ping_deamon != NULL) ) | ||
638 | { | ||
639 | th = GNUNET_TRANSPORT_connect (ping_deamon->cfg, | ||
640 | &ping_deamon->id, | ||
641 | NULL, NULL, | ||
642 | ¬ify_connect, | ||
643 | ¬ify_disconnect); | ||
644 | force_q_updates = GNUNET_YES; | ||
645 | send_msg = GNUNET_YES; | ||
646 | } | ||
647 | } | ||
648 | |||
649 | |||
650 | |||
651 | static void | ||
652 | daemon_start_cb (void *cls, | ||
653 | const struct GNUNET_PeerIdentity *id, | ||
654 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
655 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | ||
656 | { | ||
657 | if (id == NULL) | ||
658 | { | ||
659 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
660 | "Start callback called with error (too long starting peers), aborting test!\n"); | ||
661 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
662 | "Error from testing: `%s'\n"); | ||
663 | failed_peers++; | ||
664 | if (failed_peers == peers_left) | ||
665 | { | ||
666 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
667 | "Too many peers failed, ending test!\n"); | ||
668 | ok = 1; | ||
669 | shutdown_peers (); | ||
670 | } | ||
671 | return; | ||
672 | } | ||
673 | peers_left--; | ||
674 | |||
675 | if (master_deamon == NULL) | ||
676 | { | ||
677 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
678 | "Master peer `%s' '%s'\n", | ||
679 | GNUNET_i2s(id), d->cfgfile); | ||
680 | master_deamon = d; | ||
681 | stats = GNUNET_STATISTICS_create("transport", master_deamon->cfg); | ||
682 | GNUNET_assert (stats != NULL); | ||
683 | stats_task = GNUNET_SCHEDULER_add_now(&stats_get_task, NULL); | ||
684 | } | ||
685 | else | ||
686 | { | ||
687 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
688 | "Connecting peer `%s'\n", | ||
689 | GNUNET_i2s(id), GNUNET_i2s(&master_deamon->id)); | ||
690 | GNUNET_TESTING_daemons_connect(d, | ||
691 | master_deamon, | ||
692 | TIMEOUT, | ||
693 | 0, | ||
694 | GNUNET_YES, | ||
695 | &daemon_connect_cb, | ||
696 | NULL); | ||
697 | } | ||
698 | |||
699 | if (peers_left == 0) | ||
700 | { | ||
701 | if (ping_deamon == NULL) | ||
702 | { | ||
703 | ping_deamon = d; | ||
704 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
705 | "Ping peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile); | ||
706 | } | ||
707 | |||
708 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
709 | "All peers started successfully!\n"); | ||
710 | connect_peers(); | ||
711 | ok = 0; | ||
712 | } | ||
713 | else if (failed_peers == peers_left) | ||
714 | { | ||
715 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
716 | "Too many peers failed, ending test!\n"); | ||
717 | shutdown_peers(); | ||
718 | ok = 1; | ||
719 | } | ||
720 | } | ||
721 | |||
722 | |||
723 | static void | ||
724 | run (void *cls, | ||
725 | char *const *args, | ||
726 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
727 | { | ||
728 | ok = 1; | ||
729 | measurement_started = GNUNET_NO; | ||
730 | #if VERBOSE | ||
731 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting %i peers.\n", peers); | ||
732 | #endif | ||
733 | peers_left = peers; | ||
734 | pg = GNUNET_TESTING_daemons_start (cfg, | ||
735 | peers_left, /* Total number of peers */ | ||
736 | peers_left, /* Number of outstanding connections */ | ||
737 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ | ||
738 | TIMEOUT, | ||
739 | NULL, NULL, | ||
740 | &daemon_start_cb, NULL, NULL, NULL, NULL); | ||
741 | GNUNET_assert (pg != NULL); | ||
742 | } | ||
743 | |||
744 | |||
745 | static int | ||
746 | check () | ||
747 | { | ||
748 | char *const argv[] = { "test-testing", | ||
749 | "-c", | ||
750 | config_file, | ||
751 | #if VERBOSE | ||
752 | "-L", "DEBUG", | ||
753 | #endif | ||
754 | NULL | ||
755 | }; | ||
756 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
757 | GNUNET_GETOPT_OPTION_END | ||
758 | }; | ||
759 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | ||
760 | argv, "test-transport-ats", "nohelp", | ||
761 | options, &run, &ok); | ||
762 | return ok; | ||
763 | } | ||
764 | |||
765 | |||
766 | int | ||
767 | main (int argc, char *argv[]) | ||
768 | { | ||
769 | int ret; | ||
770 | |||
771 | GNUNET_log_setup ("test-transport-ats-multiple-peers", | ||
772 | #if VERBOSE | ||
773 | "DEBUG", | ||
774 | #else | ||
775 | "INFO", | ||
776 | #endif | ||
777 | NULL); | ||
778 | |||
779 | #if !HAVE_LIBGLPK && !HAVE_GLPK | ||
780 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
781 | "GLPK not installed, exiting testcase\n"); | ||
782 | return 0; | ||
783 | #endif | ||
784 | |||
785 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing"); | ||
786 | machine_parsable = GNUNET_NO; | ||
787 | peers = NUM_PEERS; | ||
788 | config_file = "test_transport_ats_4addr.conf"; | ||
789 | |||
790 | int c = 0; | ||
791 | if (argc >= 2) | ||
792 | { | ||
793 | for (c=0; c<argc; c++) | ||
794 | { | ||
795 | /* set peers */ | ||
796 | if ((strcmp(argv[c], "-p") == 0) && c < (argc-1)) | ||
797 | { | ||
798 | peers = atoi(argv[c+1]); | ||
799 | peers++; | ||
800 | } | ||
801 | /* set machine parsable */ | ||
802 | if (strcmp(argv[c], "-m") == 0) | ||
803 | { | ||
804 | machine_parsable = GNUNET_YES; | ||
805 | } | ||
806 | /* set config file */ | ||
807 | if ((strcmp(argv[c], "-c") == 0) && c < (argc-1)) | ||
808 | { | ||
809 | config_file = argv[c+1]; | ||
810 | } | ||
811 | } | ||
812 | } | ||
813 | |||
814 | |||
815 | |||
816 | ret = check (); | ||
817 | /** | ||
818 | * Still need to remove the base testing directory here, | ||
819 | * because group starts will create subdirectories under this | ||
820 | * main dir. However, we no longer need to sleep, as the | ||
821 | * shutdown sequence won't return until everything is cleaned | ||
822 | * up. | ||
823 | */ | ||
824 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing"); | ||
825 | return ret; | ||
826 | } | ||
827 | |||
828 | /* end of test_transport_ats_multiple_peers.c*/ | ||