From 5d2bfbd4a69f87c99083fc60954c884af69258f4 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 10 Jun 2012 11:18:59 +0000 Subject: -using testing in datastore tests --- src/datastore/Makefile.am | 9 ++ src/datastore/perf_datastore_api.c | 95 +++------------- src/datastore/perf_plugin_datastore.c | 58 +++------- src/datastore/test_datastore_api.c | 101 +++-------------- src/datastore/test_datastore_api_data_sqlite.conf | 2 - src/datastore/test_datastore_api_management.c | 131 ++++++---------------- src/datastore/test_defaults.conf | 3 + src/datastore/test_plugin_datastore.c | 71 ++++-------- 8 files changed, 117 insertions(+), 353 deletions(-) (limited to 'src/datastore') diff --git a/src/datastore/Makefile.am b/src/datastore/Makefile.am index e9774eddd..cd5b0d481 100644 --- a/src/datastore/Makefile.am +++ b/src/datastore/Makefile.am @@ -141,18 +141,21 @@ endif test_datastore_api_sqlite_SOURCES = \ test_datastore_api.c test_datastore_api_sqlite_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datastore/libgnunetdatastore.la \ $(top_builddir)/src/util/libgnunetutil.la test_datastore_api_management_sqlite_SOURCES = \ test_datastore_api_management.c test_datastore_api_management_sqlite_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datastore/libgnunetdatastore.la \ $(top_builddir)/src/util/libgnunetutil.la perf_datastore_api_sqlite_SOURCES = \ perf_datastore_api.c perf_datastore_api_sqlite_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datastore/libgnunetdatastore.la \ $(top_builddir)/src/util/libgnunetutil.la @@ -170,18 +173,21 @@ test_plugin_datastore_sqlite_LDADD = \ test_datastore_api_mysql_SOURCES = \ test_datastore_api.c test_datastore_api_mysql_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datastore/libgnunetdatastore.la \ $(top_builddir)/src/util/libgnunetutil.la test_datastore_api_management_mysql_SOURCES = \ test_datastore_api_management.c test_datastore_api_management_mysql_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datastore/libgnunetdatastore.la \ $(top_builddir)/src/util/libgnunetutil.la perf_datastore_api_mysql_SOURCES = \ perf_datastore_api.c perf_datastore_api_mysql_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datastore/libgnunetdatastore.la \ $(top_builddir)/src/util/libgnunetutil.la @@ -199,18 +205,21 @@ perf_plugin_datastore_mysql_LDADD = \ test_datastore_api_postgres_SOURCES = \ test_datastore_api.c test_datastore_api_postgres_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datastore/libgnunetdatastore.la \ $(top_builddir)/src/util/libgnunetutil.la test_datastore_api_management_postgres_SOURCES = \ test_datastore_api_management.c test_datastore_api_management_postgres_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datastore/libgnunetdatastore.la \ $(top_builddir)/src/util/libgnunetutil.la perf_datastore_api_postgres_SOURCES = \ perf_datastore_api.c perf_datastore_api_postgres_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/datastore/libgnunetdatastore.la \ $(top_builddir)/src/util/libgnunetutil.la diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index cdbd6ae9c..e236b6235 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c @@ -36,19 +36,14 @@ #include "gnunet_util_lib.h" #include "gnunet_protocols.h" #include "gnunet_datastore_service.h" +#include "gnunet_testing_lib-new.h" #include -#define VERBOSE GNUNET_NO - /** * How long until we give up on transmitting the message? */ #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) -static const char *plugin_name; - -static struct GNUNET_DATASTORE_Handle *datastore; - /** * Target datastore size (in bytes). */ @@ -81,8 +76,13 @@ static unsigned long long stored_ops; static struct GNUNET_TIME_Absolute start_time; +static const char *plugin_name; + +static struct GNUNET_DATASTORE_Handle *datastore; + static int ok; + enum RunPhase { RP_DONE = 0, @@ -103,13 +103,10 @@ struct CpsRunContext }; - static void run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); - - static void check_success (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) { @@ -297,7 +294,7 @@ run_tests (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, c static void -run (void *cls, char *const *args, const char *cfgfile, +run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct CpsRunContext *crc; @@ -322,85 +319,29 @@ run (void *cls, char *const *args, const char *cfgfile, } -static int -check () -{ - struct GNUNET_OS_Process *proc; - char cfg_name[128]; - - char *const argv[] = { - "perf-datastore-api", - "-c", - cfg_name, -#if VERBOSE - "-L", "DEBUG", -#endif - NULL - }; - struct GNUNET_GETOPT_CommandLineOption options[] = { - GNUNET_GETOPT_OPTION_END - }; - - GNUNET_snprintf (cfg_name, sizeof (cfg_name), - "test_datastore_api_data_%s.conf", plugin_name); - proc = - GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", -#if VERBOSE - "-L", "DEBUG", -#endif - "-c", cfg_name, NULL); - GNUNET_assert (NULL != proc); - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, - "perf-datastore-api", "nohelp", options, &run, NULL); - sleep (1); /* give datastore chance to process 'DROP' */ - if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) - { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); - ok = 1; - } - GNUNET_OS_process_wait (proc); - GNUNET_OS_process_destroy (proc); - proc = NULL; - return ok; -} - - int main (int argc, char *argv[]) { - int ret; char *pos; - char dir_name[128]; + char cfg_name[128]; - sleep (1); /* 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; + pos[0] = '\0'; else pos = (char *) plugin_name; - - GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-%s", - plugin_name); - GNUNET_DISK_directory_remove (dir_name); - GNUNET_log_setup ("perf-datastore-api", -#if VERBOSE - "DEBUG", -#else - "WARNING", -#endif - NULL); - ret = check (); - if (pos != plugin_name) - pos[0] = '.'; -#if REPORT_ID - FPRINTF (stderr, "%s", "\n"); -#endif - GNUNET_DISK_directory_remove (dir_name); - return ret; + GNUNET_snprintf (cfg_name, sizeof (cfg_name), + "test_datastore_api_data_%s.conf", plugin_name); + if (0 != + GNUNET_TESTING_peer_run ("perf-gnunet-datastore", + cfg_name, + &run, + NULL)) + return 1; + return ok; } /* end of perf_datastore_api.c */ diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index 186037429..daea8d796 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c @@ -29,8 +29,6 @@ #include "gnunet_datastore_plugin.h" #include -#define VERBOSE GNUNET_NO - /** * Target datastore size (in bytes). Realistic sizes are * more like 16 GB (not the default of 16 MB); however, @@ -164,10 +162,9 @@ iterate_zeros (void *cls, const GNUNET_HashCode * key, uint32_t size, memcpy (&i, &cdata[4], sizeof (i)); hits[i / 8] |= (1 << (i % 8)); -#if VERBOSE - FPRINTF (stderr, "Found result type=%u, priority=%u, size=%u, expire=%llu\n", - type, priority, size, (unsigned long long) expiration.abs_value); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Found result type=%u, priority=%u, size=%u, expire=%llu\n", + type, priority, size, (unsigned long long) expiration.abs_value); crc->cnt++; if (crc->cnt == PUT_10 / 4 - 1) { @@ -343,9 +340,8 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_break (0); crc->phase = RP_ERROR; } -#if VERBOSE - FPRINTF (stderr, "In phase %d, iteration %u\n", crc->phase, crc->cnt); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "In phase %d, iteration %u\n", crc->phase, crc->cnt); switch (crc->phase) { case RP_ERROR: @@ -454,43 +450,22 @@ run (void *cls, char *const *args, const char *cfgfile, } -static int -check () +int +main (int argc, char *argv[]) { + char *pos; + char dir_name[128]; char cfg_name[128]; - char *const argv[] = { "perf-plugin-datastore", "-c", cfg_name, -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_snprintf (category, sizeof (category), "DATASTORE-%s", plugin_name); - GNUNET_snprintf (cfg_name, sizeof (cfg_name), - "perf_plugin_datastore_data_%s.conf", plugin_name); - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, - "perf-plugin-datastore", "nohelp", options, &run, NULL); - if (ok != 0) - FPRINTF (stderr, "Missed some testcases: %u\n", ok); - return ok; -} - - -int -main (int argc, char *argv[]) -{ - int ret; - char *pos; - char dir_name[128]; - - sleep (1); /* determine name of plugin to use */ plugin_name = argv[0]; while (NULL != (pos = strstr (plugin_name, "_"))) @@ -499,23 +474,24 @@ main (int argc, char *argv[]) pos[0] = 0; else pos = (char *) plugin_name; - GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/perf-gnunet-datastore-%s", plugin_name); GNUNET_DISK_directory_remove (dir_name); GNUNET_log_setup ("perf-plugin-datastore", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); - ret = check (); + GNUNET_snprintf (category, sizeof (category), "DATASTORE-%s", plugin_name); + GNUNET_snprintf (cfg_name, sizeof (cfg_name), + "perf_plugin_datastore_data_%s.conf", plugin_name); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 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 ret; + return ok; } /* end of perf_plugin_datastore.c */ diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index 4c0736619..cfeac86db 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c @@ -30,10 +30,8 @@ #include "gnunet_util_lib.h" #include "gnunet_protocols.h" #include "gnunet_datastore_service.h" +#include "gnunet_testing_lib-new.h" -#define VERBOSE GNUNET_NO - -#define START_DATASTORE GNUNET_YES /** * How long until we give up on transmitting the message? @@ -314,16 +312,12 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct CpsRunContext *crc = cls; ok = (int) crc->phase; -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test in phase %u\n", crc->phase); -#endif switch (crc->phase) { case RP_PUT: -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "PUT", crc->i); -#endif GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i), get_data (crc->i), get_type (crc->i), @@ -336,10 +330,8 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) break; case RP_GET: crc->i--; -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET", crc->i); -#endif GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, get_type (crc->i), 1, 1, TIMEOUT, &check_value, @@ -347,10 +339,8 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) break; case RP_DEL: crc->i--; -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "DEL", crc->i); -#endif crc->data = NULL; GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); GNUNET_assert (NULL != @@ -359,10 +349,8 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) &delete_value, crc)); break; case RP_DO_DEL: -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "DO_DEL", crc->i); -#endif if (crc->i == 0) { crc->i = ITERATIONS; @@ -379,10 +367,8 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) break; case RP_DELVALIDATE: crc->i--; -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "DEL-VALIDATE", crc->i); -#endif GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); GNUNET_assert (NULL != GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, @@ -433,9 +419,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) &check_update, crc)); break; case RP_DONE: -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished, disconnecting\n"); -#endif GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); GNUNET_free (crc); ok = 0; @@ -479,7 +463,7 @@ run_tests (void *cls, int32_t success, struct GNUNET_TIME_Absolute min_expiratio static void -run (void *cls, char *const *args, const char *cfgfile, +run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct CpsRunContext *crc; @@ -504,88 +488,29 @@ run (void *cls, char *const *args, const char *cfgfile, } -static int -check () -{ - char cfg_name[128]; - -#if START_DATASTORE - struct GNUNET_OS_Process *proc; -#endif - char *const argv[] = { - "test-datastore-api", - "-c", - cfg_name, -#if VERBOSE - "-L", "DEBUG", -#endif - NULL - }; - struct GNUNET_GETOPT_CommandLineOption options[] = { - GNUNET_GETOPT_OPTION_END - }; - GNUNET_snprintf (cfg_name, sizeof (cfg_name), - "test_datastore_api_data_%s.conf", plugin_name); -#if START_DATASTORE - proc = - GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", -#if VERBOSE - "-L", "DEBUG", -#endif - "-c", cfg_name, NULL); -#endif - GNUNET_assert (NULL != proc); - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, - "test-datastore-api", "nohelp", options, &run, NULL); -#if START_DATASTORE - sleep (1); /* give datastore chance to receive 'DROP' request */ - if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) - { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); - ok = 1; - } - GNUNET_OS_process_wait (proc); - GNUNET_OS_process_destroy (proc); - proc = NULL; -#endif - if (ok != 0) - FPRINTF (stderr, "Missed some testcases: %u\n", ok); - return ok; -} - int main (int argc, char *argv[]) { - int ret; char *pos; - char dir_name[128]; + char cfg_name[128]; - sleep (1); /* 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; + pos[0] = '\0'; else pos = (char *) plugin_name; - - GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-%s", - plugin_name); - GNUNET_DISK_directory_remove (dir_name); - GNUNET_log_setup ("test-datastore-api", -#if VERBOSE - "DEBUG", -#else - "WARNING", -#endif - NULL); - ret = check (); - if (pos != plugin_name) - pos[0] = '.'; - GNUNET_DISK_directory_remove (dir_name); - return ret; + GNUNET_snprintf (cfg_name, sizeof (cfg_name), + "test_datastore_api_data_%s.conf", plugin_name); + if (0 != + GNUNET_TESTING_peer_run ("test-gnunet-datastore", + cfg_name, + &run, + NULL)) + return 1; + return ok; } /* end of test_datastore_api.c */ diff --git a/src/datastore/test_datastore_api_data_sqlite.conf b/src/datastore/test_datastore_api_data_sqlite.conf index 098f9d2b6..a743b8008 100644 --- a/src/datastore/test_datastore_api_data_sqlite.conf +++ b/src/datastore/test_datastore_api_data_sqlite.conf @@ -19,6 +19,4 @@ PORT = 42464 [datastore] QUOTA = 10 MB -[fs] -AUTOSTART = NO diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index bb3898e08..9b5fb4e6f 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c @@ -22,13 +22,12 @@ * @brief Test for the space management functions of the datastore implementation. * @author Christian Grothoff */ - #include "platform.h" #include "gnunet_util_lib.h" #include "gnunet_protocols.h" #include "gnunet_datastore_service.h" +#include "gnunet_testing_lib-new.h" -#define VERBOSE GNUNET_NO /** * How long until we give up on transmitting the message? @@ -41,6 +40,27 @@ */ #define ITERATIONS 5000 +enum RunPhase +{ + RP_PUT, + RP_GET, + RP_DONE, + RP_GET_FAIL +}; + + +struct CpsRunContext +{ + GNUNET_HashCode key; + int i; + int found; + const struct GNUNET_CONFIGURATION_Handle *cfg; + void *data; + enum RunPhase phase; + uint64_t offset; +}; + + static struct GNUNET_DATASTORE_Handle *datastore; static struct GNUNET_TIME_Absolute now; @@ -49,6 +69,7 @@ static int ok; static const char *plugin_name; + static size_t get_size (int i) { @@ -96,26 +117,6 @@ get_expiration (int i) return av; } -enum RunPhase -{ - RP_PUT, - RP_GET, - RP_DONE, - RP_GET_FAIL -}; - - -struct CpsRunContext -{ - GNUNET_HashCode key; - int i; - int found; - const struct GNUNET_CONFIGURATION_Handle *cfg; - void *data; - enum RunPhase phase; - uint64_t offset; -}; - static void run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); @@ -193,10 +194,8 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) switch (crc->phase) { case RP_PUT: -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "PUT", crc->i); -#endif GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i), get_data (crc->i), get_type (crc->i), @@ -214,20 +213,16 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } break; case RP_GET: -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET", crc->i); -#endif GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key, get_type (crc->i), 1, 1, TIMEOUT, &check_value, crc); break; case RP_GET_FAIL: -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET(f)", crc->i); -#endif GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key, get_type (crc->i), 1, 1, TIMEOUT, &check_nothing, @@ -235,9 +230,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) break; case RP_DONE: GNUNET_assert (0 == crc->i); -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished, disconnecting\n"); -#endif GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); GNUNET_free (crc); ok = 0; @@ -265,7 +258,7 @@ run_tests (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, c static void -run (void *cls, char *const *args, const char *cfgfile, +run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct CpsRunContext *crc; @@ -290,61 +283,12 @@ run (void *cls, char *const *args, const char *cfgfile, } - -static int -check () -{ - struct GNUNET_OS_Process *proc; - char cfg_name[128]; - - char *const argv[] = { - "test-datastore-api-management", - "-c", - cfg_name, -#if VERBOSE - "-L", "DEBUG", -#endif - NULL - }; - struct GNUNET_GETOPT_CommandLineOption options[] = { - GNUNET_GETOPT_OPTION_END - }; - GNUNET_snprintf (cfg_name, sizeof (cfg_name), - "test_datastore_api_data_%s.conf", plugin_name); - proc = - GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", -#if VERBOSE - "-L", "DEBUG", -#endif - "-c", cfg_name, NULL); - GNUNET_assert (NULL != proc); - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, - "test-datastore-api-management", "nohelp", options, &run, - NULL); - sleep (1); /* give datastore chance to process 'DROP' request */ - if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) - { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); - ok = 1; - } - GNUNET_OS_process_wait (proc); - GNUNET_OS_process_destroy (proc); - proc = NULL; - if (ok != 0) - FPRINTF (stderr, "Missed some testcases: %u\n", ok); - return ok; -} - int main (int argc, char *argv[]) { - int ret; - char *pos; - char dir_name[128]; + char cfg_name[128]; - sleep (1); /* determine name of plugin to use */ plugin_name = argv[0]; while (NULL != (pos = strstr (plugin_name, "_"))) @@ -353,22 +297,15 @@ main (int argc, char *argv[]) pos[0] = 0; else pos = (char *) plugin_name; - - GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-%s", - plugin_name); - GNUNET_DISK_directory_remove (dir_name); - GNUNET_log_setup ("test-datastore-api-management", -#if VERBOSE - "DEBUG", -#else - "WARNING", -#endif - NULL); - ret = check (); - if (pos != plugin_name) - pos[0] = '.'; - GNUNET_DISK_directory_remove (dir_name); - return ret; + GNUNET_snprintf (cfg_name, sizeof (cfg_name), + "test_datastore_api_data_%s.conf", plugin_name); + if (0 != + GNUNET_TESTING_peer_run ("test-gnunet-datastore-management", + cfg_name, + &run, + NULL)) + return 1; + return ok; } /* end of test_datastore_api_management.c */ diff --git a/src/datastore/test_defaults.conf b/src/datastore/test_defaults.conf index ce27c018a..73e4a267d 100644 --- a/src/datastore/test_defaults.conf +++ b/src/datastore/test_defaults.conf @@ -31,3 +31,6 @@ AUTOSTART = NO [namestore] AUTOSTART = NO + +[fs] +AUTOSTART = NO diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c index 16fe40ceb..de9e7c2ab 100644 --- a/src/datastore/test_plugin_datastore.c +++ b/src/datastore/test_plugin_datastore.c @@ -28,8 +28,6 @@ #include "gnunet_protocols.h" #include "gnunet_datastore_plugin.h" -#define VERBOSE GNUNET_NO - /** * Number of put operations to perform. */ @@ -117,10 +115,9 @@ put_value (struct GNUNET_DATASTORE_PluginFunctions *api, int i, int k) value[0] = k; msg = NULL; prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); -#if VERBOSE - FPRINTF (stderr, "putting type %u, anon %u under key %s\n", i + 1, i, - GNUNET_h2s (&key)); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "putting type %u, anon %u under key %s\n", i + 1, i, + GNUNET_h2s (&key)); if (GNUNET_OK != api->put (api->cls, &key, size, value, i + 1 /* type */ , prio, i /* anonymity */ , 0 /* replication */ , @@ -159,12 +156,10 @@ iterate_one_shot (void *cls, const GNUNET_HashCode * key, uint32_t size, GNUNET_assert (key != NULL); guid = uid; crc->phase++; -#if VERBOSE - FPRINTF (stderr, - "Found result type=%u, priority=%u, size=%u, expire=%llu, key %s\n", - type, priority, size, (unsigned long long) expiration.abs_value, - GNUNET_h2s (key)); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Found result type=%u, priority=%u, size=%u, expire=%llu, key %s\n", + type, priority, size, (unsigned long long) expiration.abs_value, + GNUNET_h2s (key)); GNUNET_SCHEDULER_add_now (&test, crc); return GNUNET_OK; } @@ -229,9 +224,8 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test aborted.\n"); crc->phase = RP_ERROR; } -#if VERBOSE - FPRINTF (stderr, "In phase %d, iteration %u\n", crc->phase, crc->cnt); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "In phase %d, iteration %u\n", crc->phase, crc->cnt); switch (crc->phase) { case RP_ERROR: @@ -355,42 +349,23 @@ run (void *cls, char *const *args, const char *cfgfile, } -static int -check () + +int +main (int argc, char *argv[]) { + char *pos; + char dir_name[128]; char cfg_name[128]; - - char *const argv[] = { + char *const xargv[] = { "test-plugin-datastore", "-c", cfg_name, -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; - struct GNUNET_GETOPT_CommandLineOption options[] = { + static struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_snprintf (cfg_name, sizeof (cfg_name), - "test_plugin_datastore_data_%s.conf", plugin_name); - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, - "test-plugin-datastore", "nohelp", options, &run, NULL); - if (ok != 0) - FPRINTF (stderr, "Missed some testcases: %u\n", ok); - return ok; -} - - -int -main (int argc, char *argv[]) -{ - int ret; - char *pos; - char dir_name[128]; - - sleep (1); /* determine name of plugin to use */ plugin_name = argv[0]; while (NULL != (pos = strstr (plugin_name, "_"))) @@ -404,18 +379,18 @@ main (int argc, char *argv[]) "/tmp/test-gnunet-datastore-plugin-%s", plugin_name); GNUNET_DISK_directory_remove (dir_name); GNUNET_log_setup ("test-plugin-datastore", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); - ret = check (); + GNUNET_snprintf (cfg_name, sizeof (cfg_name), + "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) + FPRINTF (stderr, "Missed some testcases: %u\n", ok); if (pos != plugin_name) pos[0] = '.'; GNUNET_DISK_directory_remove (dir_name); - - return ret; + return ok; } /* end of test_plugin_datastore.c */ -- cgit v1.2.3