summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-09-02 16:17:12 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:03:33 -0500
commit033c2c07a3a080922a35cc674163b1768d0ff227 (patch)
treeb9e73aaba0773a6173905fcbeb9ffc01eea5ff24
parentdcb925bba737ab0ee7b5f45032eeba88b9305c6f (diff)
downloadsamba-033c2c07a3a080922a35cc674163b1768d0ff227.tar.gz
samba-033c2c07a3a080922a35cc674163b1768d0ff227.tar.bz2
samba-033c2c07a3a080922a35cc674163b1768d0ff227.zip
r24898: Fix LOCAL-REGISTRY, do not silently ignore testcase setup failures.
(This used to be commit 527ea7fccf4ace9cd9cbacf49820ecd208b8d570)
-rw-r--r--source4/lib/registry/ldb.c3
-rw-r--r--source4/lib/registry/tests/registry.c42
-rwxr-xr-xsource4/selftest/selftest.pl2
-rw-r--r--source4/torture/ui.c55
4 files changed, 49 insertions, 53 deletions
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index 8a34fa7a54..5ecbfa0407 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -327,8 +327,7 @@ WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
if (location == NULL)
return WERR_INVALID_PARAM;
- wrap = ldb_wrap_connect(parent_ctx, location, session_info,
- credentials, 0, NULL);
+ wrap = ldb_wrap_connect(parent_ctx, location, session_info, credentials, 0, NULL);
if (wrap == NULL) {
DEBUG(1, (__FILE__": unable to connect\n"));
diff --git a/source4/lib/registry/tests/registry.c b/source4/lib/registry/tests/registry.c
index fd2e98eac8..9ac61b1bc0 100644
--- a/source4/lib/registry/tests/registry.c
+++ b/source4/lib/registry/tests/registry.c
@@ -132,7 +132,7 @@ static bool test_create_nested_subkey(struct torture_context *tctx,
error = reg_key_add_name(rctx, root, "Hamburg", NULL, NULL,
&newkey1);
torture_assert_werr_ok(tctx, error, "Creating key return code");
- torture_assert(tctx, newkey2 != NULL, "Creating new key");
+ torture_assert(tctx, newkey1 != NULL, "Creating new key");
error = reg_key_add_name(rctx, root, "Hamburg\\Hamburg", NULL, NULL,
&newkey2);
@@ -374,7 +374,6 @@ static bool test_security(struct torture_context *tctx, const void *_data)
const struct registry_context *rctx = _data;
struct registry_key *subkey = NULL, *root;
WERROR error;
- uint32_t data = 42;
struct security_descriptor *osd, *nsd;
if (!create_test_key(tctx, rctx, "Düsseldorf", &root, &subkey))
@@ -511,26 +510,20 @@ static bool setup_local_registry(struct torture_context *tctx, void **data)
const char *tempdir;
NTSTATUS status;
struct hive_key *hive_key;
+ const char *filename;
error = reg_open_local(tctx, &rctx, NULL, NULL);
- if (!W_ERROR_IS_OK(error))
- return false;
+ torture_assert_werr_ok(tctx, error, "Opening local registry failed");
status = torture_temp_dir(tctx, "registry-local", &tempdir);
- if (!NT_STATUS_IS_OK(status))
- return false;
+ torture_assert_ntstatus_ok(tctx, status, "Creating temp dir failed");
- error = reg_open_ldb_file(tctx,
- talloc_asprintf(tctx, "%s/classes_root.ldb", tempdir),
- NULL,
- NULL,
- &hive_key);
- if (!W_ERROR_IS_OK(error))
- return false;
+ filename = talloc_asprintf(tctx, "%s/classes_root.ldb", tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, &hive_key);
+ torture_assert_werr_ok(tctx, error, "Opening classes_root file failed");
error = reg_mount_hive(rctx, hive_key, HKEY_CLASSES_ROOT, NULL);
- if (!W_ERROR_IS_OK(error))
- return false;
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
*data = rctx;
@@ -540,13 +533,10 @@ static bool setup_local_registry(struct torture_context *tctx, void **data)
static void tcase_add_tests(struct torture_tcase *tcase)
{
torture_tcase_add_simple_test(tcase, "list_subkeys", test_list_subkeys);
- torture_tcase_add_simple_test(tcase, "get_predefined_key",
- test_get_predefined);
- torture_tcase_add_simple_test(tcase, "get_predefined_key",
- test_get_predefined_unknown);
+ torture_tcase_add_simple_test(tcase, "get_predefined_key", test_get_predefined);
+ torture_tcase_add_simple_test(tcase, "get_predefined_key", test_get_predefined_unknown);
torture_tcase_add_simple_test(tcase, "create_key", test_create_subkey);
- torture_tcase_add_simple_test(tcase, "create_key",
- test_create_nested_subkey);
+ torture_tcase_add_simple_test(tcase, "create_key", test_create_nested_subkey);
torture_tcase_add_simple_test(tcase, "key_add_abs", test_key_add_abs);
torture_tcase_add_simple_test(tcase, "key_add_abs_top", test_key_add_abs_top);
torture_tcase_add_simple_test(tcase, "set_value", test_set_value);
@@ -558,18 +548,16 @@ static void tcase_add_tests(struct torture_tcase *tcase)
torture_tcase_add_simple_test(tcase, "query_key", test_query_key);
torture_tcase_add_simple_test(tcase, "query_key_nums", test_query_key_nums);
torture_tcase_add_simple_test(tcase, "test_predef_key_by_name",
- test_predef_key_by_name);
- torture_tcase_add_simple_test(tcase, "security",
- test_security);
+ test_predef_key_by_name);
+ torture_tcase_add_simple_test(tcase, "security", test_security);
torture_tcase_add_simple_test(tcase, "test_predef_key_by_name_invalid",
- test_predef_key_by_name_invalid);
+ test_predef_key_by_name_invalid);
}
struct torture_suite *torture_registry_registry(TALLOC_CTX *mem_ctx)
{
struct torture_tcase *tcase;
- struct torture_suite *suite = torture_suite_create(mem_ctx,
- "REGISTRY");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "REGISTRY");
tcase = torture_suite_add_tcase(suite, "local");
torture_tcase_set_fixture(tcase, setup_local_registry, NULL);
diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl
index 03247a4f81..9f16db0114 100755
--- a/source4/selftest/selftest.pl
+++ b/source4/selftest/selftest.pl
@@ -528,7 +528,7 @@ push (@torture_options, "--configfile=$conffile");
# ensure any one smbtorture call doesn't run too long
push (@torture_options, "--maximum-runtime=$torture_maxtime");
push (@torture_options, "--target=$opt_target");
-push (@torture_options, "--basedir=$prefix");
+push (@torture_options, "--basedir=$prefix_abs");
push (@torture_options, "--option=torture:progress=no") if ($opt_format eq "buildfarm");
push (@torture_options, "--format=subunit");
push (@torture_options, "--option=torture:quick=yes") if ($opt_quick);
diff --git a/source4/torture/ui.c b/source4/torture/ui.c
index f26909bd83..4c22d950ae 100644
--- a/source4/torture/ui.c
+++ b/source4/torture/ui.c
@@ -164,7 +164,7 @@ BOOL torture_run_suite(struct torture_context *context,
old_testname = context->active_testname;
if (old_testname != NULL)
context->active_testname = talloc_asprintf(context, "%s-%s",
- old_testname, suite->name);
+ old_testname, suite->name);
else
context->active_testname = talloc_strdup(context, suite->name);
@@ -219,22 +219,17 @@ void torture_ui_test_result(struct torture_context *context,
context->returncode = false;
}
-static BOOL internal_torture_run_test(struct torture_context *context,
+static bool internal_torture_run_test(struct torture_context *context,
struct torture_tcase *tcase,
struct torture_test *test,
- BOOL already_setup)
+ bool already_setup)
{
- BOOL ret;
+ bool success;
char *old_testname;
- if (!already_setup && tcase->setup &&
- !tcase->setup(context, &(tcase->data)))
- return false;
-
if (tcase == NULL || strcmp(test->name, tcase->name) != 0) {
old_testname = context->active_testname;
- context->active_testname = talloc_asprintf(context, "%s-%s",
- old_testname, test->name);
+ context->active_testname = talloc_asprintf(context, "%s-%s", old_testname, test->name);
}
context->active_tcase = tcase;
@@ -245,21 +240,34 @@ static BOOL internal_torture_run_test(struct torture_context *context,
context->last_reason = NULL;
context->last_result = TORTURE_OK;
- if (test->dangerous &&
+ if (!already_setup && tcase->setup &&
+ !tcase->setup(context, &(tcase->data))) {
+ if (context->last_reason == NULL)
+ context->last_reason = talloc_strdup(context, "Setup failure");
+ context->last_result = TORTURE_ERROR;
+ success = false;
+ } else if (test->dangerous &&
!torture_setting_bool(context, "dangerous", false)) {
context->last_result = TORTURE_SKIP;
context->last_reason = talloc_asprintf(context,
"disabled %s - enable dangerous tests to use", test->name);
} else {
- ret = test->run(context, tcase, test);
+ success = test->run(context, tcase, test);
- if (!ret && context->last_result == TORTURE_OK) {
+ if (!success && context->last_result == TORTURE_OK) {
if (context->last_reason == NULL)
context->last_reason = talloc_strdup(context, "Unknown error/failure");
context->last_result = TORTURE_ERROR;
}
}
+ if (!already_setup && tcase->teardown && !tcase->teardown(context, tcase->data)) {
+ if (context->last_reason == NULL)
+ context->last_reason = talloc_strdup(context, "Setup failure");
+ context->last_result = TORTURE_ERROR;
+ success = false;
+ }
+
torture_ui_test_result(context, context->last_result,
context->last_reason);
@@ -272,10 +280,7 @@ static BOOL internal_torture_run_test(struct torture_context *context,
context->active_test = NULL;
context->active_tcase = NULL;
- if (!already_setup && tcase->teardown && !tcase->teardown(context, tcase->data))
- return False;
-
- return ret;
+ return success;
}
BOOL torture_run_tcase(struct torture_context *context,
@@ -288,18 +293,22 @@ BOOL torture_run_tcase(struct torture_context *context,
context->level++;
context->active_tcase = tcase;
- if (context->ui_ops->tcase_start)
+ if (context->ui_ops->tcase_start)
context->ui_ops->tcase_start(context, tcase);
if (tcase->fixture_persistent && tcase->setup
&& !tcase->setup(context, &tcase->data)) {
- ret = False;
+ /* FIXME: Use torture ui ops for reporting this error */
+ fprintf(stderr, "Setup failed: ");
+ if (context->last_reason != NULL)
+ fprintf(stderr, "%s", context->last_reason);
+ fprintf(stderr, "\n");
+ ret = false;
goto done;
}
old_testname = context->active_testname;
- context->active_testname = talloc_asprintf(context, "%s-%s",
- old_testname, tcase->name);
+ context->active_testname = talloc_asprintf(context, "%s-%s", old_testname, tcase->name);
for (test = tcase->tests; test; test = test->next) {
ret &= internal_torture_run_test(context, tcase, test,
tcase->fixture_persistent);
@@ -309,7 +318,7 @@ BOOL torture_run_tcase(struct torture_context *context,
if (tcase->fixture_persistent && tcase->teardown &&
!tcase->teardown(context, tcase->data))
- ret = False;
+ ret = false;
done:
context->active_tcase = NULL;
@@ -326,7 +335,7 @@ BOOL torture_run_test(struct torture_context *context,
struct torture_tcase *tcase,
struct torture_test *test)
{
- return internal_torture_run_test(context, tcase, test, False);
+ return internal_torture_run_test(context, tcase, test, false);
}
int torture_setting_int(struct torture_context *test, const char *name,