aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_reliability.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-08-31 15:45:07 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-08-31 15:45:07 +0000
commit75bf0641a6f6b19ae1ebea3c8f376c0226a0672b (patch)
tree71316a5d7d9843c803a8955c022bd03a36da8c34 /src/transport/test_transport_api_reliability.c
parent95dd1c20cc527cd8d808955fc05866829f760256 (diff)
downloadgnunet-75bf0641a6f6b19ae1ebea3c8f376c0226a0672b.tar.gz
gnunet-75bf0641a6f6b19ae1ebea3c8f376c0226a0672b.zip
utility functions
Diffstat (limited to 'src/transport/test_transport_api_reliability.c')
-rw-r--r--src/transport/test_transport_api_reliability.c49
1 files changed, 13 insertions, 36 deletions
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index 55db67877..09d23b789 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -83,6 +83,7 @@ struct TestMessage
83}; 83};
84 84
85static char *test_name; 85static char *test_name;
86static char *test_plugin;
86 87
87static int msg_scheduled; 88static int msg_scheduled;
88static int msg_sent; 89static int msg_sent;
@@ -118,7 +119,7 @@ end ()
118 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; 119 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value;
119 fprintf (stderr, "\nThroughput was %llu kb/s\n", 120 fprintf (stderr, "\nThroughput was %llu kb/s\n",
120 total_bytes * 1000 / 1024 / delta); 121 total_bytes * 1000 / 1024 / delta);
121 GNUNET_asprintf (&value_name, "reliable_%s", test_name); 122 GNUNET_asprintf (&value_name, "reliable_%s", test_plugin);
122 GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), 123 GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta),
123 "kb/s"); 124 "kb/s");
124 GNUNET_free (value_name); 125 GNUNET_free (value_name);
@@ -379,7 +380,7 @@ run (void *cls, char *const *args, const char *cfgfile,
379static int 380static int
380check () 381check ()
381{ 382{
382 static char *const argv[] = { "test-transport-api-reliability", 383 static char * argv[] = { "SDSD",
383 "-c", 384 "-c",
384 "test_transport_api_data.conf", 385 "test_transport_api_data.conf",
385#if VERBOSE 386#if VERBOSE
@@ -396,7 +397,7 @@ check ()
396#endif 397#endif
397 ok = 1; 398 ok = 1;
398 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, 399 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
399 "test-transport-api-reliability", "nohelp", options, &run, 400 test_name, "nohelp", options, &run,
400 &ok); 401 &ok);
401 402
402 return ok; 403 return ok;
@@ -407,8 +408,12 @@ main (int argc, char *argv[])
407{ 408{
408 int ret; 409 int ret;
409 int nat_res; 410 int nat_res;
411 //char * test_exec;
410 412
411 GNUNET_log_setup ("test-transport-api-reliability", 413 GNUNET_TRANSPORT_TESTING_get_test_sourcename (__FILE__, &test_name);
414
415
416 GNUNET_log_setup (test_name,
412#if VERBOSE 417#if VERBOSE
413 "DEBUG", 418 "DEBUG",
414#else 419#else
@@ -416,37 +421,7 @@ main (int argc, char *argv[])
416#endif 421#endif
417 NULL); 422 NULL);
418 423
419 char *pch = strdup (argv[0]); 424 GNUNET_TRANSPORT_TESTING_get_test_plugin (argv[0], test_name, &test_plugin);
420 char *backup = pch;
421 char *filename = NULL;
422 char *dotexe;
423 char *src_name = strdup (__FILE__);
424 char *split = NULL;
425
426 /* get executable filename */
427 pch = strtok (pch, "/");
428 while (pch != NULL)
429 {
430 pch = strtok (NULL, "/");
431 if (pch != NULL)
432 filename = pch;
433 }
434 /* remove "lt-" */
435 filename = strstr (filename, "tes");
436 if (NULL != (dotexe = strstr (filename, ".exe")))
437 dotexe[0] = '\0';
438
439 split = strstr (src_name, ".");
440 if (split != NULL)
441 {
442 split[0] = '\0';
443 test_name = strdup (&filename[strlen (src_name) + 1]);
444 }
445 else
446 test_name = NULL;
447
448 GNUNET_free (src_name);
449 GNUNET_free (backup);
450 425
451 if ((strstr (argv[0], "tcp_nat") != NULL) || 426 if ((strstr (argv[0], "tcp_nat") != NULL) ||
452 (strstr (argv[0], "udp_nat") != NULL)) 427 (strstr (argv[0], "udp_nat") != NULL))
@@ -466,6 +441,7 @@ main (int argc, char *argv[])
466 } 441 }
467 } 442 }
468 443
444
469 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 445 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
470 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 446 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
471 447
@@ -474,7 +450,8 @@ main (int argc, char *argv[])
474 GNUNET_free (cfg_file_p1); 450 GNUNET_free (cfg_file_p1);
475 GNUNET_free (cfg_file_p2); 451 GNUNET_free (cfg_file_p2);
476 452
477 GNUNET_free_non_null (test_name); 453 GNUNET_free (test_name);
454 GNUNET_free (test_plugin);
478 455
479 return ret; 456 return ret;
480} 457}