The branch, master has been updated via effc61c... smbtorture: Make SAMBA3CASEINSENSITIVE report failures properly. via b7ad0c6... smbtorture: Emit correct test results if setup fails. via 21fe753... smbtorture: Ensure that the RPC setup returns correct status. from f37793e... s4:ldap_server use talloc_unlink() to avoid talloc_free() with references
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit effc61cb782a470a0a3dee317ad271e521f6c3be Author: James Peach <jpe...@samba.org> Date: Thu Aug 12 14:31:52 2010 -0700 smbtorture: Make SAMBA3CASEINSENSITIVE report failures properly. commit b7ad0c6e394b09a8933080e966ba1c77575d9f31 Author: James Peach <jpe...@samba.org> Date: Thu Aug 12 12:36:24 2010 -0700 smbtorture: Emit correct test results if setup fails. If the test setup fails, we still need to format the test result for the UI. At leas in the subunit case, the format doesn't specify what to do here, so we fail every test manually with the setup failure message. commit 21fe7533032168222a32bc12e2ade1169d41b763 Author: James Peach <jpe...@samba.org> Date: Thu Aug 12 12:35:53 2010 -0700 smbtorture: Ensure that the RPC setup returns correct status. ----------------------------------------------------------------------- Summary of changes: lib/torture/torture.c | 46 +++++++++++++++++++++++++------------ source4/torture/raw/samba3misc.c | 10 +++++--- source4/torture/rpc/rpc.c | 8 +++--- 3 files changed, 41 insertions(+), 23 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/torture/torture.c b/lib/torture/torture.c index 71bd53b..27b2bdc 100644 --- a/lib/torture/torture.c +++ b/lib/torture/torture.c @@ -343,6 +343,7 @@ static bool internal_torture_run_test(struct torture_context *context, context->active_testname = talloc_asprintf(context, "%s-%s", old_testname, test->name); } + context->active_tcase = tcase; context->active_test = test; @@ -401,43 +402,58 @@ bool torture_run_tcase(struct torture_context *context, bool ret = true; char *old_testname; struct torture_test *test; + bool setup_succeeded = true; + const char * setup_reason = "Setup failed"; context->active_tcase = tcase; if (context->results->ui_ops->tcase_start) context->results->ui_ops->tcase_start(context, tcase); - if (tcase->fixture_persistent && tcase->setup - && !tcase->setup(context, &tcase->data)) { - /* 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; + if (tcase->fixture_persistent && tcase->setup) { + setup_succeeded = tcase->setup(context, &tcase->data); + } + + if (!setup_succeeded) { + /* Uh-oh. The setup failed, so we can't run any of the tests + * in this testcase. The subunit format doesn't specify what + * to do here, so we keep the failure reason, and manually + * use it to fail every test. + */ + if (context->last_reason != NULL) { + setup_reason = talloc_asprintf(context, + "Setup failed: %s", context->last_reason); + } } old_testname = context->active_testname; 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); + if (setup_succeeded) { + ret &= internal_torture_run_test(context, tcase, test, + tcase->fixture_persistent); + } else { + context->active_tcase = tcase; + context->active_test = test; + torture_ui_test_start(context, tcase, test); + torture_ui_test_result(context, TORTURE_FAIL, setup_reason); + } } talloc_free(context->active_testname); context->active_testname = old_testname; - if (tcase->fixture_persistent && tcase->teardown && - !tcase->teardown(context, tcase->data)) + if (setup_succeeded && tcase->fixture_persistent && tcase->teardown && + !tcase->teardown(context, tcase->data)) { ret = false; + } -done: context->active_tcase = NULL; + context->active_test = NULL; if (context->results->ui_ops->tcase_finish) context->results->ui_ops->tcase_finish(context, tcase); - return ret; + return (!setup_succeeded) ? false : ret; } bool torture_run_test(struct torture_context *context, diff --git a/source4/torture/raw/samba3misc.c b/source4/torture/raw/samba3misc.c index 603c9f6..a603111 100644 --- a/source4/torture/raw/samba3misc.c +++ b/source4/torture/raw/samba3misc.c @@ -621,7 +621,7 @@ bool torture_samba3_caseinsensitive(struct torture_context *torture) char *fpath; int fnum; int counter = 0; - bool ret = true; + bool ret = false; if (!(mem_ctx = talloc_init("torture_samba3_caseinsensitive"))) { d_printf("talloc_init failed\n"); @@ -635,8 +635,8 @@ bool torture_samba3_caseinsensitive(struct torture_context *torture) smbcli_deltree(cli->tree, dirname); status = smbcli_mkdir(cli->tree, dirname); + torture_assert_ntstatus_ok(torture, status, "smbcli_mkdir failed"); if (!NT_STATUS_IS_OK(status)) { - d_printf("smbcli_mkdir failed: %s\n", nt_errstr(status)); goto done; } @@ -645,7 +645,8 @@ bool torture_samba3_caseinsensitive(struct torture_context *torture) } fnum = smbcli_open(cli->tree, fpath, O_RDWR | O_CREAT, DENY_NONE); if (fnum == -1) { - d_printf("Could not create file %s: %s\n", fpath, + torture_result(torture, TORTURE_FAIL, + "Could not create file %s: %s", fpath, smbcli_errstr(cli->tree)); goto done; } @@ -661,7 +662,8 @@ bool torture_samba3_caseinsensitive(struct torture_context *torture) ret = true; } else { - d_fprintf(stderr, "expected 3 entries, got %d\n", counter); + torture_result(torture, TORTURE_FAIL, + "expected 3 entries, got %d", counter); ret = false; } diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c index c652ec6..caec56f 100644 --- a/source4/torture/rpc/rpc.c +++ b/source4/torture/rpc/rpc.c @@ -151,7 +151,7 @@ static bool torture_rpc_setup_machine_workstation(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "Error connecting to server"); - return true; + return NT_STATUS_IS_OK(status); } static bool torture_rpc_setup_machine_bdc(struct torture_context *tctx, @@ -183,7 +183,7 @@ static bool torture_rpc_setup_machine_bdc(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "Error connecting to server"); - return true; + return NT_STATUS_IS_OK(status); } _PUBLIC_ struct torture_rpc_tcase *torture_suite_add_machine_workstation_rpc_iface_tcase( @@ -259,7 +259,7 @@ static bool torture_rpc_setup_anonymous(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "Error connecting to server"); - return true; + return NT_STATUS_IS_OK(status); } static bool torture_rpc_setup (struct torture_context *tctx, void **data) @@ -278,7 +278,7 @@ static bool torture_rpc_setup (struct torture_context *tctx, void **data) torture_assert_ntstatus_ok(tctx, status, "Error connecting to server"); - return true; + return NT_STATUS_IS_OK(status); } -- Samba Shared Repository