X-Git-Url: http://git.samba.org/samba.git/?a=blobdiff_plain;f=ctdb%2Ftests%2Fsrc%2Ftest_options.c;h=2c644046c24873a07e7ca4d1e4e13049979e974c;hb=23709cc3516fe54637775c19b4e57432fbada8f6;hp=847ec95766cf156bee8ff157ccb11481a2670e42;hpb=2650f37018e36a9d59046098e519a662d394950e;p=vlendec%2Fsamba-autobuild%2F.git diff --git a/ctdb/tests/src/test_options.c b/ctdb/tests/src/test_options.c index 847ec95766c..2c644046c24 100644 --- a/ctdb/tests/src/test_options.c +++ b/ctdb/tests/src/test_options.c @@ -19,64 +19,116 @@ #include "replace.h" +#include #include #include #include "lib/util/debug.h" #include "common/logging.h" +#include "common/path.h" #include "tests/src/test_options.h" static struct test_options _values; static struct poptOption options_basic[] = { - { "socket", 's', POPT_ARG_STRING, &_values.socket, 0, - "CTDB socket path", "filename" }, - { "timelimit", 't', POPT_ARG_INT, &_values.timelimit, 0, - "Time limit (in seconds)" }, - { "num-nodes", 'n', POPT_ARG_INT, &_values.num_nodes, 0, - "Number of cluster nodes" }, - { "debug", 'd', POPT_ARG_STRING, &_values.debugstr, 0, - "Debug level" }, - { "interactive", 'i', POPT_ARG_NONE, &_values.interactive, 0, - "Interactive output" }, - { NULL } + { + .longName = "socket", + .shortName = 's', + .argInfo = POPT_ARG_STRING, + .arg = &_values.socket, + .descrip = "CTDB socket path", + .argDescrip = "filename", + }, + { + .longName = "timelimit", + .shortName = 't', + .argInfo = POPT_ARG_INT, + .arg = &_values.timelimit, + .descrip = "Time limit (in seconds)", + }, + { + .longName = "num-nodes", + .shortName = 'n', + .argInfo = POPT_ARG_INT, + .arg = &_values.num_nodes, + .descrip = "Number of cluster nodes", + }, + { + .longName = "debug", + .shortName = 'd', + .argInfo = POPT_ARG_STRING, + .arg = &_values.debugstr, + .descrip = "Debug level", + }, + { + .longName = "interactive", + .shortName = 'i', + .argInfo = POPT_ARG_NONE, + .arg = &_values.interactive, + .val = 0, + .descrip = "Interactive output", + }, + POPT_TABLEEND }; -#define TEST_OPTIONS_BASIC \ - { NULL, 0, POPT_ARG_INCLUDE_TABLE, options_basic, 0, \ - "General options:", NULL }, +#define TEST_OPTIONS_BASIC \ + { \ + .argInfo = POPT_ARG_INCLUDE_TABLE, \ + .arg = options_basic, \ + .descrip = "General options:", \ + }, static struct poptOption options_database[] = { - { "database", 'D', POPT_ARG_STRING, &_values.dbname, 0, - "CTDB database name" }, - { "key", 'k', POPT_ARG_STRING, &_values.keystr, 0, - "Name of database key" }, - { "value", 'v', POPT_ARG_STRING, &_values.valuestr, 0, - "Value of database key" }, - { NULL } + { + .longName = "database", + .shortName = 'D', + .argInfo = POPT_ARG_STRING, + .arg = &_values.dbname, + .descrip = "CTDB database name", + }, + { + .longName = "key", + .shortName = 'k', + .argInfo = POPT_ARG_STRING, + .arg = &_values.keystr, + .descrip = "Name of database key", + }, + { + .longName = "value", + .shortName = 'v', + .argInfo = POPT_ARG_STRING, + .arg = &_values.valuestr, + .descrip = "Value of database key", + }, + { + .longName = "dbtype", + .shortName = 'T', + .argInfo = POPT_ARG_STRING, + .arg = &_values.dbtype, + .descrip = "CTDB database type", + }, + POPT_TABLEEND }; -#define TEST_OPTIONS_DATABASE \ - { NULL, 0, POPT_ARG_INCLUDE_TABLE, options_database, 0, \ - "Database options:", NULL }, +#define TEST_OPTIONS_DATABASE \ + { \ + .argInfo = POPT_ARG_INCLUDE_TABLE, \ + .arg = options_database, \ + .descrip = "Database options:", \ + }, static void set_defaults_basic(struct test_options *opts) { - const char *ctdb_socket; - /* Set default options */ - opts->socket = CTDB_SOCKET; + opts->socket = path_socket(NULL, "ctdbd"); /* leaked */ + assert(opts->socket != NULL); + opts->timelimit = 10; opts->num_nodes = 1; opts->debugstr = "ERR"; opts->interactive = 0; - - ctdb_socket = getenv("CTDB_SOCKET"); - if (ctdb_socket != NULL) { - opts->socket = ctdb_socket; - } } static void set_defaults_database(struct test_options *opts) @@ -84,6 +136,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) @@ -98,7 +151,7 @@ static bool verify_options_basic(struct test_options *opts) return false; } - DEBUGLEVEL = log_level; + debuglevel_set(log_level); return true; } @@ -114,6 +167,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; }