};
static char *test_name;
+static char *test_plugin;
static int msg_scheduled;
static int msg_sent;
delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value;
fprintf (stderr, "\nThroughput was %llu kb/s\n",
total_bytes * 1000 / 1024 / delta);
- GNUNET_asprintf (&value_name, "reliable_%s", test_name);
+ GNUNET_asprintf (&value_name, "reliable_%s", test_plugin);
GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta),
"kb/s");
GNUNET_free (value_name);
static int
check ()
{
- static char *const argv[] = { "test-transport-api-reliability",
+ static char * argv[] = { "SDSD",
"-c",
"test_transport_api_data.conf",
#if VERBOSE
#endif
ok = 1;
GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
- "test-transport-api-reliability", "nohelp", options, &run,
+ test_name, "nohelp", options, &run,
&ok);
return ok;
{
int ret;
int nat_res;
+ //char * test_exec;
- GNUNET_log_setup ("test-transport-api-reliability",
+ GNUNET_TRANSPORT_TESTING_get_test_sourcename (__FILE__, &test_name);
+
+
+ GNUNET_log_setup (test_name,
#if VERBOSE
"DEBUG",
#else
#endif
NULL);
- char *pch = strdup (argv[0]);
- char *backup = pch;
- char *filename = NULL;
- char *dotexe;
- char *src_name = strdup (__FILE__);
- char *split = NULL;
-
- /* get executable filename */
- pch = strtok (pch, "/");
- while (pch != NULL)
- {
- pch = strtok (NULL, "/");
- if (pch != NULL)
- filename = pch;
- }
- /* remove "lt-" */
- filename = strstr (filename, "tes");
- if (NULL != (dotexe = strstr (filename, ".exe")))
- dotexe[0] = '\0';
-
- split = strstr (src_name, ".");
- if (split != NULL)
- {
- split[0] = '\0';
- test_name = strdup (&filename[strlen (src_name) + 1]);
- }
- else
- test_name = NULL;
-
- GNUNET_free (src_name);
- GNUNET_free (backup);
+ GNUNET_TRANSPORT_TESTING_get_test_plugin (argv[0], test_name, &test_plugin);
if ((strstr (argv[0], "tcp_nat") != NULL) ||
(strstr (argv[0], "udp_nat") != NULL))
}
}
+
GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
GNUNET_free (cfg_file_p1);
GNUNET_free (cfg_file_p2);
- GNUNET_free_non_null (test_name);
+ GNUNET_free (test_name);
+ GNUNET_free (test_plugin);
return ret;
}
* Some utility functions
*/
+char *
+extract_filename (const char * file)
+{
+ char *pch = strdup (file);
+ char *backup = pch;
+ char *filename = NULL;
+ char *res;
+
+
+ /* get executable filename */
+ if (NULL != strstr (pch, "/"))
+ {
+ pch = strtok (pch, "/");
+ while (pch != NULL)
+ {
+ pch = strtok (NULL, "/");
+ if (pch != NULL)
+ {
+ filename = pch;
+ }
+ }
+ }
+ else
+ filename = pch;
+ res = strdup(filename);
+ GNUNET_free (backup);
+
+ return res;
+}
+
+void
+GNUNET_TRANSPORT_TESTING_get_test_sourcename (const char * file, char **testname)
+{
+ char * src = extract_filename (file);
+ char * split;
+
+ split = strstr (src, ".");
+ if (split != NULL)
+ {
+ split[0] = '\0';
+ }
+ GNUNET_asprintf(testname, "%s", src);
+ GNUNET_free (src);
+}
+
+void
+GNUNET_TRANSPORT_TESTING_get_test_plugin (const char * executable, const char * testname, char **pluginname)
+{
+ char *exec = extract_filename (executable);
+ char *test = extract_filename (testname);
+
+ char *backup_t = test;
+ char *filename = NULL;
+ char *dotexe;
+
+ if (exec == NULL)
+ goto fail;
+
+ /* remove "lt-" */
+ filename = strstr (exec, "tes");
+ if (filename == NULL)
+ goto fail;
+
+ /* remove ".exe" */
+ if (NULL != (dotexe = strstr (filename, ".exe")))
+ dotexe[0] = '\0';
+
+ /* find last _ */
+ filename = strstr (filename, test);
+ if (filename == NULL)
+ goto fail;
+
+ /* copy plugin */
+ filename += strlen (test);
+ filename++;
+ GNUNET_asprintf (pluginname, "%s", filename);
+ goto suc;
+
+fail:
+ (*pluginname) = NULL;
+suc:
+ GNUNET_free (backup_t);
+ GNUNET_free (exec);
+
+}
+
/**
* this function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
* if existing ".exe"-prefix and adds the peer-number
GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, char **cfgname,
int count)
{
- char *pch = strdup (file);
- char *backup = pch;
- char *filename = NULL;
+ char *filename = extract_filename (file);
+ char *backup = filename;
char *dotexe;
- /* get executable filename */
- pch = strtok (pch, "/");
- while (pch != NULL)
- {
- pch = strtok (NULL, "/");
- if (pch != NULL)
- filename = pch;
- }
+ if (filename == NULL)
+ goto fail;
+
/* remove "lt-" */
filename = strstr (filename, "tes");
+ if (filename == NULL)
+ goto fail;
+
+ /* remove ".exe" */
if (NULL != (dotexe = strstr (filename, ".exe")))
- dotexe[0] = '\0';
+ dotexe[0] = '\0';
+
+ if (filename == NULL)
+ goto fail;
+
+ /* copy plugin */
+ goto suc;
+fail:
+ (*cfgname) = NULL;
+ return;
+
+suc:
/* create cfg filename */
GNUNET_asprintf (cfgname, "%s_peer%u.conf", filename, count);
-
GNUNET_free (backup);
}
+
/* end of transport_testing.h */