diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-06-05 13:07:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-06-05 13:07:13 +0000 |
commit | 187f3ee1b6edac986b7bc46c62c86a138290b147 (patch) | |
tree | 809c2751509e7111ad26e802e5df8d2332c24455 /src/transport/test_transport_ats.c | |
parent | 2850662595ec7d25aaaf9674e987449375960c23 (diff) | |
download | gnunet-187f3ee1b6edac986b7bc46c62c86a138290b147.tar.gz gnunet-187f3ee1b6edac986b7bc46c62c86a138290b147.zip |
adapting testcases to use new API
Diffstat (limited to 'src/transport/test_transport_ats.c')
-rw-r--r-- | src/transport/test_transport_ats.c | 955 |
1 files changed, 503 insertions, 452 deletions
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c index 08f38398e..314d78172 100644 --- a/src/transport/test_transport_ats.c +++ b/src/transport/test_transport_ats.c | |||
@@ -63,12 +63,12 @@ struct GNUNET_STATISTICS_Handle * stats; | |||
63 | 63 | ||
64 | struct TEST_result | 64 | struct TEST_result |
65 | { | 65 | { |
66 | uint64_t timestamp; | 66 | uint64_t timestamp; |
67 | uint64_t duration; | 67 | uint64_t duration; |
68 | uint64_t mechs; | 68 | uint64_t mechs; |
69 | uint64_t peers; | 69 | uint64_t peers; |
70 | uint64_t solution; | 70 | uint64_t solution; |
71 | uint64_t state; | 71 | uint64_t state; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | struct TestMessage | 74 | struct TestMessage |
@@ -109,13 +109,14 @@ struct GNUNET_TRANSPORT_Handle * th; | |||
109 | /** | 109 | /** |
110 | * Check whether peers successfully shut down. | 110 | * Check whether peers successfully shut down. |
111 | */ | 111 | */ |
112 | void | 112 | static void |
113 | shutdown_callback (void *cls, const char *emsg) | 113 | shutdown_callback (void *cls, const char *emsg) |
114 | { | 114 | { |
115 | if (emsg != NULL) | 115 | if (emsg != NULL) |
116 | { | 116 | { |
117 | #if VERBOSE | 117 | #if VERBOSE |
118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); | 118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
119 | "Shutdown of peers failed!\n"); | ||
119 | #endif | 120 | #endif |
120 | if (ok == 0) | 121 | if (ok == 0) |
121 | ok = 666; | 122 | ok = 666; |
@@ -132,464 +133,511 @@ shutdown_callback (void *cls, const char *emsg) | |||
132 | } | 133 | } |
133 | } | 134 | } |
134 | 135 | ||
135 | static void shutdown_peers() | 136 | static void |
137 | shutdown_peers() | ||
136 | { | 138 | { |
137 | if (shutdown_task != GNUNET_SCHEDULER_NO_TASK) | 139 | if (shutdown_task != GNUNET_SCHEDULER_NO_TASK) |
138 | { | 140 | { |
139 | GNUNET_SCHEDULER_cancel(shutdown_task); | 141 | GNUNET_SCHEDULER_cancel(shutdown_task); |
140 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | 142 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; |
141 | } | 143 | } |
142 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | 144 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) |
143 | { | 145 | { |
144 | GNUNET_SCHEDULER_cancel(stats_task); | 146 | GNUNET_SCHEDULER_cancel(stats_task); |
145 | stats_task = GNUNET_SCHEDULER_NO_TASK; | 147 | stats_task = GNUNET_SCHEDULER_NO_TASK; |
146 | } | 148 | } |
147 | if (send_task != GNUNET_SCHEDULER_NO_TASK) | 149 | if (send_task != GNUNET_SCHEDULER_NO_TASK) |
148 | { | 150 | { |
149 | GNUNET_SCHEDULER_cancel(send_task); | 151 | GNUNET_SCHEDULER_cancel(send_task); |
150 | send_task = GNUNET_SCHEDULER_NO_TASK; | 152 | send_task = GNUNET_SCHEDULER_NO_TASK; |
151 | } | 153 | } |
152 | 154 | ||
153 | if (t!=NULL) | 155 | if (t != NULL) |
154 | { | 156 | { |
155 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(t); | 157 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(t); |
156 | t = NULL; | 158 | t = NULL; |
157 | } | 159 | } |
158 | 160 | GNUNET_TRANSPORT_disconnect(th); | |
159 | GNUNET_TRANSPORT_disconnect(th); | 161 | if (s_time != NULL) |
160 | 162 | { | |
161 | if (s_time != NULL) | 163 | GNUNET_STATISTICS_get_cancel(s_time); |
162 | { | 164 | s_time = NULL; |
163 | GNUNET_STATISTICS_get_cancel(s_time); | 165 | } |
164 | s_time = NULL; | 166 | if (s_peers != NULL) |
165 | } | 167 | { |
166 | if (s_peers != NULL) | 168 | GNUNET_STATISTICS_get_cancel(s_peers); |
167 | { | 169 | s_peers = NULL; |
168 | GNUNET_STATISTICS_get_cancel(s_peers); | 170 | } |
169 | s_peers = NULL; | 171 | if (s_mechs != NULL) |
170 | } | 172 | { |
171 | if (s_mechs != NULL) | 173 | GNUNET_STATISTICS_get_cancel(s_mechs); |
172 | { | 174 | s_mechs = NULL; |
173 | GNUNET_STATISTICS_get_cancel(s_mechs); | 175 | } |
174 | s_mechs = NULL; | 176 | if (s_solution != NULL) |
175 | } | 177 | { |
176 | if (s_solution != NULL) | 178 | GNUNET_STATISTICS_get_cancel(s_solution); |
177 | { | 179 | s_solution = NULL; |
178 | GNUNET_STATISTICS_get_cancel(s_solution); | 180 | } |
179 | s_solution = NULL; | 181 | if (s_duration != NULL) |
180 | } | 182 | { |
181 | if (s_duration != NULL) | 183 | GNUNET_STATISTICS_get_cancel(s_duration); |
182 | { | 184 | s_duration = NULL; |
183 | GNUNET_STATISTICS_get_cancel(s_duration); | 185 | } |
184 | s_duration = NULL; | 186 | if (s_invalid != NULL) |
185 | } | 187 | { |
186 | if (s_invalid != NULL) | 188 | GNUNET_STATISTICS_get_cancel(s_invalid); |
187 | { | 189 | s_invalid = NULL; |
188 | GNUNET_STATISTICS_get_cancel(s_invalid); | 190 | } |
189 | s_invalid = NULL; | 191 | if (s_state != NULL) |
190 | } | 192 | { |
191 | if (s_state != NULL) | 193 | GNUNET_STATISTICS_get_cancel(s_state); |
192 | { | 194 | s_state = NULL; |
193 | GNUNET_STATISTICS_get_cancel(s_state); | 195 | } |
194 | s_state = NULL; | 196 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
195 | } | ||
196 | |||
197 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | ||
198 | } | 197 | } |
199 | 198 | ||
200 | static void evaluate_measurements() | 199 | static void |
200 | evaluate_measurements() | ||
201 | { | 201 | { |
202 | int c; | 202 | int c; |
203 | //int mechs = 0; | 203 | //int mechs = 0; |
204 | double average[3]; | 204 | double average[3]; |
205 | double stddev[3]; | 205 | double stddev[3]; |
206 | //char * output; | 206 | //char * output; |
207 | c = 1; | 207 | c = 1; |
208 | 208 | ||
209 | //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, results_modified[0].mechs, | 209 | //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, results_modified[0].mechs, |
210 | 210 | ||
211 | average[0] = 0.0; | 211 | average[0] = 0.0; |
212 | for (c=0; c<c_new;c++) | 212 | for (c=0; c<c_new;c++) |
213 | { | 213 | { |
214 | average[0] += (double) results_new[c].duration; | 214 | average[0] += (double) results_new[c].duration; |
215 | } | 215 | } |
216 | average[0] /= c_new; | 216 | average[0] /= c_new; |
217 | 217 | ||
218 | stddev[0] = 0.0; | 218 | stddev[0] = 0.0; |
219 | for (c=0; c<c_new;c++) | 219 | for (c=0; c<c_new;c++) |
220 | { | 220 | { |
221 | stddev[0] += (results_new[c].duration - average[0]) * (results_new[c].duration - average[0]); | 221 | stddev[0] += (results_new[c].duration - average[0]) * (results_new[c].duration - average[0]); |
222 | } | 222 | } |
223 | stddev[0] /= c_new; | 223 | stddev[0] /= c_new; |
224 | stddev[0] = sqrt (stddev[0]); | 224 | stddev[0] = sqrt (stddev[0]); |
225 | if (!machine_parsable) | 225 | if (!machine_parsable) |
226 | fprintf (stderr, | 226 | fprintf (stderr, |
227 | "new, %i measurements, average: %f stddev: %f\n", | 227 | "new, %i measurements, average: %f stddev: %f\n", |
228 | c_new, average[0], stddev[0]); | 228 | c_new, average[0], stddev[0]); |
229 | 229 | ||
230 | average[1] = 0.0; | 230 | average[1] = 0.0; |
231 | for (c=0; c<c_modified;c++) | 231 | for (c=0; c<c_modified;c++) |
232 | { | 232 | { |
233 | average[1] += (double) results_modified[c].duration; | 233 | average[1] += (double) results_modified[c].duration; |
234 | } | 234 | } |
235 | average[1] /= c_modified; | 235 | average[1] /= c_modified; |
236 | 236 | ||
237 | stddev[1] = 0.0; | 237 | stddev[1] = 0.0; |
238 | for (c=0; c<c_modified;c++) | 238 | for (c=0; c<c_modified;c++) |
239 | { | 239 | { |
240 | stddev[1] += (results_modified[c].duration - average[1]) * (results_modified[c].duration - average[1]); | 240 | stddev[1] += (results_modified[c].duration - average[1]) * (results_modified[c].duration - average[1]); |
241 | } | 241 | } |
242 | stddev[1] /= c_modified; | 242 | stddev[1] /= c_modified; |
243 | stddev[1] = sqrt (stddev[1]); | 243 | stddev[1] = sqrt (stddev[1]); |
244 | if (!machine_parsable) | 244 | if (!machine_parsable) |
245 | fprintf (stderr, | 245 | fprintf (stderr, |
246 | "modified, %i measurements, average: %f stddev: %f\n", | 246 | "modified, %i measurements, average: %f stddev: %f\n", |
247 | c_modified, average[1], stddev[1]); | 247 | c_modified, average[1], stddev[1]); |
248 | 248 | ||
249 | average[2] = 0.0; | 249 | average[2] = 0.0; |
250 | for (c=0; c<c_unmodified;c++) | 250 | for (c=0; c<c_unmodified;c++) |
251 | { | 251 | { |
252 | average[2] += (double) results_unmodified[c].duration; | 252 | average[2] += (double) results_unmodified[c].duration; |
253 | } | 253 | } |
254 | average[2] /= c_unmodified; | 254 | average[2] /= c_unmodified; |
255 | stddev[2] = 0.0; | 255 | stddev[2] = 0.0; |
256 | for (c=0; c<c_unmodified;c++) | 256 | for (c=0; c<c_unmodified;c++) |
257 | { | 257 | { |
258 | stddev[2] += (results_unmodified[c].duration - average[2]) * (results_unmodified[c].duration - average[2]); | 258 | stddev[2] += (results_unmodified[c].duration - average[2]) * (results_unmodified[c].duration - average[2]); |
259 | } | 259 | } |
260 | stddev[2] /= c_unmodified; | 260 | stddev[2] /= c_unmodified; |
261 | stddev[2] = sqrt (stddev[2]); | 261 | stddev[2] = sqrt (stddev[2]); |
262 | 262 | ||
263 | if (!machine_parsable) | 263 | if (!machine_parsable) |
264 | fprintf (stderr, | 264 | fprintf (stderr, |
265 | "unmodified, %i measurements, average: %f stddev: %f\n", | 265 | "unmodified, %i measurements, average: %f stddev: %f\n", |
266 | c_unmodified, average[2], stddev[2]); | 266 | c_unmodified, average[2], stddev[2]); |
267 | 267 | ||
268 | if (machine_parsable) | 268 | if (machine_parsable) |
269 | fprintf (stderr, | 269 | fprintf (stderr, |
270 | "peers,%i,mechs,%llu," | 270 | "peers,%i,mechs,%llu," |
271 | "new,%i,%f,%f," | 271 | "new,%i,%f,%f," |
272 | "mod,%i,%f,%f," | 272 | "mod,%i,%f,%f," |
273 | "unmod,%i,%f,%f\n", | 273 | "unmod,%i,%f,%f\n", |
274 | peers-1, (unsigned long long) results_unmodified[0].mechs, | 274 | peers-1, (unsigned long long) results_unmodified[0].mechs, |
275 | c_new, average[0], stddev[0], | 275 | c_new, average[0], stddev[0], |
276 | c_modified, average[1], stddev[1], | 276 | c_modified, average[1], stddev[1], |
277 | c_unmodified, average[2], stddev[2]); | 277 | c_unmodified, average[2], stddev[2]); |
278 | shutdown_peers(); | 278 | shutdown_peers(); |
279 | } | 279 | } |
280 | 280 | ||
281 | int stats_cb (void *cls, | ||
282 | const char *subsystem, | ||
283 | const char *name, | ||
284 | uint64_t value, | ||
285 | int is_persistent) | ||
286 | { | ||
287 | static int printed = GNUNET_NO; | ||
288 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s = %llu\n", name ,value); | ||
289 | if (0 == strcmp (name,"ATS invalid solutions")) | ||
290 | { | ||
291 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | ||
292 | { | ||
293 | GNUNET_SCHEDULER_cancel(stats_task); | ||
294 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
295 | } | ||
296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"MLP produced invalid %llu result(s)!\n", value); | ||
297 | shutdown_peers(); | ||
298 | return GNUNET_SYSERR; | ||
299 | } | ||
300 | |||
301 | if (0 == strcmp (name,"ATS solution")) | ||
302 | { | ||
303 | s_solution = NULL; | ||
304 | } | ||
305 | |||
306 | if (0 == strcmp (name,"ATS peers")) | ||
307 | { | ||
308 | s_peers = NULL; | ||
309 | } | ||
310 | |||
311 | if (0 == strcmp (name,"ATS mechanisms")) | ||
312 | { | ||
313 | s_mechs = NULL; | ||
314 | } | ||
315 | 281 | ||
316 | if (0 == strcmp (name,"ATS duration")) | 282 | static int |
317 | { | 283 | stats_cb (void *cls, |
318 | s_duration = NULL; | 284 | const char *subsystem, |
319 | } | 285 | const char *name, |
320 | if (0 == strcmp (name,"ATS timestamp")) | 286 | uint64_t value, |
321 | { | 287 | int is_persistent) |
322 | s_time = NULL; | 288 | { |
323 | } | 289 | static int printed = GNUNET_NO; |
324 | if (0 == strcmp (name,"ATS state")) | 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) | ||
325 | { | 294 | { |
326 | s_state = NULL; | 295 | GNUNET_SCHEDULER_cancel(stats_task); |
296 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
327 | } | 297 | } |
328 | 298 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"MLP produced invalid %llu result(s)!\n", value); | |
329 | if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == peers-1)) | 299 | shutdown_peers(); |
300 | return GNUNET_SYSERR; | ||
301 | } | ||
302 | |||
303 | if (0 == strcmp (name,"ATS solution")) | ||
330 | { | 304 | { |
331 | measurement_started = GNUNET_YES; | 305 | s_solution = NULL; |
332 | count = 1; | ||
333 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value); | ||
334 | #if !VERBOSE | ||
335 | if (!machine_parsable) fprintf(stderr, "%i", count); | ||
336 | #endif | ||
337 | } | 306 | } |
338 | 307 | ||
339 | if (measurement_started == GNUNET_YES) | 308 | if (0 == strcmp (name,"ATS peers")) |
340 | { | 309 | { |
341 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value); | 310 | s_peers = NULL; |
342 | if (0 == strcmp (name,"ATS timestamp")) | 311 | } |
343 | { | 312 | |
344 | if (current.timestamp == 0) | 313 | if (0 == strcmp (name,"ATS mechanisms")) |
345 | { | 314 | { |
346 | printed = GNUNET_NO; | 315 | s_mechs = NULL; |
347 | current.timestamp = value; | 316 | } |
348 | } | 317 | |
349 | if (current.timestamp == value) | 318 | if (0 == strcmp (name,"ATS duration")) |
350 | { | 319 | { |
351 | printed = GNUNET_YES; | 320 | s_duration = NULL; |
352 | } | 321 | } |
353 | if (current.timestamp != value) | 322 | if (0 == strcmp (name,"ATS timestamp")) |
354 | { | 323 | { |
355 | if (current.state == ATS_NEW) | 324 | s_time = NULL; |
356 | { | 325 | } |
357 | if (c_new < MEASUREMENTS) | 326 | if (0 == strcmp (name,"ATS state")) |
358 | { | 327 | { |
359 | results_new[c_new] = current; | 328 | s_state = NULL; |
360 | c_new++; | 329 | } |
361 | } | 330 | |
362 | else | 331 | if ( (measurement_started == GNUNET_NO) && |
363 | { | 332 | (0 == strcmp (name, "ATS peers")) && |
364 | force_rebuild = GNUNET_NO; | 333 | (value == peers-1) ) |
365 | force_q_updates = GNUNET_NO; | 334 | { |
366 | send_msg = GNUNET_NO; | 335 | measurement_started = GNUNET_YES; |
367 | } | 336 | count = 1; |
368 | } | 337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
369 | if (current.state == ATS_UNMODIFIED) | 338 | "All %llu peers connected\n", |
370 | { | 339 | value); |
371 | if (c_unmodified < MEASUREMENTS) | ||
372 | { | ||
373 | results_unmodified[c_unmodified] = current; | ||
374 | c_unmodified++; | ||
375 | } | ||
376 | |||
377 | } | ||
378 | if (current.state == ATS_Q_UPDATED) | ||
379 | { | ||
380 | if (c_modified < MEASUREMENTS) | ||
381 | { | ||
382 | results_modified[c_modified] = current; | ||
383 | c_modified++; | ||
384 | } | ||
385 | else | ||
386 | { | ||
387 | force_q_updates = GNUNET_NO; | ||
388 | force_rebuild = GNUNET_YES; | ||
389 | } | ||
390 | } | ||
391 | count ++; | ||
392 | #if VERBOSE | ||
393 | fprintf (stderr, | ||
394 | "(new: %i / modified: %i / unmodified: %i) of %i \n", | ||
395 | c_new, c_modified, c_unmodified , MEASUREMENTS); | ||
396 | #endif | ||
397 | if ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS)) | ||
398 | { | ||
399 | #if !VERBOSE | ||
400 | if (!machine_parsable) fprintf(stdout, "\n"); | ||
401 | #endif | ||
402 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) | ||
403 | { | ||
404 | GNUNET_SCHEDULER_cancel(stats_task); | ||
405 | stats_task = GNUNET_SCHEDULER_NO_TASK; | ||
406 | } | ||
407 | evaluate_measurements(); | ||
408 | return GNUNET_SYSERR; | ||
409 | } | ||
410 | |||
411 | printed = GNUNET_NO; | ||
412 | current.timestamp = value; | ||
413 | #if !VERBOSE | 340 | #if !VERBOSE |
414 | if (!machine_parsable) fprintf(stderr, "..%i", count); | 341 | if (! machine_parsable) |
342 | fprintf(stderr, "%i", count); | ||
415 | #endif | 343 | #endif |
416 | return GNUNET_OK; | 344 | } |
417 | } | 345 | |
418 | } | 346 | if (measurement_started == GNUNET_YES) |
419 | 347 | { | |
420 | if (0 == strcmp (name,"ATS solution")) | 348 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value); |
421 | { | 349 | if (0 == strcmp (name,"ATS timestamp")) |
422 | current.solution = value; | 350 | { |
423 | if (printed == GNUNET_NO) | 351 | if (current.timestamp == 0) |
424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); | 352 | { |
425 | } | 353 | printed = GNUNET_NO; |
426 | 354 | current.timestamp = value; | |
427 | if (0 == strcmp (name,"ATS peers")) | 355 | } |
356 | if (current.timestamp == value) | ||
357 | { | ||
358 | printed = GNUNET_YES; | ||
359 | } | ||
360 | if (current.timestamp != value) | ||
361 | { | ||
362 | if (current.state == ATS_NEW) | ||
428 | { | 363 | { |
429 | current.peers = value; | 364 | if (c_new < MEASUREMENTS) |
430 | if (printed == GNUNET_NO) | 365 | { |
431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); | 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 | } | ||
432 | } | 375 | } |
433 | 376 | if (current.state == ATS_UNMODIFIED) | |
434 | if (0 == strcmp (name,"ATS mechanisms")) | ||
435 | { | 377 | { |
436 | current.mechs = value; | 378 | if (c_unmodified < MEASUREMENTS) |
437 | if (printed == GNUNET_NO) | 379 | { |
438 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); | 380 | results_unmodified[c_unmodified] = current; |
381 | c_unmodified++; | ||
382 | } | ||
383 | |||
439 | } | 384 | } |
440 | 385 | if (current.state == ATS_Q_UPDATED) | |
441 | if (0 == strcmp (name,"ATS duration")) | ||
442 | { | 386 | { |
443 | current.duration = value; | 387 | if (c_modified < MEASUREMENTS) |
444 | if (printed == GNUNET_NO) | 388 | { |
445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); | 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 | } | ||
446 | } | 397 | } |
447 | if (0 == strcmp (name,"ATS state")) | 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)) | ||
448 | { | 405 | { |
449 | current.state = value; | 406 | #if !VERBOSE |
450 | char * cont; | 407 | if (!machine_parsable) |
451 | if (value == ATS_NEW) | 408 | fprintf(stdout, "\n"); |
452 | cont = "NEW"; | 409 | #endif |
453 | if (value == ATS_C_UPDATED) | 410 | if (stats_task != GNUNET_SCHEDULER_NO_TASK) |
454 | cont = "C_UPDATED"; | 411 | { |
455 | if (value == ATS_Q_UPDATED) | 412 | GNUNET_SCHEDULER_cancel(stats_task); |
456 | cont = "Q_UPDATED"; | 413 | stats_task = GNUNET_SCHEDULER_NO_TASK; |
457 | if (value == ATS_QC_UPDATED) | 414 | } |
458 | cont = "QC_UPDATED"; | 415 | evaluate_measurements(); |
459 | if (value == ATS_UNMODIFIED) | 416 | return GNUNET_SYSERR; |
460 | cont = "UNMODIFIED"; | ||
461 | if (printed == GNUNET_NO) | ||
462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS state: %s\n", count, cont); | ||
463 | } | 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 | } | ||
464 | } | 474 | } |
465 | return GNUNET_OK; | 475 | return GNUNET_OK; |
466 | } | 476 | } |
467 | 477 | ||
468 | 478 | ||
469 | void | 479 | static void |
470 | stats_get_task (void *cls, | 480 | stats_get_task (void *cls, |
471 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 481 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
472 | { | 482 | { |
473 | stats_task = GNUNET_SCHEDULER_NO_TASK; | 483 | stats_task = GNUNET_SCHEDULER_NO_TASK; |
474 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 484 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
475 | return; | 485 | return; |
476 | 486 | ||
477 | s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL); | 487 | s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL); |
478 | s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL); | 488 | s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL); |
479 | s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL); | 489 | s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL); |
480 | s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); | 490 | s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); |
481 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); | 491 | s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); |
482 | s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", TIMEOUT, NULL, &stats_cb, NULL); | 492 | s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", TIMEOUT, NULL, &stats_cb, NULL); |
483 | s_state = GNUNET_STATISTICS_get (stats, "transport", "ATS state", TIMEOUT, NULL, &stats_cb, NULL); | 493 | s_state = GNUNET_STATISTICS_get (stats, "transport", "ATS state", TIMEOUT, NULL, &stats_cb, NULL); |
484 | 494 | ||
485 | stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), &stats_get_task, NULL); | 495 | stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), |
496 | &stats_get_task, NULL); | ||
486 | } | 497 | } |
487 | 498 | ||
488 | void | 499 | |
500 | static void | ||
489 | delay (void *cls, | 501 | delay (void *cls, |
490 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 502 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
491 | { | 503 | { |
492 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | 504 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; |
493 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 505 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
494 | return; | 506 | return; |
495 | |||
496 | #if VERBOSE | 507 | #if VERBOSE |
497 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Delay over\n"); | 508 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
509 | "Delay over\n"); | ||
498 | #endif | 510 | #endif |
499 | shutdown_peers (); | 511 | shutdown_peers (); |
500 | } | 512 | } |
501 | 513 | ||
502 | static void connect_peers() | 514 | static void |
515 | connect_peers() | ||
503 | { | 516 | { |
504 | shutdown_task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay, NULL); | 517 | shutdown_task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay, NULL); |
505 | |||
506 | } | 518 | } |
507 | 519 | ||
508 | size_t send_dummy_data_task (void *cls, size_t size, void *buf) | 520 | static size_t |
521 | send_dummy_data_task (void *cls, size_t size, void *buf) | ||
509 | { | 522 | { |
510 | 523 | int s = sizeof (struct TestMessage); | |
511 | int s = sizeof (struct TestMessage); | 524 | struct TestMessage hdr; |
512 | struct TestMessage hdr; | 525 | |
513 | 526 | hdr.header.size = htons (s); | |
514 | hdr.header.size = htons (s); | 527 | hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ATS); |
515 | hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ATS); | 528 | if (force_rebuild) |
516 | if (force_rebuild) | 529 | hdr.num = htonl (1); |
517 | hdr.num = htonl (1); | 530 | if (force_q_updates) |
518 | if (force_q_updates) | 531 | hdr.num = htonl (2); |
519 | 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 | } | ||
520 | 537 | ||
521 | 538 | ||
522 | memcpy (buf,&hdr, s); | 539 | static void |
523 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i of %i\n", s, s); | 540 | send_task_f (void *cls, |
524 | t = NULL; | 541 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
525 | return s; | 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); | ||
526 | } | 561 | } |
527 | 562 | ||
528 | void send_task_f (void *cls, | 563 | static void |
529 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 564 | notify_connect (void *cls, |
565 | const struct GNUNET_PeerIdentity *peer, | ||
566 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | ||
567 | uint32_t ats_count) | ||
530 | { | 568 | { |
531 | send_task = GNUNET_SCHEDULER_NO_TASK; | 569 | send_task = GNUNET_SCHEDULER_add_now(&send_task_f, NULL); |
532 | if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
533 | return; | ||
534 | |||
535 | if (t!=NULL) | ||
536 | { | ||
537 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(t); | ||
538 | t = NULL; | ||
539 | } | ||
540 | // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i to %s\n", size, GNUNET_i2s(&master_deamon->id)); | ||
541 | if (send_msg == GNUNET_YES) | ||
542 | t = GNUNET_TRANSPORT_notify_transmit_ready(th, &master_deamon->id, sizeof (struct TestMessage), 0, SEND_TIMEOUT, &send_dummy_data_task, NULL); | ||
543 | send_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,1000), &send_task_f, NULL); | ||
544 | } | 570 | } |
545 | 571 | ||
546 | 572 | static void | |
547 | 573 | notify_disconnect (void *cls, | |
548 | void daemon_connect_cb(void *cls, | 574 | const struct GNUNET_PeerIdentity *peer) |
549 | const struct GNUNET_PeerIdentity *first, | ||
550 | const struct GNUNET_PeerIdentity *second, | ||
551 | uint32_t distance, | ||
552 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | ||
553 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | ||
554 | struct GNUNET_TESTING_Daemon *first_daemon, | ||
555 | struct GNUNET_TESTING_Daemon *second_daemon, | ||
556 | const char *emsg) | ||
557 | { | 575 | { |
558 | char * firstc = strdup(GNUNET_i2s(first)); | 576 | if (GNUNET_SCHEDULER_NO_TASK != send_task) |
559 | char * secondc = strdup(GNUNET_i2s(second)); | 577 | { |
560 | connected++; | 578 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
561 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 579 | "Disconnect event before transmission request could be scheduled!\n"); |
562 | "Connected peers `%s'<->`%s' (%i/%i)\n", firstc, secondc, connected, peers-1); | 580 | GNUNET_SCHEDULER_cancel (send_task); |
563 | GNUNET_free(firstc); | 581 | send_task = GNUNET_SCHEDULER_NO_TASK; |
564 | GNUNET_free(secondc); | 582 | } |
565 | 583 | if (NULL != t) | |
566 | if (((first_daemon == ping_deamon) || (second_daemon == ping_deamon)) && (master_deamon != NULL) && (ping_deamon != NULL)) | 584 | { |
567 | { | 585 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
568 | th = GNUNET_TRANSPORT_connect (ping_deamon->cfg,&ping_deamon->id, NULL, NULL,NULL, NULL); | 586 | "Disconnect event before transmission request could be completed!\n"); |
569 | t = NULL; | 587 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (t); |
570 | force_q_updates = GNUNET_YES; | 588 | t = NULL; |
571 | send_msg = GNUNET_YES; | 589 | } |
572 | send_task = GNUNET_SCHEDULER_add_now(&send_task_f, NULL); | ||
573 | } | ||
574 | } | 590 | } |
575 | 591 | ||
576 | void cont_cb (void *cls, int success) | 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) | ||
577 | { | 602 | { |
578 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 603 | char * firstc = strdup(GNUNET_i2s(first)); |
579 | "STATS cont_cb: %i\n", success); | 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 | } | ||
580 | } | 625 | } |
581 | 626 | ||
627 | |||
628 | |||
582 | static void | 629 | static void |
583 | daemon_start_cb (void *cls, | 630 | daemon_start_cb (void *cls, |
584 | const struct GNUNET_PeerIdentity *id, | 631 | const struct GNUNET_PeerIdentity *id, |
585 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 632 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
586 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 633 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
587 | { | 634 | { |
588 | if (id == NULL) | 635 | if (id == NULL) |
589 | { | 636 | { |
590 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
591 | "Start callback called with error (too long starting peers), aborting test!\n"); | 638 | "Start callback called with error (too long starting peers), aborting test!\n"); |
592 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error from testing: `%s'\n"); | 639 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
640 | "Error from testing: `%s'\n"); | ||
593 | failed_peers++; | 641 | failed_peers++; |
594 | if (failed_peers == peers_left) | 642 | if (failed_peers == peers_left) |
595 | { | 643 | { |
@@ -603,29 +651,33 @@ daemon_start_cb (void *cls, | |||
603 | peers_left--; | 651 | peers_left--; |
604 | 652 | ||
605 | if (master_deamon == NULL) | 653 | if (master_deamon == NULL) |
606 | { | 654 | { |
607 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile); | 655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
608 | 656 | "Master peer `%s' '%s'\n", | |
609 | master_deamon = d; | 657 | GNUNET_i2s(id), d->cfgfile); |
610 | stats = GNUNET_STATISTICS_create("transport", master_deamon->cfg); | 658 | master_deamon = d; |
611 | GNUNET_assert (stats != NULL); | 659 | stats = GNUNET_STATISTICS_create("transport", master_deamon->cfg); |
612 | stats_task = GNUNET_SCHEDULER_add_now(&stats_get_task, NULL); | 660 | GNUNET_assert (stats != NULL); |
613 | } | 661 | stats_task = GNUNET_SCHEDULER_add_now(&stats_get_task, NULL); |
662 | } | ||
614 | else | 663 | else |
615 | { | 664 | { |
616 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer `%s'\n", GNUNET_i2s(id), GNUNET_i2s(&master_deamon->id)); | 665 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
617 | GNUNET_TESTING_daemons_connect(d, master_deamon, TIMEOUT, 0, GNUNET_YES,&daemon_connect_cb, NULL); | 666 | "Connecting peer `%s'\n", |
618 | } | 667 | GNUNET_i2s(id), GNUNET_i2s(&master_deamon->id)); |
619 | 668 | GNUNET_TESTING_daemons_connect(d, master_deamon, TIMEOUT, 0, GNUNET_YES,&daemon_connect_cb, NULL); | |
669 | } | ||
670 | |||
620 | if (peers_left == 0) | 671 | if (peers_left == 0) |
621 | { | 672 | { |
622 | if (ping_deamon == NULL) | 673 | if (ping_deamon == NULL) |
623 | { | 674 | { |
624 | ping_deamon = d; | 675 | ping_deamon = d; |
625 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ping peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile); | 676 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
626 | } | 677 | "Ping peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile); |
627 | 678 | } | |
628 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 679 | |
680 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
629 | "All peers started successfully!\n"); | 681 | "All peers started successfully!\n"); |
630 | connect_peers(); | 682 | connect_peers(); |
631 | ok = 0; | 683 | ok = 0; |
@@ -661,6 +713,7 @@ run (void *cls, | |||
661 | GNUNET_assert (pg != NULL); | 713 | GNUNET_assert (pg != NULL); |
662 | } | 714 | } |
663 | 715 | ||
716 | |||
664 | static int | 717 | static int |
665 | check () | 718 | check () |
666 | { | 719 | { |
@@ -681,10 +734,10 @@ check () | |||
681 | return ok; | 734 | return ok; |
682 | } | 735 | } |
683 | 736 | ||
737 | |||
684 | int | 738 | int |
685 | main (int argc, char *argv[]) | 739 | main (int argc, char *argv[]) |
686 | { | 740 | { |
687 | |||
688 | int ret; | 741 | int ret; |
689 | 742 | ||
690 | GNUNET_log_setup ("test-transport-ats", | 743 | GNUNET_log_setup ("test-transport-ats", |
@@ -696,40 +749,38 @@ main (int argc, char *argv[]) | |||
696 | NULL); | 749 | NULL); |
697 | 750 | ||
698 | #if !HAVE_LIBGLPK | 751 | #if !HAVE_LIBGLPK |
699 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, exiting testcase\n"); | 752 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
700 | return 0; | 753 | "GLPK not installed, exiting testcase\n"); |
754 | return 0; | ||
701 | #endif | 755 | #endif |
702 | |||
703 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing"); | 756 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing"); |
704 | |||
705 | |||
706 | machine_parsable = GNUNET_NO; | 757 | machine_parsable = GNUNET_NO; |
707 | peers = NUM_PEERS; | 758 | peers = NUM_PEERS; |
708 | config_file = "test_transport_ats_4addr.conf"; | 759 | config_file = "test_transport_ats_4addr.conf"; |
709 | 760 | ||
710 | int c = 0; | 761 | int c = 0; |
711 | if (argc >= 2) | 762 | if (argc >= 2) |
712 | { | 763 | { |
713 | for (c=0; c<argc; c++) | 764 | for (c=0; c<argc; c++) |
714 | { | 765 | { |
715 | /* set peers */ | 766 | /* set peers */ |
716 | if ((strcmp(argv[c], "-p") == 0) && c < (argc-1)) | 767 | if ((strcmp(argv[c], "-p") == 0) && c < (argc-1)) |
717 | { | 768 | { |
718 | peers = atoi(argv[c+1]); | 769 | peers = atoi(argv[c+1]); |
719 | peers++; | 770 | peers++; |
720 | } | 771 | } |
721 | /* set machine parsable */ | 772 | /* set machine parsable */ |
722 | if (strcmp(argv[c], "-m") == 0) | 773 | if (strcmp(argv[c], "-m") == 0) |
723 | { | 774 | { |
724 | machine_parsable = GNUNET_YES; | 775 | machine_parsable = GNUNET_YES; |
725 | } | 776 | } |
726 | /* set config file */ | 777 | /* set config file */ |
727 | if ((strcmp(argv[c], "-c") == 0) && c < (argc-1)) | 778 | if ((strcmp(argv[c], "-c") == 0) && c < (argc-1)) |
728 | { | 779 | { |
729 | config_file = argv[c+1]; | 780 | config_file = argv[c+1]; |
730 | } | 781 | } |
731 | } | 782 | } |
732 | } | 783 | } |
733 | 784 | ||
734 | 785 | ||
735 | 786 | ||