diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-01 09:49:17 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-01 09:49:17 +0000 |
commit | 8962c636773aeb4a029b9db542b454bd64b2d915 (patch) | |
tree | 2f822035bca621ea7c8e3c26c2439447a42d4116 /src/transport | |
parent | d7181f0e7bc21fe4d7193cea580d034cd188ea48 (diff) | |
download | gnunet-8962c636773aeb4a029b9db542b454bd64b2d915.tar.gz gnunet-8962c636773aeb4a029b9db542b454bd64b2d915.zip |
porting all tests using testing lib
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/test_transport_api.c | 42 | ||||
-rw-r--r-- | src/transport/test_transport_api_multiaddress.c | 37 | ||||
-rw-r--r-- | src/transport/test_transport_api_reliability.c | 2 | ||||
-rw-r--r-- | src/transport/test_transport_api_unreliability.c | 71 |
4 files changed, 95 insertions, 57 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 15f490947..aac8eb400 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include "transport.h" | 37 | #include "transport.h" |
38 | #include "transport-testing.h" | 38 | #include "transport-testing.h" |
39 | 39 | ||
40 | #define VERBOSE GNUNET_NO | 40 | #define VERBOSE GNUNET_YES |
41 | 41 | ||
42 | #define VERBOSE_ARM GNUNET_NO | 42 | #define VERBOSE_ARM GNUNET_NO |
43 | 43 | ||
@@ -55,6 +55,12 @@ | |||
55 | 55 | ||
56 | #define MTYPE 12345 | 56 | #define MTYPE 12345 |
57 | 57 | ||
58 | static char *test_source; | ||
59 | |||
60 | static char *test_plugin; | ||
61 | |||
62 | static char *test_name; | ||
63 | |||
58 | static int ok; | 64 | static int ok; |
59 | 65 | ||
60 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | 66 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
@@ -229,6 +235,16 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
229 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, ¬ify_receive, | 235 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, ¬ify_receive, |
230 | ¬ify_connect, ¬ify_disconnect, | 236 | ¬ify_connect, ¬ify_disconnect, |
231 | NULL); | 237 | NULL); |
238 | |||
239 | if ((p1 == NULL) || (p2 == NULL)) | ||
240 | { | ||
241 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n"); | ||
242 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | ||
243 | GNUNET_SCHEDULER_cancel (die_task); | ||
244 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
245 | return; | ||
246 | } | ||
247 | |||
232 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, | 248 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, |
233 | NULL); | 249 | NULL); |
234 | } | 250 | } |
@@ -255,8 +271,8 @@ check () | |||
255 | send_task = GNUNET_SCHEDULER_NO_TASK; | 271 | send_task = GNUNET_SCHEDULER_NO_TASK; |
256 | 272 | ||
257 | ok = 1; | 273 | ok = 1; |
258 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | 274 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, test_name, |
259 | "test-transport-api", "nohelp", options, &run, &ok); | 275 | "nohelp", options, &run, &ok); |
260 | 276 | ||
261 | return ok; | 277 | return ok; |
262 | } | 278 | } |
@@ -265,8 +281,14 @@ int | |||
265 | main (int argc, char *argv[]) | 281 | main (int argc, char *argv[]) |
266 | { | 282 | { |
267 | int ret; | 283 | int ret; |
284 | int nat_res; | ||
285 | |||
286 | GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); | ||
287 | GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, | ||
288 | &test_plugin); | ||
289 | GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); | ||
268 | 290 | ||
269 | GNUNET_log_setup ("test-transport-api", | 291 | GNUNET_log_setup (test_name, |
270 | #if VERBOSE | 292 | #if VERBOSE |
271 | "DEBUG", | 293 | "DEBUG", |
272 | #else | 294 | #else |
@@ -274,10 +296,8 @@ main (int argc, char *argv[]) | |||
274 | #endif | 296 | #endif |
275 | NULL); | 297 | NULL); |
276 | 298 | ||
277 | int nat_res; | 299 | if ((strcmp (test_plugin, "tcp_nat") == 0) || |
278 | 300 | (strcmp (test_plugin, "udp_nat") == 0)) | |
279 | if ((strstr (argv[0], "tcp_nat") != NULL) || | ||
280 | (strstr (argv[0], "udp_nat") != NULL)) | ||
281 | { | 301 | { |
282 | nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server"); | 302 | nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server"); |
283 | if (GNUNET_NO == nat_res) | 303 | if (GNUNET_NO == nat_res) |
@@ -292,7 +312,6 @@ main (int argc, char *argv[]) | |||
292 | "gnunet-nat-server", "file not found"); | 312 | "gnunet-nat-server", "file not found"); |
293 | return 0; | 313 | return 0; |
294 | } | 314 | } |
295 | |||
296 | } | 315 | } |
297 | 316 | ||
298 | GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); | 317 | GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); |
@@ -303,6 +322,11 @@ main (int argc, char *argv[]) | |||
303 | GNUNET_free (cfg_file_p1); | 322 | GNUNET_free (cfg_file_p1); |
304 | GNUNET_free (cfg_file_p2); | 323 | GNUNET_free (cfg_file_p2); |
305 | 324 | ||
325 | GNUNET_free (test_source); | ||
326 | GNUNET_free (test_plugin); | ||
327 | GNUNET_free (test_name); | ||
328 | |||
329 | |||
306 | return ret; | 330 | return ret; |
307 | } | 331 | } |
308 | 332 | ||
diff --git a/src/transport/test_transport_api_multiaddress.c b/src/transport/test_transport_api_multiaddress.c index 8204610d7..1096df840 100644 --- a/src/transport/test_transport_api_multiaddress.c +++ b/src/transport/test_transport_api_multiaddress.c | |||
@@ -48,10 +48,17 @@ | |||
48 | * How long until we give up on transmitting the message? | 48 | * How long until we give up on transmitting the message? |
49 | */ | 49 | */ |
50 | #define WAIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 50 | #define WAIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
51 | |||
51 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90) | 52 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90) |
52 | 53 | ||
53 | #define MTYPE 12345 | 54 | #define MTYPE 12345 |
54 | 55 | ||
56 | static char *test_source; | ||
57 | |||
58 | static char *test_plugin; | ||
59 | |||
60 | static char *test_name; | ||
61 | |||
55 | static int ok; | 62 | static int ok; |
56 | 63 | ||
57 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | 64 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
@@ -244,6 +251,16 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
244 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, ¬ify_receive, | 251 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, ¬ify_receive, |
245 | ¬ify_connect, ¬ify_disconnect, | 252 | ¬ify_connect, ¬ify_disconnect, |
246 | NULL); | 253 | NULL); |
254 | |||
255 | if ((p1 == NULL) || (p2 == NULL)) | ||
256 | { | ||
257 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n"); | ||
258 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | ||
259 | GNUNET_SCHEDULER_cancel (die_task); | ||
260 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
261 | return; | ||
262 | } | ||
263 | |||
247 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, | 264 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, |
248 | NULL); | 265 | NULL); |
249 | } | 266 | } |
@@ -280,8 +297,14 @@ int | |||
280 | main (int argc, char *argv[]) | 297 | main (int argc, char *argv[]) |
281 | { | 298 | { |
282 | int ret; | 299 | int ret; |
300 | int nat_res; | ||
283 | 301 | ||
284 | GNUNET_log_setup ("test-transport-api", | 302 | GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); |
303 | GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, | ||
304 | &test_plugin); | ||
305 | GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); | ||
306 | |||
307 | GNUNET_log_setup (test_name, | ||
285 | #if VERBOSE | 308 | #if VERBOSE |
286 | "DEBUG", | 309 | "DEBUG", |
287 | #else | 310 | #else |
@@ -289,10 +312,8 @@ main (int argc, char *argv[]) | |||
289 | #endif | 312 | #endif |
290 | NULL); | 313 | NULL); |
291 | 314 | ||
292 | int nat_res; | 315 | if ((strcmp (test_plugin, "tcp_nat") == 0) || |
293 | 316 | (strcmp (test_plugin, "udp_nat") == 0)) | |
294 | if ((strstr (argv[0], "tcp_nat") != NULL) || | ||
295 | (strstr (argv[0], "udp_nat") != NULL)) | ||
296 | { | 317 | { |
297 | nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server"); | 318 | nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server"); |
298 | if (GNUNET_NO == nat_res) | 319 | if (GNUNET_NO == nat_res) |
@@ -307,7 +328,6 @@ main (int argc, char *argv[]) | |||
307 | "gnunet-nat-server", "file not found"); | 328 | "gnunet-nat-server", "file not found"); |
308 | return 0; | 329 | return 0; |
309 | } | 330 | } |
310 | |||
311 | } | 331 | } |
312 | 332 | ||
313 | GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); | 333 | GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); |
@@ -318,6 +338,11 @@ main (int argc, char *argv[]) | |||
318 | GNUNET_free (cfg_file_p1); | 338 | GNUNET_free (cfg_file_p1); |
319 | GNUNET_free (cfg_file_p2); | 339 | GNUNET_free (cfg_file_p2); |
320 | 340 | ||
341 | GNUNET_free (test_source); | ||
342 | GNUNET_free (test_plugin); | ||
343 | GNUNET_free (test_name); | ||
344 | |||
345 | |||
321 | return ret; | 346 | return ret; |
322 | } | 347 | } |
323 | 348 | ||
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index f0c9d9db8..18769bee0 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c | |||
@@ -47,7 +47,7 @@ | |||
47 | /** | 47 | /** |
48 | * How long until we give up on transmitting the message? | 48 | * How long until we give up on transmitting the message? |
49 | */ | 49 | */ |
50 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1500) | 50 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 900) |
51 | 51 | ||
52 | static char *test_source; | 52 | static char *test_source; |
53 | 53 | ||
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c index 6f6f481fc..2572781ba 100644 --- a/src/transport/test_transport_api_unreliability.c +++ b/src/transport/test_transport_api_unreliability.c | |||
@@ -50,6 +50,12 @@ | |||
50 | */ | 50 | */ |
51 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 900) | 51 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 900) |
52 | 52 | ||
53 | static char *test_source; | ||
54 | |||
55 | static char *test_plugin; | ||
56 | |||
57 | static char *test_name; | ||
58 | |||
53 | static int ok; | 59 | static int ok; |
54 | 60 | ||
55 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | 61 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
@@ -118,12 +124,12 @@ end () | |||
118 | 124 | ||
119 | char *value_name; | 125 | char *value_name; |
120 | 126 | ||
121 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); | 127 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stopping peers\n"); |
122 | 128 | ||
123 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; | 129 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; |
124 | fprintf (stderr, "\nThroughput was %llu kb/s\n", | 130 | fprintf (stderr, "\nThroughput was %llu kb/s\n", |
125 | total_bytes * 1000 / 1024 / delta); | 131 | total_bytes * 1000 / 1024 / delta); |
126 | GNUNET_asprintf (&value_name, "unreliable_%s", test_name); | 132 | GNUNET_asprintf (&value_name, "unreliable_%s", test_plugin); |
127 | GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), | 133 | GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), |
128 | "kb/s"); | 134 | "kb/s"); |
129 | GNUNET_free (value_name); | 135 | GNUNET_free (value_name); |
@@ -435,6 +441,15 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
435 | ¬ify_connect, ¬ify_disconnect, | 441 | ¬ify_connect, ¬ify_disconnect, |
436 | NULL); | 442 | NULL); |
437 | 443 | ||
444 | if ((p1 == NULL) || (p2 == NULL)) | ||
445 | { | ||
446 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n"); | ||
447 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | ||
448 | GNUNET_SCHEDULER_cancel (die_task); | ||
449 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | ||
450 | return; | ||
451 | } | ||
452 | |||
438 | GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL); | 453 | GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL); |
439 | } | 454 | } |
440 | 455 | ||
@@ -458,9 +473,8 @@ check () | |||
458 | #endif | 473 | #endif |
459 | ok = GNUNET_SYSERR; | 474 | ok = GNUNET_SYSERR; |
460 | 475 | ||
461 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | 476 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, test_name, |
462 | "test-transport-api-unreliability", "nohelp", options, | 477 | "nohelp", options, &run, &ok); |
463 | &run, &ok); | ||
464 | 478 | ||
465 | return ok; | 479 | return ok; |
466 | } | 480 | } |
@@ -471,7 +485,12 @@ main (int argc, char *argv[]) | |||
471 | int ret; | 485 | int ret; |
472 | int nat_res; | 486 | int nat_res; |
473 | 487 | ||
474 | GNUNET_log_setup ("test-transport-api-unreliability", | 488 | GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); |
489 | GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, | ||
490 | &test_plugin); | ||
491 | GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); | ||
492 | |||
493 | GNUNET_log_setup (test_name, | ||
475 | #if VERBOSE | 494 | #if VERBOSE |
476 | "DEBUG", | 495 | "DEBUG", |
477 | #else | 496 | #else |
@@ -479,40 +498,8 @@ main (int argc, char *argv[]) | |||
479 | #endif | 498 | #endif |
480 | NULL); | 499 | NULL); |
481 | 500 | ||
482 | char *pch = strdup (argv[0]); | 501 | if ((strcmp (test_plugin, "tcp_nat") == 0) || |
483 | char *backup = pch; | 502 | (strcmp (test_plugin, "udp_nat") == 0)) |
484 | char *filename = NULL; | ||
485 | char *dotexe; | ||
486 | char *src_name = strdup (__FILE__); | ||
487 | char *split = NULL; | ||
488 | |||
489 | /* get executable filename */ | ||
490 | pch = strtok (pch, "/"); | ||
491 | while (pch != NULL) | ||
492 | { | ||
493 | pch = strtok (NULL, "/"); | ||
494 | if (pch != NULL) | ||
495 | filename = pch; | ||
496 | } | ||
497 | /* remove "lt-" */ | ||
498 | filename = strstr (filename, "tes"); | ||
499 | if (NULL != (dotexe = strstr (filename, ".exe"))) | ||
500 | dotexe[0] = '\0'; | ||
501 | |||
502 | split = strstr (src_name, "."); | ||
503 | if (split != NULL) | ||
504 | { | ||
505 | split[0] = '\0'; | ||
506 | test_name = strdup (&filename[strlen (src_name) + 1]); | ||
507 | } | ||
508 | else | ||
509 | test_name = NULL; | ||
510 | |||
511 | GNUNET_free (src_name); | ||
512 | GNUNET_free (backup); | ||
513 | |||
514 | if ((strstr (argv[0], "tcp_nat") != NULL) || | ||
515 | (strstr (argv[0], "udp_nat") != NULL)) | ||
516 | { | 503 | { |
517 | nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server"); | 504 | nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server"); |
518 | if (GNUNET_NO == nat_res) | 505 | if (GNUNET_NO == nat_res) |
@@ -537,7 +524,9 @@ main (int argc, char *argv[]) | |||
537 | GNUNET_free (cfg_file_p1); | 524 | GNUNET_free (cfg_file_p1); |
538 | GNUNET_free (cfg_file_p2); | 525 | GNUNET_free (cfg_file_p2); |
539 | 526 | ||
540 | GNUNET_free_non_null (test_name); | 527 | GNUNET_free (test_source); |
528 | GNUNET_free (test_plugin); | ||
529 | GNUNET_free (test_name); | ||
541 | 530 | ||
542 | return ret; | 531 | return ret; |
543 | } | 532 | } |