From 8773e743c518578584d07d35ffdafdd598af88b0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 16 Oct 2006 13:06:41 +0000 Subject: r19339: Merge my 4.0-unittest branch. This adds an API for more fine-grained output in the testsuite rather than just True or False for a set of tests. The aim is to use this for: * known failure lists (run all tests and detect tests that started working or started failing). This would allow us to get rid of the RPC-SAMBA3-* tests * nicer torture output * simplification of the testsuite system * compatibility with other unit testing systems * easier usage of smbtorture (being able to run one test and automatically set up the environment for that) This is still a work-in-progress; expect more updates over the next couple of days. (This used to be commit 0eb6097305776325c75081356309115f445a7218) --- source4/torture/basic/rename.c | 96 +++++++++++++----------------------------- 1 file changed, 29 insertions(+), 67 deletions(-) (limited to 'source4/torture/basic/rename.c') diff --git a/source4/torture/basic/rename.c b/source4/torture/basic/rename.c index b80c909470..2d4fb38e9f 100644 --- a/source4/torture/basic/rename.c +++ b/source4/torture/basic/rename.c @@ -28,20 +28,13 @@ /* Test rename on files open with share delete and no share delete. */ -BOOL torture_test_rename(struct torture_context *torture) +BOOL torture_test_rename(struct torture_context *tctx, + struct smbcli_state *cli1) { - struct smbcli_state *cli1; const char *fname = "\\test.txt"; const char *fname1 = "\\test1.txt"; - BOOL correct = True; int fnum1; - printf("starting rename test\n"); - - if (!torture_open_connection(&cli1, 0)) { - return False; - } - smbcli_unlink(cli1->tree, fname); smbcli_unlink(cli1->tree, fname1); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -50,24 +43,14 @@ BOOL torture_test_rename(struct torture_context *torture) NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) First open failed - %s\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } - - if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) { - printf("First rename failed (this is correct) - %s\n", smbcli_errstr(cli1->tree)); - } else { - printf("(%s) First rename succeeded - this should have failed !\n", - __location__); - correct = False; - } - - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 1 failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "First open failed - %s", + smbcli_errstr(cli1->tree))); + + torture_assert(tctx, NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1)), + "First rename succeeded - this should have failed !"); + + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 1 failed (%s)", smbcli_errstr(cli1->tree))); smbcli_unlink(cli1->tree, fname); smbcli_unlink(cli1->tree, fname1); @@ -77,24 +60,17 @@ BOOL torture_test_rename(struct torture_context *torture) NTCREATEX_SHARE_ACCESS_DELETE|NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) Second open failed - %s\n", __location__, smbcli_errstr(cli1->tree)); - return False; - } - - if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) { - printf("(%s) Second rename failed - this should have succeeded - %s\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - } else { - printf("Second rename succeeded\n"); - } - - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, + "Second open failed - %s", smbcli_errstr(cli1->tree))); + + torture_assert_ntstatus_ok(tctx, smbcli_rename(cli1->tree, fname, fname1), + talloc_asprintf(tctx, + "Second rename failed - this should have succeeded - %s", + smbcli_errstr(cli1->tree))); + + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, + "close - 2 failed (%s)", smbcli_errstr(cli1->tree))); smbcli_unlink(cli1->tree, fname); smbcli_unlink(cli1->tree, fname1); @@ -105,33 +81,19 @@ BOOL torture_test_rename(struct torture_context *torture) NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) Third open failed - %s\n", __location__, smbcli_errstr(cli1->tree)); - return False; - } - + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "Third open failed - %s", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) { - printf("(%s) Third rename failed - this should have succeeded - %s\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - } else { - printf("Third rename succeeded\n"); - } + torture_assert_ntstatus_ok(tctx, smbcli_rename(cli1->tree, fname, fname1), + talloc_asprintf(tctx, "Third rename failed - this should have succeeded - %s", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 3 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 3 failed (%s)", smbcli_errstr(cli1->tree))); smbcli_unlink(cli1->tree, fname); smbcli_unlink(cli1->tree, fname1); - if (!torture_close_connection(cli1)) { - correct = False; - } - - return correct; + return true; } -- cgit