diff options
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/local/dbspeed.c | 2 | ||||
-rw-r--r-- | source4/torture/smbtorture.c | 38 | ||||
-rw-r--r-- | source4/torture/torture.c | 35 | ||||
-rw-r--r-- | source4/torture/torture.h | 7 | ||||
-rw-r--r-- | source4/torture/ui.c | 9 | ||||
-rw-r--r-- | source4/torture/ui.h | 4 |
6 files changed, 40 insertions, 55 deletions
diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c index 757c13cf6e..3f9607eb81 100644 --- a/source4/torture/local/dbspeed.c +++ b/source4/torture/local/dbspeed.c @@ -245,7 +245,7 @@ failed: struct torture_suite *torture_local_dbspeed(TALLOC_CTX *mem_ctx) { - struct torture_suite *s = torture_suite_create(mem_ctx, "LOCAL-DBSPEED"); + struct torture_suite *s = torture_suite_create(mem_ctx, "DBSPEED"); torture_suite_add_simple_tcase(s, "tdb_speed", test_tdb_speed, NULL); torture_suite_add_simple_tcase(s, "ldb_speed", test_ldb_speed, NULL); return s; diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index 3d7a75f8cf..3733d72492 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -43,18 +43,18 @@ static bool run_matching(struct torture_context *torture, bool ret = true; if (suite == NULL) { - struct torture_suite_list *o; + struct torture_suite *o; - for (o = torture_suites; o; o = o->next) { - if (gen_fnmatch(expr, o->suite->name) == 0) { + for (o = torture_root->children; o; o = o->next) { + if (gen_fnmatch(expr, o->name) == 0) { *matched = true; init_iconv(); - ret &= torture_run_suite(torture, o->suite); + ret &= torture_run_suite(torture, o); continue; } ret &= run_matching(torture, - o->suite->name, expr, o->suite, matched); + o->name, expr, o, matched); } } else { char *name; @@ -99,11 +99,11 @@ static bool run_test(struct torture_context *torture, const char *name) { bool ret = true; bool matched = false; - struct torture_suite_list *o; + struct torture_suite *o; if (strequal(name, "ALL")) { - for (o = torture_suites; o; o = o->next) { - ret &= torture_run_suite(torture, o->suite); + for (o = torture_root->children; o; o = o->next) { + ret &= torture_run_suite(torture, o); } return ret; } @@ -160,7 +160,7 @@ static void parse_dns(const char *dns) static void usage(poptContext pc) { - struct torture_suite_list *o; + struct torture_suite *o; struct torture_suite *s; struct torture_tcase *t; int i; @@ -217,24 +217,24 @@ static void usage(poptContext pc) printf("Tests are:"); - for (o = torture_suites; o; o = o->next) { - printf("\n%s (%s):\n ", o->suite->description, o->suite->name); + for (o = torture_root->children; o; o = o->next) { + printf("\n%s (%s):\n ", o->description, o->name); i = 0; - for (s = o->suite->children; s; s = s->next) { - if (i + strlen(o->suite->name) + strlen(s->name) >= (MAX_COLS - 3)) { + for (s = o->children; s; s = s->next) { + if (i + strlen(o->name) + strlen(s->name) >= (MAX_COLS - 3)) { printf("\n "); i = 0; } - i+=printf("%s-%s ", o->suite->name, s->name); + i+=printf("%s-%s ", o->name, s->name); } - for (t = o->suite->testcases; t; t = t->next) { - if (i + strlen(o->suite->name) + strlen(t->name) >= (MAX_COLS - 3)) { + for (t = o->testcases; t; t = t->next) { + if (i + strlen(o->name) + strlen(t->name) >= (MAX_COLS - 3)) { printf("\n "); i = 0; } - i+=printf("%s-%s ", o->suite->name, t->name); + i+=printf("%s-%s ", o->name, t->name); } if (i) printf("\n"); @@ -532,10 +532,10 @@ const static struct torture_ui_ops quiet_ui_ops = { subunit_dir = lp_parm_string_list(-1, "torture", "subunitdir", ":"); if (subunit_dir == NULL) - torture_subunit_load_testsuites(dyn_TORTUREDIR); + torture_subunit_load_testsuites(dyn_TORTUREDIR, true, NULL); else { for (i = 0; subunit_dir[i]; i++) - torture_subunit_load_testsuites(subunit_dir[i]); + torture_subunit_load_testsuites(subunit_dir[i], true, NULL); } diff --git a/source4/torture/torture.c b/source4/torture/torture.c index d5cb0511f7..f83a7330c2 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -33,42 +33,23 @@ _PUBLIC_ int torture_seed=0; _PUBLIC_ int torture_numasync=100; _PUBLIC_ bool torture_showall = false; -struct torture_suite_list *torture_suites = NULL; +struct torture_suite *torture_root = NULL; -NTSTATUS torture_register_suite(struct torture_suite *suite) +bool torture_register_suite(struct torture_suite *suite) { - struct torture_suite_list *p, *n; + if (!suite) + return true; - if (!suite) { - return NT_STATUS_OK; - } - - n = talloc(talloc_autofree_context(), struct torture_suite_list); - n->suite = suite; - - for (p = torture_suites; p; p = p->next) { - if (strcmp(p->suite->name, suite->name) == 0) { - /* Check for duplicates */ - DEBUG(0,("There already is a suite registered with the name %s!\n", suite->name)); - return NT_STATUS_OBJECT_NAME_COLLISION; - } - - if (strcmp(p->suite->name, suite->name) < 0 && - (!p->next || strcmp(p->next->suite->name, suite->name) > 0)) { - DLIST_ADD_AFTER(torture_suites, n, p); - return NT_STATUS_OK; - } - } - - DLIST_ADD_END(torture_suites, n, struct torture_suite_list *); - - return NT_STATUS_OK; + return torture_suite_add_suite(torture_root, suite); } int torture_init(void) { init_module_fn static_init[] = STATIC_torture_MODULES; init_module_fn *shared_init = load_samba_modules(NULL, "torture"); + + torture_root = talloc_zero(talloc_autofree_context(), + struct torture_suite); run_init_functions(static_init); run_init_functions(shared_init); diff --git a/source4/torture/torture.h b/source4/torture/torture.h index 1a1cd7aba9..a88c1c3654 100644 --- a/source4/torture/torture.h +++ b/source4/torture/torture.h @@ -26,12 +26,7 @@ struct smbcli_state; -struct torture_suite_list { - struct torture_suite *suite; - struct torture_suite_list *prev, *next; -}; - -extern struct torture_suite_list * torture_suites; +extern struct torture_suite *torture_root; extern BOOL use_oplocks; extern BOOL torture_showall; diff --git a/source4/torture/ui.c b/source4/torture/ui.c index 32b632a3e8..d8bff6cca3 100644 --- a/source4/torture/ui.c +++ b/source4/torture/ui.c @@ -394,9 +394,14 @@ bool torture_suite_add_suite(struct torture_suite *suite, } -struct torture_suite *torture_find_suite(const char *name) +struct torture_suite *torture_find_suite(struct torture_suite *parent, + const char *name) { - /* FIXME */ + struct torture_suite *child; + + for (child = parent->children; child; child = child->next) + if (!strcmp(child->name, name)) + return child; return NULL; } diff --git a/source4/torture/ui.h b/source4/torture/ui.h index b4e3585031..b145989046 100644 --- a/source4/torture/ui.h +++ b/source4/torture/ui.h @@ -294,4 +294,8 @@ bool torture_setting_bool(struct torture_context *test, /* Helper function commonly used */ bool torture_teardown_free(struct torture_context *torture, void *data); +struct torture_suite *torture_find_suite(struct torture_suite *parent, + const char *name); + + #endif /* __TORTURE_UI_H__ */ |