diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-04-28 11:40:40 +0200 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-04-28 11:40:40 +0200 |
commit | 514f92a9169d70113f2e189bd3d5f8e83034d3a9 (patch) | |
tree | f22ab6a20ca152c9199cbc9d1b6ca1dd02a03494 /src/backenddb | |
parent | e5fd06914800c3a8f0eb8f9af91f94d1c09deaa5 (diff) | |
download | merchant-514f92a9169d70113f2e189bd3d5f8e83034d3a9.tar.gz merchant-514f92a9169d70113f2e189bd3d5f8e83034d3a9.tar.bz2 merchant-514f92a9169d70113f2e189bd3d5f8e83034d3a9.zip |
configuration file for testcase + "run()" function for it
Diffstat (limited to 'src/backenddb')
-rw-r--r-- | src/backenddb/Makefile.am | 29 | ||||
-rw-r--r-- | src/backenddb/test-merchantdb-postgres.conf | 5 | ||||
-rw-r--r-- | src/backenddb/test_merchantdb.c | 66 |
3 files changed, 89 insertions, 11 deletions
diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am index e74d12c9..692dd746 100644 --- a/src/backenddb/Makefile.am +++ b/src/backenddb/Makefile.am @@ -40,14 +40,21 @@ libtaler_plugin_merchantdb_postgres_la_LDFLAGS = \ -lgnunetpostgres \ -lgnunetutil $(XLIB) -#check_PROGRAMS = \ -# test-merchantdb-postgres -# -#test_merchantdb_postgres_SOURCES = \ -# test_merchantdb.c -# -#test_merchantdb_postgres_LDADD = \ -# # TODO -# -#TESTS = \ -# test-merchantdb-postgres +if HAVE_POSTGRESQL +if HAVE_GNUNETPQ +check_PROGRAMS = \ + test-merchantdb-postgres +endif +endif + +test_merchantdb_postgres_SOURCES = \ + test_merchantdb.c + +test_merchantdb_postgres_LDFLAGS = \ + -lgnunetutil + +test_merchantdb_postgres_LDADD = \ + $(top_srcdir)/src/backenddb/libtalermerchantdb.la + +TESTS = \ + test-merchantdb-postgres diff --git a/src/backenddb/test-merchantdb-postgres.conf b/src/backenddb/test-merchantdb-postgres.conf new file mode 100644 index 00000000..614519ba --- /dev/null +++ b/src/backenddb/test-merchantdb-postgres.conf @@ -0,0 +1,5 @@ +[merchant] +DB = postgres + +[merchantdb-postgres] +CONFIG = postges:///talertest diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 6054963b..96975ca9 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -18,3 +18,69 @@ * @brief testcase for merchant's postgres db plugin * @author Marcello Stanisci */ + +#include "platform.h" +#include <taler/taler_util.h> +#include "taler_merchantdb_lib.h" + +static int result; +static struct TALER_EXCHANGEDB_Plugin *plugin; + +/** + * Main function that will be run by the scheduler. + * + * @param cls closure with config + */ +static void +run (void *cls) +{ + struct GNUNET_CONFIGURATION_Handle *cfg = cls; + + if (NULL == + (plugin = TALER_MERCHANTDB_plugin_load (cfg))) + { + result = 1; + return; + } +} + +int +main (int argc, + char *const argv[]) +{ + + const char *plugin_name; + char *config_filename; + char *testname; + struct GNUNET_CONFIGURATION_Handle *cfg; + + result = -1; + if (NULL == (plugin_name = strrchr (argv[0], (int) '-'))) + { + GNUNET_break (0); + return -1; + } + GNUNET_log_setup (argv[0], + "WARNING", + NULL); + plugin_name++; + (void) GNUNET_asprintf (&testname, + "test-merchantdb-%s", plugin_name); + (void) GNUNET_asprintf (&config_filename, + "%s.conf", testname); + cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_OK != + GNUNET_CONFIGURATION_parse (cfg, + config_filename)) + { + GNUNET_break (0); + GNUNET_free (config_filename); + GNUNET_free (testname); + return 2; + } + GNUNET_SCHEDULER_run (&run, cfg); + GNUNET_CONFIGURATION_destroy (cfg); + GNUNET_free (config_filename); + GNUNET_free (testname); + return result; +} |