summaryrefslogtreecommitdiff
path: root/source4/torture/basic/rename.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-10-16 13:06:41 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:21:12 -0500
commit8773e743c518578584d07d35ffdafdd598af88b0 (patch)
tree89726232dd6ae9eca1c219e21729a9b2336ddaa9 /source4/torture/basic/rename.c
parent0f2347e417dec4a50f95d64353b260cd53a44a2b (diff)
downloadsamba-8773e743c518578584d07d35ffdafdd598af88b0.tar.gz
samba-8773e743c518578584d07d35ffdafdd598af88b0.tar.bz2
samba-8773e743c518578584d07d35ffdafdd598af88b0.zip
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)
Diffstat (limited to 'source4/torture/basic/rename.c')
-rw-r--r--source4/torture/basic/rename.c96
1 files changed, 29 insertions, 67 deletions
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;
}