ctdb-tests: Add database type option for tests
authorAmitay Isaacs <amitay@gmail.com>
Thu, 2 Mar 2017 07:14:44 +0000 (18:14 +1100)
committerMartin Schwenke <martins@samba.org>
Thu, 29 Jun 2017 08:34:28 +0000 (10:34 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/tests/src/test_options.c
ctdb/tests/src/test_options.h

index 847ec95766cf156bee8ff157ccb11481a2670e42..e732a79c8ff378f2655bd59281335bdb4e90fdf3 100644 (file)
@@ -55,6 +55,8 @@ static struct poptOption options_database[] = {
                "Name of database key" },
        { "value", 'v', POPT_ARG_STRING, &_values.valuestr, 0,
                "Value of database key" },
+       { "dbtype", 'T', POPT_ARG_STRING, &_values.dbtype, 0,
+               "CTDB database type" },
        { NULL }
 };
 
@@ -84,6 +86,7 @@ static void set_defaults_database(struct test_options *opts)
        opts->dbname = NULL;
        opts->keystr = NULL;
        opts->valuestr = NULL;
+       opts->dbtype = "volatile";
 }
 
 static bool verify_options_basic(struct test_options *opts)
@@ -114,6 +117,12 @@ static bool verify_options_database(struct test_options *opts)
                return false;
        }
 
+       if ((strcmp(opts->dbtype, "volatile") != 0) &&
+           (strcmp(opts->dbtype, "persistent") != 0) &&
+           (strcmp(opts->dbtype, "replicated") != 0)) {
+               return false;
+       }
+
        return true;
 }
 
index 4874dd2adedc771e956cdaec3cefc8152ef65ef4..1e194c9e436ffa383472f04ef467decc86d1f85e 100644 (file)
@@ -32,6 +32,7 @@ struct test_options {
        const char *dbname;
        const char *keystr;
        const char *valuestr;
+       const char *dbtype;
 };
 
 bool process_options_basic(int argc, const char **argv,