From: Christian Grothoff Date: Sun, 10 Jun 2012 11:43:20 +0000 (+0000) Subject: -using new testing api to determine plugin name X-Git-Tag: initial-import-from-subversion-38251~13178 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=dadbf4c950bf4cd459c95ac4ab61a02af7b3668b;p=oweals%2Fgnunet.git -using new testing api to determine plugin name --- diff --git a/src/datacache/Makefile.am b/src/datacache/Makefile.am index e1cd8fd79..0f10e6c1b 100644 --- a/src/datacache/Makefile.am +++ b/src/datacache/Makefile.am @@ -134,54 +134,63 @@ endif test_datacache_sqlite_SOURCES = \ test_datacache.c test_datacache_sqlite_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datacache/libgnunetdatacache.la \ $(top_builddir)/src/util/libgnunetutil.la test_datacache_quota_sqlite_SOURCES = \ test_datacache_quota.c test_datacache_quota_sqlite_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datacache/libgnunetdatacache.la \ $(top_builddir)/src/util/libgnunetutil.la perf_datacache_sqlite_SOURCES = \ perf_datacache.c perf_datacache_sqlite_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datacache/libgnunetdatacache.la \ $(top_builddir)/src/util/libgnunetutil.la test_datacache_mysql_SOURCES = \ test_datacache.c test_datacache_mysql_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datacache/libgnunetdatacache.la \ $(top_builddir)/src/util/libgnunetutil.la test_datacache_quota_mysql_SOURCES = \ test_datacache_quota.c test_datacache_quota_mysql_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datacache/libgnunetdatacache.la \ $(top_builddir)/src/util/libgnunetutil.la perf_datacache_mysql_SOURCES = \ perf_datacache.c perf_datacache_mysql_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datacache/libgnunetdatacache.la \ $(top_builddir)/src/util/libgnunetutil.la test_datacache_postgres_SOURCES = \ test_datacache.c test_datacache_postgres_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datacache/libgnunetdatacache.la \ $(top_builddir)/src/util/libgnunetutil.la test_datacache_quota_postgres_SOURCES = \ test_datacache_quota.c test_datacache_quota_postgres_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datacache/libgnunetdatacache.la \ $(top_builddir)/src/util/libgnunetutil.la perf_datacache_postgres_SOURCES = \ perf_datacache.c perf_datacache_postgres_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datacache/libgnunetdatacache.la \ $(top_builddir)/src/util/libgnunetutil.la diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c index 77edbf925..94cd7a58e 100644 --- a/src/datacache/perf_datacache.c +++ b/src/datacache/perf_datacache.c @@ -25,9 +25,9 @@ #include "platform.h" #include "gnunet_util_lib.h" #include "gnunet_datacache_lib.h" +#include "gnunet_testing_lib-new.h" #include -#define VERBOSE GNUNET_NO #define ASSERT(x) do { if (! (x)) { printf("Error at %s:%d\n", __FILE__, __LINE__); goto FAILURE;} } while (0) @@ -129,16 +129,11 @@ FAILURE: int main (int argc, char *argv[]) { - char *pos; char cfg_name[128]; - char *const xargv[] = { "perf-datacache", "-c", cfg_name, -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -146,25 +141,11 @@ main (int argc, char *argv[]) }; GNUNET_log_setup ("perf-datacache", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); - /* determine name of plugin to use */ - plugin_name = argv[0]; - while (NULL != (pos = strstr (plugin_name, "_"))) - plugin_name = pos + 1; - if (NULL != (pos = strstr (plugin_name, "."))) - pos[0] = 0; - else - pos = (char *) plugin_name; - + plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); GNUNET_snprintf (cfg_name, sizeof (cfg_name), "perf_datacache_data_%s.conf", plugin_name); - if (pos != plugin_name) - pos[0] = '.'; GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv, "perf-datacache", "nohelp", options, &run, NULL); if (ok != 0) diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c index 97e2cda30..c818daaa8 100644 --- a/src/datacache/test_datacache.c +++ b/src/datacache/test_datacache.c @@ -25,6 +25,7 @@ #include "platform.h" #include "gnunet_util_lib.h" #include "gnunet_datacache_lib.h" +#include "gnunet_testing_lib-new.h" #define ASSERT(x) do { if (! (x)) { printf("Error at %s:%d\n", __FILE__, __LINE__); goto FAILURE;} } while (0) @@ -114,9 +115,7 @@ FAILURE: int main (int argc, char *argv[]) { - char *pos; char cfg_name[128]; - char *const xargv[] = { "test-datacache", "-c", @@ -130,22 +129,12 @@ main (int argc, char *argv[]) GNUNET_log_setup ("test-datacache", "WARNING", NULL); - /* determine name of plugin to use */ - plugin_name = argv[0]; - while (NULL != (pos = strstr (plugin_name, "_"))) - plugin_name = pos + 1; - if (NULL != (pos = strstr (plugin_name, "."))) - pos[0] = 0; - else - pos = (char *) plugin_name; - + plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datacache_data_%s.conf", plugin_name); - if (pos != plugin_name) - pos[0] = '.'; GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv, "test-datacache", "nohelp", options, &run, NULL); - if (ok != 0) + if (0 != ok) FPRINTF (stderr, "Missed some testcases: %d\n", ok); return ok; } diff --git a/src/datacache/test_datacache_quota.c b/src/datacache/test_datacache_quota.c index cc47bdb8f..5325b398f 100644 --- a/src/datacache/test_datacache_quota.c +++ b/src/datacache/test_datacache_quota.c @@ -25,8 +25,7 @@ #include "platform.h" #include "gnunet_util_lib.h" #include "gnunet_datacache_lib.h" - -#define VERBOSE GNUNET_NO +#include "gnunet_testing_lib-new.h" #define ASSERT(x) do { if (! (x)) { printf("Error at %s:%d\n", __FILE__, __LINE__); goto FAILURE;} } while (0) @@ -104,16 +103,11 @@ FAILURE: int main (int argc, char *argv[]) { - char *pos; char cfg_name[128]; - char *const xargv[] = { "test-datacache-quota", "-c", cfg_name, -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -121,29 +115,15 @@ main (int argc, char *argv[]) }; GNUNET_log_setup ("test-datacache-quota", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); - /* determine name of plugin to use */ - plugin_name = argv[0]; - while (NULL != (pos = strstr (plugin_name, "_"))) - plugin_name = pos + 1; - if (NULL != (pos = strstr (plugin_name, "."))) - pos[0] = 0; - else - pos = (char *) plugin_name; - + plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datacache_data_%s.conf", plugin_name); - if (pos != plugin_name) - pos[0] = '.'; GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv, "test-datacache-quota", "nohelp", options, &run, NULL); - if (ok != 0) + if (0 != ok) FPRINTF (stderr, "Missed some testcases: %d\n", ok); return ok; } diff --git a/src/datastore/Makefile.am b/src/datastore/Makefile.am index cd5b0d481..4000e9981 100644 --- a/src/datastore/Makefile.am +++ b/src/datastore/Makefile.am @@ -162,11 +162,13 @@ perf_datastore_api_sqlite_LDADD = \ perf_plugin_datastore_sqlite_SOURCES = \ perf_plugin_datastore.c perf_plugin_datastore_sqlite_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/util/libgnunetutil.la test_plugin_datastore_sqlite_SOURCES = \ test_plugin_datastore.c test_plugin_datastore_sqlite_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/util/libgnunetutil.la @@ -194,11 +196,13 @@ perf_datastore_api_mysql_LDADD = \ test_plugin_datastore_mysql_SOURCES = \ test_plugin_datastore.c test_plugin_datastore_mysql_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/util/libgnunetutil.la perf_plugin_datastore_mysql_SOURCES = \ perf_plugin_datastore.c perf_plugin_datastore_mysql_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/util/libgnunetutil.la @@ -226,11 +230,13 @@ perf_datastore_api_postgres_LDADD = \ test_plugin_datastore_postgres_SOURCES = \ test_plugin_datastore.c test_plugin_datastore_postgres_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/util/libgnunetutil.la perf_plugin_datastore_postgres_SOURCES = \ perf_plugin_datastore.c perf_plugin_datastore_postgres_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/util/libgnunetutil.la diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index e236b6235..fa2ee52dc 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c @@ -322,17 +322,9 @@ run (void *cls, int main (int argc, char *argv[]) { - char *pos; char cfg_name[128]; - /* determine name of plugin to use */ - plugin_name = argv[0]; - while (NULL != (pos = strstr (plugin_name, "_"))) - plugin_name = pos + 1; - if (NULL != (pos = strstr (plugin_name, "."))) - pos[0] = '\0'; - else - pos = (char *) plugin_name; + plugin_name = GNUNET_TESTING_get_testname_from_underscoare (argv[0]); GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datastore_api_data_%s.conf", plugin_name); if (0 != diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index daea8d796..763b38766 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c @@ -27,6 +27,7 @@ #include "gnunet_util_lib.h" #include "gnunet_protocols.h" #include "gnunet_datastore_plugin.h" +#include "gnunet_testing_lib-new.h" #include /** @@ -453,7 +454,6 @@ run (void *cls, char *const *args, const char *cfgfile, int main (int argc, char *argv[]) { - char *pos; char dir_name[128]; char cfg_name[128]; char *const argv[] = { @@ -466,14 +466,7 @@ main (int argc, char *argv[]) GNUNET_GETOPT_OPTION_END }; - /* determine name of plugin to use */ - plugin_name = argv[0]; - while (NULL != (pos = strstr (plugin_name, "_"))) - plugin_name = pos + 1; - if (NULL != (pos = strstr (plugin_name, "."))) - pos[0] = 0; - else - pos = (char *) plugin_name; + plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/perf-gnunet-datastore-%s", plugin_name); GNUNET_DISK_directory_remove (dir_name); @@ -487,8 +480,6 @@ main (int argc, char *argv[]) "perf-plugin-datastore", "nohelp", options, &run, NULL); if (ok != 0) FPRINTF (stderr, "Missed some testcases: %u\n", ok); - if (pos != plugin_name) - pos[0] = '.'; GNUNET_DISK_directory_remove (dir_name); return ok; diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index cfeac86db..374067ca0 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c @@ -491,17 +491,9 @@ run (void *cls, int main (int argc, char *argv[]) { - char *pos; char cfg_name[128]; - /* determine name of plugin to use */ - plugin_name = argv[0]; - while (NULL != (pos = strstr (plugin_name, "_"))) - plugin_name = pos + 1; - if (NULL != (pos = strstr (plugin_name, "."))) - pos[0] = '\0'; - else - pos = (char *) plugin_name; + plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datastore_api_data_%s.conf", plugin_name); if (0 != diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index 9b5fb4e6f..bbb954304 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c @@ -286,17 +286,9 @@ run (void *cls, int main (int argc, char *argv[]) { - char *pos; char cfg_name[128]; - /* determine name of plugin to use */ - plugin_name = argv[0]; - while (NULL != (pos = strstr (plugin_name, "_"))) - plugin_name = pos + 1; - if (NULL != (pos = strstr (plugin_name, "."))) - pos[0] = 0; - else - pos = (char *) plugin_name; + plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datastore_api_data_%s.conf", plugin_name); if (0 != diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c index de9e7c2ab..a228e1004 100644 --- a/src/datastore/test_plugin_datastore.c +++ b/src/datastore/test_plugin_datastore.c @@ -27,6 +27,7 @@ #include "gnunet_util_lib.h" #include "gnunet_protocols.h" #include "gnunet_datastore_plugin.h" +#include "gnunet_testing_lib-new.h" /** * Number of put operations to perform. @@ -349,11 +350,9 @@ run (void *cls, char *const *args, const char *cfgfile, } - int main (int argc, char *argv[]) { - char *pos; char dir_name[128]; char cfg_name[128]; char *const xargv[] = { @@ -367,14 +366,7 @@ main (int argc, char *argv[]) }; /* determine name of plugin to use */ - plugin_name = argv[0]; - while (NULL != (pos = strstr (plugin_name, "_"))) - plugin_name = pos + 1; - if (NULL != (pos = strstr (plugin_name, "."))) - pos[0] = 0; - else - pos = (char *) plugin_name; - + plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-plugin-%s", plugin_name); GNUNET_DISK_directory_remove (dir_name); @@ -385,10 +377,8 @@ main (int argc, char *argv[]) "test_plugin_datastore_data_%s.conf", plugin_name); GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv, "test-plugin-datastore", "nohelp", options, &run, NULL); - if (ok != 0) + if (0 != ok) FPRINTF (stderr, "Missed some testcases: %u\n", ok); - if (pos != plugin_name) - pos[0] = '.'; GNUNET_DISK_directory_remove (dir_name); return ok; }