aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_reliability.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-09-01 09:24:44 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-09-01 09:24:44 +0000
commitd7181f0e7bc21fe4d7193cea580d034cd188ea48 (patch)
tree8380a21b755a25f41d57bd0329b23ec939d9de29 /src/transport/test_transport_api_reliability.c
parent06e2ee2b2be79cee6acc2628f9b91a3591b014df (diff)
downloadgnunet-d7181f0e7bc21fe4d7193cea580d034cd188ea48.tar.gz
gnunet-d7181f0e7bc21fe4d7193cea580d034cd188ea48.zip
using new function + additional safety checks
Diffstat (limited to 'src/transport/test_transport_api_reliability.c')
-rw-r--r--src/transport/test_transport_api_reliability.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index 09d23b789..f0c9d9db8 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -38,7 +38,7 @@
38#include "transport.h" 38#include "transport.h"
39#include "transport-testing.h" 39#include "transport-testing.h"
40 40
41#define VERBOSE GNUNET_NO 41#define VERBOSE GNUNET_YES
42 42
43#define VERBOSE_ARM GNUNET_NO 43#define VERBOSE_ARM GNUNET_NO
44 44
@@ -49,6 +49,12 @@
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, 1500)
51 51
52static char *test_source;
53
54static char *test_plugin;
55
56static char *test_name;
57
52static int ok; 58static int ok;
53 59
54static GNUNET_SCHEDULER_TaskIdentifier die_task; 60static GNUNET_SCHEDULER_TaskIdentifier die_task;
@@ -82,9 +88,6 @@ struct TestMessage
82 uint32_t num; 88 uint32_t num;
83}; 89};
84 90
85static char *test_name;
86static char *test_plugin;
87
88static int msg_scheduled; 91static int msg_scheduled;
89static int msg_sent; 92static int msg_sent;
90static int msg_recv_expected; 93static int msg_recv_expected;
@@ -374,13 +377,22 @@ run (void *cls, char *const *args, const char *cfgfile,
374 &notify_connect, &notify_disconnect, 377 &notify_connect, &notify_disconnect,
375 NULL); 378 NULL);
376 379
380 if ((p1 == NULL) || (p2 == NULL))
381 {
382 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n");
383 if (die_task != GNUNET_SCHEDULER_NO_TASK)
384 GNUNET_SCHEDULER_cancel (die_task);
385 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
386 return;
387 }
388
377 GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL); 389 GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL);
378} 390}
379 391
380static int 392static int
381check () 393check ()
382{ 394{
383 static char * argv[] = { "SDSD", 395 static char *argv[] = { "test_transport",
384 "-c", 396 "-c",
385 "test_transport_api_data.conf", 397 "test_transport_api_data.conf",
386#if VERBOSE 398#if VERBOSE
@@ -396,9 +408,8 @@ check ()
396 setTransportOptions ("test_transport_api_data.conf"); 408 setTransportOptions ("test_transport_api_data.conf");
397#endif 409#endif
398 ok = 1; 410 ok = 1;
399 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, 411 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, test_name,
400 test_name, "nohelp", options, &run, 412 "nohelp", options, &run, &ok);
401 &ok);
402 413
403 return ok; 414 return ok;
404} 415}
@@ -408,10 +419,11 @@ main (int argc, char *argv[])
408{ 419{
409 int ret; 420 int ret;
410 int nat_res; 421 int nat_res;
411 //char * test_exec;
412
413 GNUNET_TRANSPORT_TESTING_get_test_sourcename (__FILE__, &test_name);
414 422
423 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
424 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
425 &test_plugin);
426 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
415 427
416 GNUNET_log_setup (test_name, 428 GNUNET_log_setup (test_name,
417#if VERBOSE 429#if VERBOSE
@@ -421,10 +433,8 @@ main (int argc, char *argv[])
421#endif 433#endif
422 NULL); 434 NULL);
423 435
424 GNUNET_TRANSPORT_TESTING_get_test_plugin (argv[0], test_name, &test_plugin); 436 if ((strcmp (test_plugin, "tcp_nat") == 0) ||
425 437 (strcmp (test_plugin, "udp_nat") == 0))
426 if ((strstr (argv[0], "tcp_nat") != NULL) ||
427 (strstr (argv[0], "udp_nat") != NULL))
428 { 438 {
429 nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server"); 439 nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server");
430 if (GNUNET_NO == nat_res) 440 if (GNUNET_NO == nat_res)
@@ -441,7 +451,6 @@ main (int argc, char *argv[])
441 } 451 }
442 } 452 }
443 453
444
445 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 454 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
446 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 455 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
447 456
@@ -450,8 +459,9 @@ main (int argc, char *argv[])
450 GNUNET_free (cfg_file_p1); 459 GNUNET_free (cfg_file_p1);
451 GNUNET_free (cfg_file_p2); 460 GNUNET_free (cfg_file_p2);
452 461
453 GNUNET_free (test_name); 462 GNUNET_free (test_source);
454 GNUNET_free (test_plugin); 463 GNUNET_free (test_plugin);
464 GNUNET_free (test_name);
455 465
456 return ret; 466 return ret;
457} 467}