From c53a4d5b82b7235734b21481305932a031ef7822 Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Thu, 26 Mar 2015 18:31:59 +0100 Subject: [PATCH] db: pick the right plugin in the DB testcase --- src/mint/Makefile.am | 6 +++--- src/mint/test-mint-db-postgres.conf | 6 ++++++ src/mint/test_mint_db.c | 25 +++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 src/mint/test-mint-db-postgres.conf diff --git a/src/mint/Makefile.am b/src/mint/Makefile.am index 1eba7d61d..17caccffa 100644 --- a/src/mint/Makefile.am +++ b/src/mint/Makefile.am @@ -117,7 +117,7 @@ taler_mint_dbinit_LDFLAGS = $(POSTGRESQL_LDFLAGS) check_PROGRAMS = \ test-mint-deposits \ test-mint-common \ - test-mint-db + test-mint-db-postgres test_mint_deposits_SOURCES = \ test_mint_deposits.c @@ -137,9 +137,9 @@ test_mint_common_LDADD = \ $(top_srcdir)/src/pq/libtalerpq.la \ -lgnunetutil -test_mint_db_SOURCES = \ +test_mint_db_postgres_SOURCES = \ test_mint_db.c -test_mint_db_LDADD = \ +test_mint_db_postgres_LDADD = \ libtalermint_common.la \ $(top_srcdir)/src/util/libtalerutil.la \ $(top_srcdir)/src/pq/libtalerpq.la \ diff --git a/src/mint/test-mint-db-postgres.conf b/src/mint/test-mint-db-postgres.conf new file mode 100644 index 000000000..a5a738e49 --- /dev/null +++ b/src/mint/test-mint-db-postgres.conf @@ -0,0 +1,6 @@ +[mint] +#The DB plugin to use +DB = postgres + +#The connection string the plugin has to use for connecting to the database +DB_CONN_STR = postgres:///taler diff --git a/src/mint/test_mint_db.c b/src/mint/test_mint_db.c index ef882b90a..4f41cdc23 100644 --- a/src/mint/test_mint_db.c +++ b/src/mint/test_mint_db.c @@ -354,13 +354,34 @@ main (int argc, static const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; + const char *argv2[] = { + "test-mint-db-", /* will be replaced later */ + "-c", "test-mint-db-.conf", /* will be replaced later */ + NULL, + }; + const char *plugin_name; + char *config_filename; result = -1; + if (NULL == (plugin_name = strrchr (argv[0], (int) '-'))) + { + GNUNET_break (0); + return -1; + } + plugin_name++; + (void) GNUNET_asprintf (&config_filename, + "test-mint-db-%s.conf", plugin_name); + argv2[0] = argv[0]; + argv2[2] = config_filename; if (GNUNET_OK != - GNUNET_PROGRAM_run (argc, argv, - "test-mint-db", + GNUNET_PROGRAM_run ((sizeof (argv2)/sizeof (char *)) - 1, argv2, + "test-mint-db-postgres", "Test cases for mint database helper functions.", options, &run, NULL)) + { + GNUNET_free (config_filename); return 3; + } + GNUNET_free (config_filename); return result; }