s4: [2/3] Fix a delete on close divergence from windows and the associated torture...
[kai/samba.git] / source4 / torture / basic / delete.c
index 97ae518ea831966c4392a4639fed0977a59c77f0..c1ac62f1b1eac34cc4cbdb2b4090045977b5a77b 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
 #include "torture/util.h"
 #include "system/filesys.h"
 #include "libcli/raw/libcliraw.h"
+#include "libcli/raw/raw_proto.h"
 
 #include "torture/raw/proto.h"
 
-static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum,
-                                 const char *fname, BOOL expect_it, 
-                                 const char *where)
+static bool check_delete_on_close(struct torture_context *tctx, 
+                                                                 struct smbcli_state *cli, int fnum,
+                                                                 const char *fname, bool expect_it, 
+                                                                 const char *where)
 {
-       TALLOC_CTX *mem_ctx = talloc_init("single_search");
        union smb_search_data data;
        NTSTATUS status;
 
@@ -41,18 +41,14 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum,
        size_t size;
        uint16_t mode;
 
-       BOOL res = True;
-
-       status = torture_single_search(cli, mem_ctx,
-                                      fname, RAW_SEARCH_FULL_DIRECTORY_INFO,
+       status = torture_single_search(cli, tctx,
+                                      fname,
+                                      RAW_SEARCH_TRANS2,
+                                      RAW_SEARCH_DATA_FULL_DIRECTORY_INFO,
                                       FILE_ATTRIBUTE_DIRECTORY,
                                       &data);
-       if (!NT_STATUS_IS_OK(status)) {
-               printf("(%s) single_search failed (%s)\n", 
-                      where, nt_errstr(status));
-               res = False;
-               goto done;
-       }
+       torture_assert_ntstatus_ok(tctx, status, 
+               talloc_asprintf(tctx, "single_search failed (%s)", where));
 
        if (fnum != -1) {
                union smb_fileinfo io;
@@ -61,53 +57,33 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum,
                io.all_info.level = RAW_FILEINFO_ALL_INFO;
                io.all_info.in.file.fnum = fnum;
 
-               status = smb_raw_fileinfo(cli->tree, mem_ctx, &io);
-               if (!NT_STATUS_IS_OK(status)) {
-                       printf("(%s) qfileinfo failed (%s)\n", where,
-                              nt_errstr(status));
-                       res = False;
-                       goto done;
-               }
+               status = smb_raw_fileinfo(cli->tree, tctx, &io);
+               torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, 
+                                       "qfileinfo failed (%s)", where));
 
-               if (expect_it != io.all_info.out.delete_pending) {
-                       printf("%s - Expected del_on_close flag %d, qfileinfo/all_info gave %d\n",
-                              where, expect_it, io.all_info.out.delete_pending);
-                       res = False;
-                       goto done;
-               }
+               torture_assert(tctx, expect_it == io.all_info.out.delete_pending, 
+                       talloc_asprintf(tctx, 
+                       "%s - Expected del_on_close flag %d, qfileinfo/all_info gave %d",
+                              where, expect_it, io.all_info.out.delete_pending));
 
-               if (nlink != io.all_info.out.nlink) {
-                       printf("%s - Expected nlink %d, qfileinfo/all_info gave %d\n",
-                              where, nlink, io.all_info.out.nlink);
-                       res = False;
-                       goto done;
-               }
+               torture_assert(tctx, nlink == io.all_info.out.nlink, 
+                       talloc_asprintf(tctx, 
+                               "%s - Expected nlink %d, qfileinfo/all_info gave %d",
+                              where, nlink, io.all_info.out.nlink));
 
                io.standard_info.level = RAW_FILEINFO_STANDARD_INFO;
                io.standard_info.in.file.fnum = fnum;
 
-               status = smb_raw_fileinfo(cli->tree, mem_ctx, &io);
-               if (!NT_STATUS_IS_OK(status)) {
-                       printf("(%s) qpathinfo failed (%s)\n", where,
-                              nt_errstr(status));
-                       res = False;
-                       goto done;
-               }
+               status = smb_raw_fileinfo(cli->tree, tctx, &io);
+               torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "qpathinfo failed (%s)", where));
 
-               if (expect_it != io.standard_info.out.delete_pending) {
-                       printf("%s - Expected del_on_close flag %d, qfileinfo/standard_info gave %d\n",
-                              where, expect_it, io.standard_info.out.delete_pending);
-                       res = False;
-                       goto done;
-               }
-
-               if (nlink != io.standard_info.out.nlink) {
-                       printf("%s - Expected nlink %d, qfileinfo/standard_info gave %d\n",
-                              where, nlink, io.all_info.out.nlink);
-                       res = False;
-                       goto done;
-               }
+               torture_assert(tctx, expect_it == io.standard_info.out.delete_pending,
+                       talloc_asprintf(tctx, "%s - Expected del_on_close flag %d, qfileinfo/standard_info gave %d\n",
+                              where, expect_it, io.standard_info.out.delete_pending));
 
+               torture_assert(tctx, nlink == io.standard_info.out.nlink,
+                       talloc_asprintf(tctx, "%s - Expected nlink %d, qfileinfo/standard_info gave %d",
+                              where, nlink, io.all_info.out.nlink));
        }
 
        status = smbcli_qpathinfo(cli->tree, fname,
@@ -115,55 +91,39 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum,
                                  &size, &mode);
 
        if (expect_it) {
-               if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) {
-                       printf("(%s) qpathinfo did not give correct error "
-                              "code (%s) -- NT_STATUS_DELETE_PENDING "
-                              "expected\n", where,
-                              nt_errstr(status));
-                       res = False;
-                       goto done;
-               }
+               torture_assert_ntstatus_equal(tctx, status, NT_STATUS_DELETE_PENDING,
+                       "qpathinfo did not give correct error code");
        } else {
-               if (!NT_STATUS_IS_OK(status)) {
-                       printf("(%s) qpathinfo failed (%s)\n", where,
-                              nt_errstr(status));
-                       res = False;
-                       goto done;
-               }
+               torture_assert_ntstatus_ok(tctx, status, 
+                       talloc_asprintf(tctx, "qpathinfo failed (%s)", where));
        }
 
- done:
-       talloc_free(mem_ctx);
-       return res;
+       return true;
 }
 
-#define CHECK_STATUS(_cli, _expected) do { \
-       if (!NT_STATUS_EQUAL(_cli->tree->session->transport->error.e.nt_status, _expected)) { \
-               printf("(%d) Incorrect status %s - should be %s\n", \
-                      __LINE__, nt_errstr(_cli->tree->session->transport->error.e.nt_status), nt_errstr(_expected)); \
-               correct = False; \
-               goto fail; \
-       }} while (0)
+#define CHECK_STATUS(_cli, _expected) \
+       torture_assert_ntstatus_equal(tctx, _cli->tree->session->transport->error.e.nt_status, _expected, \
+                "Incorrect status")
 
-const char *fname = "\\delete.file";
-const char *fname_new = "\\delete.new";
-const char *dirname = "\\delete.dir";
+static const char *fname = "\\delete.file";
+static const char *fname_new = "\\delete.new";
+static const char *dname = "\\delete.dir";
 
 static void del_clean_area(struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
-       smbcli_deltree(cli1->tree, dirname);
+       smb_raw_exit(cli1->session);
+       smb_raw_exit(cli2->session);
+
+       smbcli_deltree(cli1->tree, dname);
        smbcli_setatr(cli1->tree, fname, 0, 0);
        smbcli_unlink(cli1->tree, fname);
        smbcli_setatr(cli1->tree, fname_new, 0, 0);
        smbcli_unlink(cli1->tree, fname_new);
-
-       smb_raw_exit(cli1->session);
-       smb_raw_exit(cli2->session);
 }
 
 /* Test 1 - this should delete the file on close. */
 
-static BOOL deltest1(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest1(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
 
@@ -175,31 +135,21 @@ static BOOL deltest1(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, 
                                      NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
        
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
        
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
-               printf("(%s) close failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), 
+               talloc_asprintf(tctx, "close failed (%s)", smbcli_errstr(cli1->tree)));
 
        fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
-       if (fnum1 != -1) {
-               printf("(%s) open of %s succeeded (should fail)\n", 
-                      __location__, fname);
-               return False;
-       }
+       torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail)", 
+                      fname));
 
-       printf("first delete on close test succeeded.\n");
-       return True;
+       return true;
 }
 
 /* Test 2 - this should delete the file on close. */
-static BOOL deltest2(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest2(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
 
@@ -210,23 +160,17 @@ static BOOL deltest2(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, 
                                      NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
        
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert(tctx, fnum1 != -1, 
+               talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
        
-       if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
-               printf("(%s) setting delete_on_close failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, true), 
+               talloc_asprintf(tctx, "setting delete_on_close failed (%s)", 
+                      smbcli_errstr(cli1->tree)));
        
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
-               printf("(%s) close failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), 
+               talloc_asprintf(tctx, "close failed (%s)", 
+                      smbcli_errstr(cli1->tree)));
        
        fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
        if (fnum1 != -1) {
@@ -235,17 +179,15 @@ static BOOL deltest2(struct smbcli_state *cli1, struct smbcli_state *cli2)
                if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
                        printf("(%s) close failed (%s)\n", 
                               __location__, smbcli_errstr(cli1->tree));
-                       return False;
+                       return false;
                }
                smbcli_unlink(cli1->tree, fname);
-       } else {
-               printf("second delete on close test succeeded.\n");
        }
-       return True;
+       return true;
 }
 
 /* Test 3 - ... */
-static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest3(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
        int fnum2 = -1;
@@ -258,11 +200,8 @@ static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, 
                                      NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
 
-       if (fnum1 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                       fname, smbcli_errstr(cli1->tree)));
 
        /* This should fail with a sharing violation - open for delete is only compatible
           with SHARE_DELETE. */
@@ -273,11 +212,9 @@ static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, 
                                      NTCREATEX_DISP_OPEN, 0, 0);
 
-       if (fnum2 != -1) {
-               printf("(%s) open  - 2 of %s succeeded - should have failed.\n", 
-                      __location__, fname);
-               return False;
-       }
+       torture_assert(tctx, fnum2 == -1, 
+               talloc_asprintf(tctx, "open  - 2 of %s succeeded - should have failed.", 
+                      fname));
 
        /* This should succeed. */
 
@@ -287,29 +224,21 @@ static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, 
                                      NTCREATEX_DISP_OPEN, 0, 0);
 
-       if (fnum2 == -1) {
-               printf("(%s) open  - 2 of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open  - 2 of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
-       if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
-               printf("(%s) setting delete_on_close failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert_ntstatus_ok(tctx, 
+                                                          smbcli_nt_delete_on_close(cli1->tree, fnum1, true),
+                                                          talloc_asprintf(tctx, "setting delete_on_close failed (%s)", 
+                                                  smbcli_errstr(cli1->tree)));
        
-       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_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1),
+               talloc_asprintf(tctx, "close 1 failed (%s)", 
+                      smbcli_errstr(cli1->tree)));
        
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) {
-               printf("(%s) close 2 failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum2),
+               talloc_asprintf(tctx, "close 2 failed (%s)", 
+                      smbcli_errstr(cli1->tree)));
        
        /* This should fail - file should no longer be there. */
 
@@ -322,19 +251,17 @@ static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2)
                               __location__, smbcli_errstr(cli1->tree));
                }
                smbcli_unlink(cli1->tree, fname);
-               return False;
-       } else {
-               printf("third delete on close test succeeded.\n");
+               return false;
        }
-       return True;
+       return true;
 }
 
 /* Test 4 ... */
-static BOOL deltest4(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest4(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
        int fnum2 = -1;
-       BOOL correct = True;
+       bool correct = true;
 
        del_clean_area(cli1, cli2);
 
@@ -346,11 +273,8 @@ static BOOL deltest4(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, 
                                      NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
                                                                
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
        /* This should succeed. */
        fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, 
@@ -360,84 +284,62 @@ static BOOL deltest4(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_WRITE |
                                      NTCREATEX_SHARE_ACCESS_DELETE, 
                                      NTCREATEX_DISP_OPEN, 0, 0);
-       if (fnum2 == -1) {
-               printf("(%s) open  - 2 of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               return False;
-       }
-       
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) {
-               printf("(%s) close - 1 failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open  - 2 of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
        
-       if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
-               printf("(%s) setting delete_on_close failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert_ntstatus_ok(tctx, 
+                                       smbcli_close(cli1->tree, fnum2),
+                                       talloc_asprintf(tctx, "close - 1 failed (%s)", 
+                                       smbcli_errstr(cli1->tree)));
        
+       torture_assert_ntstatus_ok(tctx, 
+                               smbcli_nt_delete_on_close(cli1->tree, fnum1, true), 
+                               talloc_asprintf(tctx, "setting delete_on_close failed (%s)", 
+                       smbcli_errstr(cli1->tree)));
+
        /* This should fail - no more opens once delete on close set. */
        fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, 
                                      SEC_RIGHTS_FILE_READ,
                                      FILE_ATTRIBUTE_NORMAL, 
                                      NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE,
                                      NTCREATEX_DISP_OPEN, 0, 0);
-       if (fnum2 != -1) {
-               printf("(%s) open  - 3 of %s succeeded ! Should have failed.\n",
-                      __location__, fname );
-               return False;
-       }
+       torture_assert(tctx, fnum2 == -1, 
+                talloc_asprintf(tctx, "open  - 3 of %s succeeded ! Should have failed.",
+                      fname ));
+
        CHECK_STATUS(cli1, NT_STATUS_DELETE_PENDING);
 
-       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_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), 
+                talloc_asprintf(tctx, "close - 2 failed (%s)", 
+                      smbcli_errstr(cli1->tree)));
        
-       printf("fourth delete on close test succeeded.\n");
-
-  fail:
-
        return correct;
 }
 
 /* Test 5 ... */
-static BOOL deltest5(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest5(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
 
        del_clean_area(cli1, cli2);
 
        fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               return False;
-       }
-
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
+       
        /* This should fail - only allowed on NT opens with DELETE access. */
 
-       if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
-               printf("(%s) setting delete_on_close on OpenX file succeeded - should fail !\n",
-                      __location__);
-               return False;
-       }
+       torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, true)),
+                "setting delete_on_close on OpenX file succeeded - should fail !");
 
-       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_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1),
+               talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree)));
 
-       printf("fifth delete on close test succeeded.\n");
-       return True;
+       return true;
 }
 
 /* Test 6 ... */
-static BOOL deltest6(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest6(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
 
@@ -451,35 +353,28 @@ static BOOL deltest6(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                   NTCREATEX_SHARE_ACCESS_DELETE,
                                   NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
        
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
        
        /* This should fail - only allowed on NT opens with DELETE access. */
        
-       if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
-               printf("(%s) setting delete_on_close on file with no delete access succeeded - should fail !\n",
-                      __location__);
-               return False;
-       }
+       torture_assert(tctx, 
+               !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, true)),
+               "setting delete_on_close on file with no delete access succeeded - should fail !");
 
-       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_ntstatus_ok(tctx, 
+                                                          smbcli_close(cli1->tree, fnum1),
+               talloc_asprintf(tctx, "close - 2 failed (%s)", 
+                      smbcli_errstr(cli1->tree)));
 
-       printf("sixth delete on close test succeeded.\n");
-       return True;
+       return true;
 }
 
 /* Test 7 ... */
-static BOOL deltest7(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest7(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
-       BOOL correct = True;
+       bool correct = true;
 
        del_clean_area(cli1, cli2);
 
@@ -490,68 +385,42 @@ static BOOL deltest7(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      FILE_ATTRIBUTE_NORMAL, 0, 
                                      NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
                                                                
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
-       if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
-               printf("(%s) setting delete_on_close on file failed !\n",
-                      __location__);
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, true),
+                       "setting delete_on_close on file failed !");
 
-       correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__);
        
-       if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, False))) {
-               printf("(%s) unsetting delete_on_close on file failed !\n",
-                      __location__);
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, 
+                                       smbcli_nt_delete_on_close(cli1->tree, fnum1, false), 
+                                       "unsetting delete_on_close on file failed !");
 
-       correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
        
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
-               printf("(%s) close - 2 failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), 
+               talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree)));
        
        /* This next open should succeed - we reset the flag. */
        
        fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
-               printf("(%s) close - 2 failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
-
-       printf("seventh delete on close test succeeded.\n");
-
-  fail:
+       torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), 
+                                                      talloc_asprintf(tctx, "close - 2 failed (%s)", 
+                                                  smbcli_errstr(cli1->tree)));
 
        return correct;
 }
 
 /* Test 8 ... */
-static BOOL deltest8(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest8(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
        int fnum2 = -1;
-       BOOL correct = True;
+       bool correct = true;
 
        del_clean_area(cli1, cli2);
 
@@ -563,12 +432,9 @@ static BOOL deltest8(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE,
                                      NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
        
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1,
+               talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
        fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, 
                                      SEC_FILE_READ_DATA|
@@ -578,57 +444,36 @@ static BOOL deltest8(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE,
                                      NTCREATEX_DISP_OPEN, 0, 0);
        
-       if (fnum2 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
-       if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
-               printf("(%s) setting delete_on_close on file failed !\n",
-                      __location__);
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, 
+                                       smbcli_nt_delete_on_close(cli1->tree, fnum1, true),
+               "setting delete_on_close on file failed !");
 
-       correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__);
-       correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__);
+       correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__);
 
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
-               printf("(%s) close - 1 failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1),
+               talloc_asprintf(tctx, "close - 1 failed (%s)", 
+                      smbcli_errstr(cli1->tree)));
 
-       correct &= check_delete_on_close(cli1, -1, fname, True, __location__);
-       correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__);
+       correct &= check_delete_on_close(tctx, cli1, -1, fname, true, __location__);
+       correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__);
        
-       if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
-               printf("(%s) close - 2 failed (%s)\n", 
-                      __location__, smbcli_errstr(cli2->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, smbcli_close(cli2->tree, fnum2),
+               talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli2->tree)));
 
        /* This should fail.. */
        fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
-       if (fnum1 != -1) {
-               printf("(%s) open of %s succeeded should have been deleted on close !\n",
-                      __location__, fname);
-               correct = False;
-       } else {
-               printf("eighth delete on close test succeeded.\n");
-       }
-
-  fail:
+       torture_assert(tctx, fnum1 == -1,
+               talloc_asprintf(tctx, "open of %s succeeded should have been deleted on close !\n", fname));
 
        return correct;
 }
 
 /* Test 9 ... */
-static BOOL deltest9(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest9(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
 
@@ -642,21 +487,17 @@ static BOOL deltest9(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_OVERWRITE_IF, 
                                      NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
        
-       if (fnum1 != -1) {
-               printf("(%s) open of %s succeeded should have failed!\n", 
-                      __location__, fname);
-               return False;
-       }
+       torture_assert(tctx, fnum1 == -1, 
+                                  talloc_asprintf(tctx, "open of %s succeeded should have failed!", 
+                      fname));
 
-       printf("ninth delete on close test succeeded.\n");
-       return True;
+       return true;
 }
 
 /* Test 10 ... */
-static BOOL deltest10(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest10(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
-       BOOL correct = True;
 
        del_clean_area(cli1, cli2);
 
@@ -668,39 +509,25 @@ static BOOL deltest10(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_NONE, 
                                      NTCREATEX_DISP_OVERWRITE_IF, 
                                      NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1, 
+               talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
        /* This should delete the file. */
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
-               printf("(%s) close failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1),
+               talloc_asprintf(tctx, "close failed (%s)", 
+                      smbcli_errstr(cli1->tree)));
 
        /* This should fail.. */
        fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
-       if (fnum1 != -1) {
-               printf("(%s) open of %s succeeded should have been deleted on close !\n",
-                      __location__, fname);
-               correct = False;
-               goto fail;
-       } else {
-               printf("tenth delete on close test succeeded.\n");
-       }
-
-  fail:
-
-       return correct;
+       torture_assert(tctx, fnum1 == -1, 
+                               talloc_asprintf(tctx, "open of %s succeeded should have been deleted on close !",
+                      fname));
+       return true;
 }
 
 /* Test 11 ... */
-static BOOL deltest11(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest11(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
        NTSTATUS status;
@@ -715,32 +542,23 @@ static BOOL deltest11(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_NONE, 
                                      NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
        
-        if (fnum1 == -1) {
-                printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               return False;
-        }
-
-       status = smbcli_nt_delete_on_close(cli1->tree, fnum1, True);
-
-       if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) {
-               printf("(%s) setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
-               printf("(%s) close failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       status = smbcli_nt_delete_on_close(cli1->tree, fnum1, true);
+
+       torture_assert_ntstatus_equal(tctx, status, NT_STATUS_CANNOT_DELETE, 
+               talloc_asprintf(tctx, "setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)", smbcli_errstr(cli1->tree)));
 
-        printf("eleventh delete on close test succeeded.\n");
-       return True;
+       torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1),
+               talloc_asprintf(tctx, "close failed (%s)", 
+                      smbcli_errstr(cli1->tree)));
+
+       return true;
 }
 
 /* Test 12 ... */
-static BOOL deltest12(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest12(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
        NTSTATUS status;
@@ -757,32 +575,26 @@ static BOOL deltest12(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_OVERWRITE_IF, 
                                      NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
        
-       if (fnum1 != -1) {
-               printf("(%s) open of %s succeeded. Should fail with "
-                      "NT_STATUS_CANNOT_DELETE.\n", __location__, fname);
-               smbcli_close(cli1->tree, fnum1);
-               return False;
-       } else {
-               status = smbcli_nt_error(cli1->tree);
-               if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) {
-                       printf("(%s) setting delete_on_close on open should "
+       torture_assert(tctx, fnum1 == -1, 
+                talloc_asprintf(tctx, "open of %s succeeded. Should fail with "
+                      "NT_STATUS_CANNOT_DELETE.\n", fname));
+
+       status = smbcli_nt_error(cli1->tree);
+       torture_assert_ntstatus_equal(tctx, status, NT_STATUS_CANNOT_DELETE, 
+                        talloc_asprintf(tctx, "setting delete_on_close on open should "
                               "fail with NT_STATUS_CANNOT_DELETE. Got %s "
-                              "instead)\n", 
-                              __location__, smbcli_errstr(cli1->tree));
-                       return False;
-               }
-       }
+                              "instead)", 
+                              smbcli_errstr(cli1->tree)));
        
-        printf("twelvth delete on close test succeeded.\n");
-       return True;
+       return true;
 }
 
 /* Test 13 ... */
-static BOOL deltest13(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest13(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
        int fnum2 = -1;
-       BOOL correct = True;
+       bool correct = true;
 
        del_clean_area(cli1, cli2);
 
@@ -800,12 +612,9 @@ static BOOL deltest13(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_OVERWRITE_IF,
                                      0, 0);
        
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1, 
+               talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
        fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, 
                                      SEC_FILE_READ_DATA|
@@ -817,76 +626,54 @@ static BOOL deltest13(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_DELETE,
                                      NTCREATEX_DISP_OPEN, 0, 0);
        
-       if (fnum2 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli2->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, 
+                               "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli2->tree)));
 
-       if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1,
-                                                      True))) {
-               printf("(%s) setting delete_on_close on file failed !\n",
-                      __location__);
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, 
+                                               smbcli_nt_delete_on_close(cli1->tree, fnum1,
+                                                      true), 
+                "setting delete_on_close on file failed !");
 
-       correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__);
-       correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__);
+       correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__);
 
-       if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli2->tree, fnum2,
-                                                      False))) {
-               printf("(%s) setting delete_on_close on file failed !\n",
-                      __location__);
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli2->tree, fnum2,
+                                                      false), 
+                "setting delete_on_close on file failed !");
 
-       correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__);
-       correct &= check_delete_on_close(cli2, fnum2, fname, False, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
+       correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
        
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
-               printf("(%s) close - 1 failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), 
+               talloc_asprintf(tctx, "close - 1 failed (%s)", 
+                      smbcli_errstr(cli1->tree)));
 
-       if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) {
-               printf("(%s) close - 2 failed (%s)\n", 
-                      __location__, smbcli_errstr(cli2->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, smbcli_close(cli2->tree, fnum2),
+                       talloc_asprintf(tctx, "close - 2 failed (%s)", 
+                      smbcli_errstr(cli2->tree)));
 
        fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
 
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed!\n", 
-                      __location__, fname);
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed!", 
+                      fname));
 
-       printf("thirteenth delete on close test succeeded.\n");
-
-  fail:
+       smbcli_close(cli1->tree, fnum1);
 
        return correct;
 }
 
 /* Test 14 ... */
-static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest14(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int dnum1 = -1;
-       BOOL correct = True;
+       bool correct = true;
 
        del_clean_area(cli1, cli2);
 
        /* Test 14 -- directory */
 
-       dnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0,
+       dnum1 = smbcli_nt_create_full(cli1->tree, dname, 0,
                                      SEC_FILE_READ_DATA|
                                      SEC_FILE_WRITE_DATA|
                                      SEC_STD_DELETE,
@@ -895,26 +682,18 @@ static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_WRITE|
                                      NTCREATEX_SHARE_ACCESS_DELETE,
                                      NTCREATEX_DISP_CREATE, 0, 0);
-       if (dnum1 == -1) {
-               printf("(%s) open of %s failed: %s!\n", 
-                      __location__, dirname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx, "open of %s failed: %s!", 
+                      dname, smbcli_errstr(cli1->tree)));
 
-       correct &= check_delete_on_close(cli1, dnum1, dirname, False, __location__);
-       if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, dnum1, True))) {
-               printf("(%s) setting delete_on_close on file failed !\n",
-                      __location__);
-               correct = False;
-               goto fail;
-       }
-       correct &= check_delete_on_close(cli1, dnum1, dirname, True, __location__);
+       correct &= check_delete_on_close(tctx, cli1, dnum1, dname, false, __location__);
+       torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, true),
+                       "setting delete_on_close on file failed !");
+       correct &= check_delete_on_close(tctx, cli1, dnum1, dname, true, __location__);
        smbcli_close(cli1->tree, dnum1);
 
        /* Now it should be gone... */
 
-       dnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0,
+       dnum1 = smbcli_nt_create_full(cli1->tree, dname, 0,
                                      SEC_FILE_READ_DATA|
                                      SEC_FILE_WRITE_DATA|
                                      SEC_STD_DELETE,
@@ -923,26 +702,17 @@ static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_WRITE|
                                      NTCREATEX_SHARE_ACCESS_DELETE,
                                      NTCREATEX_DISP_OPEN, 0, 0);
-       if (dnum1 != -1) {
-               printf("(%s) setting delete_on_close on file succeeded !\n",
-                      __location__);
-               correct = False;
-               goto fail;
-       }
-
-       printf("fourteenth delete on close test succeeded.\n");
-
-  fail:
+       torture_assert(tctx, dnum1 == -1, "setting delete_on_close on file succeeded !");
 
        return correct;
 }
 
 /* Test 15 ... */
-static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest15(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
+       bool correct = true;
        int fnum2 = -1;
-       BOOL correct = True;
        NTSTATUS status;
 
        del_clean_area(cli1, cli2);
@@ -962,21 +732,12 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_OVERWRITE_IF,
                                      0, 0);
 
-       if (fnum1 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1, 
+               talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree)));
 
        status = smbcli_rename(cli2->tree, fname, fname_new);
 
-       if (!NT_STATUS_IS_OK(status)) {
-               printf("(%s) renaming failed: %s !\n",
-                      __location__, nt_errstr(status));
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, status, "renaming failed!");
 
        fnum2 = smbcli_nt_create_full(cli2->tree, fname_new, 0, 
                                      SEC_GENERIC_ALL,
@@ -987,28 +748,21 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_OVERWRITE_IF,
                                      0, 0);
 
-       if (fnum2 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, fname_new, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum2 != -1, 
+               talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      fname_new, smbcli_errstr(cli1->tree)));
 
-       status = smbcli_nt_delete_on_close(cli2->tree, fnum2, True);
+       status = smbcli_nt_delete_on_close(cli2->tree, fnum2, true);
 
-       if (!NT_STATUS_IS_OK(status)) {
-               printf("(%s) setting delete_on_close on file failed !\n",
-                      __location__);
-               correct = False;
-               goto fail;
-       }
+       torture_assert_ntstatus_ok(tctx, status, 
+               "setting delete_on_close on file failed !");
 
        smbcli_close(cli2->tree, fnum2);
 
        /* The file should be around under the new name, there's a second
         * handle open */
 
-       correct &= check_delete_on_close(cli1, fnum1, fname_new, True, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname_new, true, __location__);
 
        fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, 
                                      SEC_GENERIC_ALL,
@@ -1019,14 +773,10 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_OVERWRITE_IF,
                                      0, 0);
 
-       if (fnum2 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
-       correct &= check_delete_on_close(cli2, fnum2, fname, False, __location__);
+       correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
 
        smbcli_close(cli2->tree, fnum2);
        smbcli_close(cli1->tree, fnum1);
@@ -1040,12 +790,8 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_OPEN,
                                      0, 0);
 
-       if (fnum1 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
        smbcli_close(cli1->tree, fnum1);
 
@@ -1058,27 +804,19 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_OPEN,
                                      0, 0);
 
-       if (fnum1 != -1) {
-               printf("(%s) smbcli_open succeeded, should have "
-                      "failed\n", __location__);
-               smbcli_close(cli1->tree, fnum1);
-               correct = False;
-               goto fail;
-       }
-
-       printf("fifteenth delete on close test succeeded.\n");
-
-  fail:
+       torture_assert(tctx, fnum1 == -1, 
+               "smbcli_open succeeded, should have "
+                      "failed");
 
        return correct;
 }
 
 /* Test 16 ... */
-static BOOL deltest16(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest16(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
        int fnum2 = -1;
-       BOOL correct = True;
+       bool correct = true;
 
        del_clean_area(cli1, cli2);
 
@@ -1100,19 +838,14 @@ static BOOL deltest16(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_CREATE,
                                      NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
        
-       if (fnum1 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert (tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree)));
 
        /* The delete on close bit is *not* reported as being set. */
-       correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
 
        /* The delete on close bit is *not* reported as being set. */
-       correct &= check_delete_on_close(cli1, -1, fname, False, __location__);
-       correct &= check_delete_on_close(cli2, -1, fname, False, __location__);
+       correct &= check_delete_on_close(tctx, cli1, -1, fname, false, __location__);
+       correct &= check_delete_on_close(tctx, cli2, -1, fname, false, __location__);
 
        /* Now try opening again for read-only. */
        fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, 
@@ -1124,49 +857,36 @@ static BOOL deltest16(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_OPEN,
                                      0, 0);
        
-
        /* Should work. */
-       if (fnum2 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                     fname, smbcli_errstr(cli1->tree)));
 
-       correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__);
-       correct &= check_delete_on_close(cli1, -1, fname, False, __location__);
-       correct &= check_delete_on_close(cli2, fnum2, fname, False, __location__);
-       correct &= check_delete_on_close(cli2, -1, fname, False, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
+       correct &= check_delete_on_close(tctx, cli1, -1, fname, false, __location__);
+       correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
+       correct &= check_delete_on_close(tctx, cli2, -1, fname, false, __location__);
 
        smbcli_close(cli1->tree, fnum1);
 
-       correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__);
-       correct &= check_delete_on_close(cli2, -1, fname, True, __location__);
+       correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__);
+       correct &= check_delete_on_close(tctx, cli2, -1, fname, true, __location__);
 
        smbcli_close(cli2->tree, fnum2);
 
        /* And the file should be deleted ! */
        fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
-       if (fnum1 != -1) {
-               printf("(%s) open of %s succeeded (should fail)\n", 
-                      __location__, fname);
-               correct = False;
-               goto fail;
-       }
-       
-       printf("sixteenth delete on close test succeeded.\n");
-
-  fail:
+       torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail)", 
+                      fname));
 
        return correct;
 }
 
 /* Test 17 ... */
-static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest17(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
        int fnum2 = -1;
-       BOOL correct = True;
+       bool correct = true;
 
        del_clean_area(cli1, cli2);
 
@@ -1187,12 +907,8 @@ static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_DELETE,
                                      NTCREATEX_DISP_CREATE, 
                                      0, 0);
-       if (fnum1 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
        /* And close - just to create the file. */
        smbcli_close(cli1->tree, fnum1);
@@ -1207,15 +923,11 @@ static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_OPEN,
                                      NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
        
-       if (fnum1 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
        /* The delete on close bit is *not* reported as being set. */
-       correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
 
        /* Now try opening again for read-only. */
        fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, 
@@ -1229,45 +941,36 @@ static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      0, 0);
        
        /* Should work. */
-       if (fnum2 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
 
        /* still not reported as being set on either */
-       correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__);
-       correct &= check_delete_on_close(cli1, fnum2, fname, False, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum2, fname, false, __location__);
 
        smbcli_close(cli1->tree, fnum1);
 
-       correct &= check_delete_on_close(cli1, fnum2, fname, False, __location__);
+       /* After the first close, the files has the delete on close bit set. */
+       correct &= check_delete_on_close(tctx, cli1, fnum2, fname, true, __location__);
 
        smbcli_close(cli1->tree, fnum2);
 
-       /* See if the file is deleted - shouldn't be.... */
+       /* Make sure the file has been deleted */
        fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed (should succeed) - %s\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
-       
-       printf("seventeenth delete on close test succeeded.\n");
+       torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s failed (should succeed) - %s",
+                      fname, smbcli_errstr(cli1->tree)));
 
-  fail:
+       CHECK_STATUS(cli1, NT_STATUS_OBJECT_NAME_NOT_FOUND);
 
        return correct;
 }
 
 /* Test 18 ... */
-static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest18(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
        int fnum2 = -1;
-       BOOL correct = True;
+       bool correct = true;
 
        del_clean_area(cli1, cli2);
 
@@ -1277,10 +980,10 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2)
        smbcli_close(cli1->tree, fnum1);
        smbcli_close(cli1->tree, fnum2);
 
-       smbcli_deltree(cli1->tree, dirname);
+       smbcli_deltree(cli1->tree, dname);
 
        /* Firstly create with all access, but delete on close. */
-       fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, 
+       fnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, 
                                      SEC_FILE_READ_DATA|
                                      SEC_FILE_WRITE_DATA|
                                      SEC_STD_DELETE,
@@ -1291,18 +994,19 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_CREATE,
                                      NTCREATEX_OPTIONS_DIRECTORY|NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
        
-       if (fnum1 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, dirname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      dname, smbcli_errstr(cli1->tree)));
 
-       /* The delete on close bit is *not* reported as being set. */
-       correct &= check_delete_on_close(cli1, fnum1, dirname, False, __location__);
+       /*
+        * The delete on close bit is *not* reported as being set.
+        * Win2k3/win2k8 should pass this check, but WinXPsp2 reports delete on
+        * close as being set.  This causes the subsequent create to fail with
+        * NT_STATUS_DELETE_PENDING.
+        */
+       correct &= check_delete_on_close(tctx, cli1, fnum1, dname, false, __location__);
 
        /* Now try opening again for read-only. */
-       fnum2 = smbcli_nt_create_full(cli1->tree, dirname, 0, 
+       fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, 
                                      SEC_RIGHTS_FILE_READ,
                                      FILE_ATTRIBUTE_DIRECTORY,
                                      NTCREATEX_SHARE_ACCESS_READ|
@@ -1313,24 +1017,20 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2)
        
 
        /* Should work. */
-       if (fnum2 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, dirname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      dname, smbcli_errstr(cli1->tree)));
 
-       correct &= check_delete_on_close(cli1, fnum1, dirname, False, __location__);
-       correct &= check_delete_on_close(cli1, fnum2, dirname, False, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum1, dname, false, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum2, dname, false, __location__);
 
        smbcli_close(cli1->tree, fnum1);
 
-       correct &= check_delete_on_close(cli1, fnum2, dirname, True, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum2, dname, true, __location__);
 
        smbcli_close(cli1->tree, fnum2);
 
        /* And the directory should be deleted ! */
-       fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, 
+       fnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, 
                                      SEC_RIGHTS_FILE_READ,
                                      FILE_ATTRIBUTE_DIRECTORY,
                                      NTCREATEX_SHARE_ACCESS_READ|
@@ -1338,35 +1038,27 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_DELETE,
                                      NTCREATEX_DISP_OPEN,
                                      NTCREATEX_OPTIONS_DIRECTORY, 0);
-       if (fnum1 != -1) {
-               printf("(%s) open of %s succeeded (should fail)\n", 
-                      __location__, dirname);
-               correct = False;
-               goto fail;
-       }
-       
-       printf("eighteenth delete on close test succeeded.\n");
-
-  fail:
+       torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail)", 
+                      dname));
 
        return correct;
 }
 
 /* Test 19 ... */
-static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest19(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
        int fnum2 = -1;
-       BOOL correct = True;
+       bool correct = true;
 
        del_clean_area(cli1, cli2);
 
        /* Test 19. */
 
-       smbcli_deltree(cli1->tree, dirname);
+       smbcli_deltree(cli1->tree, dname);
 
        /* Firstly open and create with all access */
-       fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, 
+       fnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, 
                                      SEC_FILE_READ_DATA|
                                      SEC_FILE_WRITE_DATA|
                                      SEC_STD_DELETE,
@@ -1377,18 +1069,14 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_CREATE,
                                      NTCREATEX_OPTIONS_DIRECTORY, 0);
        
-       if (fnum1 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, dirname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      dname, smbcli_errstr(cli1->tree)));
 
        /* And close - just to create the directory. */
        smbcli_close(cli1->tree, fnum1);
        
        /* Next open with all access, but add delete on close. */
-       fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, 
+       fnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, 
                                      SEC_FILE_READ_DATA|
                                      SEC_FILE_WRITE_DATA|
                                      SEC_STD_DELETE,
@@ -1399,18 +1087,19 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_DISP_OPEN,
                                      NTCREATEX_OPTIONS_DIRECTORY|NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
        
-       if (fnum1 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum1 != -1, 
+               talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree)));
 
-       /* The delete on close bit is *not* reported as being set. */
-       correct &= check_delete_on_close(cli1, fnum1, dirname, False, __location__);
+       /*
+        * The delete on close bit is *not* reported as being set.
+        * Win2k3/win2k8 should pass this check, but WinXPsp2 reports delete on
+        * close as being set.  This causes the subsequent create to fail with
+        * NT_STATUS_DELETE_PENDING.
+        */
+       correct &= check_delete_on_close(tctx, cli1, fnum1, dname, false, __location__);
 
        /* Now try opening again for read-only. */
-       fnum2 = smbcli_nt_create_full(cli1->tree, dirname, 0, 
+       fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, 
                                      SEC_RIGHTS_FILE_READ,
                                      FILE_ATTRIBUTE_DIRECTORY,
                                      NTCREATEX_SHARE_ACCESS_READ|
@@ -1420,21 +1109,17 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_OPTIONS_DIRECTORY, 0);
        
        /* Should work. */
-       if (fnum2 == -1) {
-               printf("(%s) open - 1 of %s failed (%s)\n", 
-                      __location__, dirname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      dname, smbcli_errstr(cli1->tree)));
 
        smbcli_close(cli1->tree, fnum1);
 
-       correct &= check_delete_on_close(cli1, fnum2, dirname, True, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum2, dname, true, __location__);
 
        smbcli_close(cli1->tree, fnum2);
 
        /* See if the file is deleted - for a directory this seems to be true ! */
-       fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0, 
+       fnum1 = smbcli_nt_create_full(cli1->tree, dname, 0, 
                                      SEC_RIGHTS_FILE_READ,
                                      FILE_ATTRIBUTE_DIRECTORY,
                                      NTCREATEX_SHARE_ACCESS_READ|
@@ -1445,35 +1130,31 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2)
 
        CHECK_STATUS(cli1, NT_STATUS_OBJECT_NAME_NOT_FOUND);
 
-       if (fnum1 != -1) {
-               printf("(%s) open of %s succeeded (should fail)\n", 
-                      __location__, dirname);
-               correct = False;
-               goto fail;
-       }
-
-       printf("nineteenth delete on close test succeeded.\n");
-
-  fail:
+       torture_assert(tctx, fnum1 == -1, 
+               talloc_asprintf(tctx, "open of %s succeeded (should fail)", dname));
 
        return correct;
 }
 
 /* Test 20 ... */
-static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
 {
        int fnum1 = -1;
        int dnum1 = -1;
-       BOOL correct = True;
+       bool correct = true;
        NTSTATUS status;
 
        del_clean_area(cli1, cli2);
 
        /* Test 20 -- non-empty directory hardest to get right... */
 
-       smbcli_deltree(cli1->tree, dirname);
+       if (torture_setting_bool(tctx, "samba3", false)) {
+               return true;
+       }
+
+       smbcli_deltree(cli1->tree, dname);
 
-       dnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0,
+       dnum1 = smbcli_nt_create_full(cli1->tree, dname, 0,
                                      SEC_FILE_READ_DATA|
                                      SEC_FILE_WRITE_DATA|
                                      SEC_STD_DELETE,
@@ -1483,87 +1164,234 @@ static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2)
                                      NTCREATEX_SHARE_ACCESS_DELETE,
                                      NTCREATEX_DISP_CREATE, 
                                      NTCREATEX_OPTIONS_DIRECTORY, 0);
-       if (dnum1 == -1) {
-               printf("(%s) open of %s failed: %s!\n", 
-                      __location__, dirname, smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
-       }
+       torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx, "open of %s failed: %s!", 
+                      dname, smbcli_errstr(cli1->tree)));
 
-       correct &= check_delete_on_close(cli1, dnum1, dirname, False, __location__);
-       status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True);
+       correct &= check_delete_on_close(tctx, cli1, dnum1, dname, false, __location__);
+       status = smbcli_nt_delete_on_close(cli1->tree, dnum1, true);
 
        {
                char *fullname;
-               asprintf(&fullname, "\\%s%s", dirname, fname);
+               asprintf(&fullname, "\\%s%s", dname, fname);
                fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR,
                                    DENY_NONE);
-               if (fnum1 != -1) {
-                       printf("(%s) smbcli_open succeeded, should have "
-                              "failed with NT_STATUS_DELETE_PENDING\n",
-                              __location__);
-                       correct = False;
-                       goto fail;
-               }
+               torture_assert(tctx, fnum1 == -1, 
+                               "smbcli_open succeeded, should have "
+                              "failed with NT_STATUS_DELETE_PENDING"
+                              );
 
-               if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree),
-                                    NT_STATUS_DELETE_PENDING)) {
-                       printf("(%s) smbcli_open returned %s, expected "
-                              "NT_STATUS_DELETE_PENDING\n",
-                              __location__, smbcli_errstr(cli1->tree));
-                       correct = False;
-                       goto fail;
-               }
+               torture_assert_ntstatus_equal(tctx, 
+                                        smbcli_nt_error(cli1->tree),
+                                    NT_STATUS_DELETE_PENDING, 
+                                       "smbcli_open failed");
        }
 
-       status = smbcli_nt_delete_on_close(cli1->tree, dnum1, False);
-       if (!NT_STATUS_IS_OK(status)) {
-               printf("(%s) setting delete_on_close on file failed !\n",
-                      __location__);
-               correct = False;
-               goto fail;
-       }
+       status = smbcli_nt_delete_on_close(cli1->tree, dnum1, false);
+       torture_assert_ntstatus_ok(tctx, status, 
+                                       "setting delete_on_close on file failed !");
                
        {
                char *fullname;
-               asprintf(&fullname, "\\%s%s", dirname, fname);
+               asprintf(&fullname, "\\%s%s", dname, fname);
                fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR,
                                    DENY_NONE);
-               if (fnum1 == -1) {
-                       printf("(%s) smbcli_open failed: %s\n",
-                              __location__, smbcli_errstr(cli1->tree));
-                       correct = False;
-                       goto fail;
-               }
+               torture_assert(tctx, fnum1 != -1, 
+                               talloc_asprintf(tctx, "smbcli_open failed: %s\n",
+                              smbcli_errstr(cli1->tree)));
                smbcli_close(cli1->tree, fnum1);
        }
 
-       status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True);
+       status = smbcli_nt_delete_on_close(cli1->tree, dnum1, true);
+
+       torture_assert_ntstatus_equal(tctx, status, NT_STATUS_DIRECTORY_NOT_EMPTY,
+                "setting delete_on_close failed");
+       smbcli_close(cli1->tree, dnum1);
+
+       return correct;
+}
+
+/* Test 20a ... */
+static bool deltest20a(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+       int fnum1 = -1;
+       int fnum2 = -1;
+       bool correct = true;
+
+       del_clean_area(cli1, cli2);
+
+       /* Test 20a. */
+
+       /* Ensure the file doesn't already exist. */
+       smbcli_close(cli1->tree, fnum1);
+       smbcli_close(cli1->tree, fnum2);
+       smbcli_setatr(cli1->tree, fname, 0, 0);
+       smbcli_unlink(cli1->tree, fname);
+
+       /* Firstly open and create with all access */
+       fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, 
+                                     SEC_RIGHTS_FILE_ALL,
+                                     FILE_ATTRIBUTE_NORMAL,
+                                     NTCREATEX_SHARE_ACCESS_READ|
+                                     NTCREATEX_SHARE_ACCESS_WRITE|
+                                     NTCREATEX_SHARE_ACCESS_DELETE,
+                                     NTCREATEX_DISP_CREATE, 
+                                     0, 0);
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
+
+       /* Next open with all access, but add delete on close. */
+       fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, 
+                                     SEC_RIGHTS_FILE_ALL,
+                                     FILE_ATTRIBUTE_NORMAL,
+                                     NTCREATEX_SHARE_ACCESS_READ|
+                                     NTCREATEX_SHARE_ACCESS_WRITE|
+                                     NTCREATEX_SHARE_ACCESS_DELETE,
+                                     NTCREATEX_DISP_OPEN,
+                                     NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
+       
+       torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 2 of %s failed (%s)", 
+                      fname, smbcli_errstr(cli2->tree)));
+
+       /* The delete on close bit is *not* reported as being set. */
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
+       correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
+
+       smbcli_close(cli1->tree, fnum1);
+
+       correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
+
+       smbcli_close(cli2->tree, fnum2);
+
+       /* See if the file is deleted - should be.... */
+       fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+       torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail) - %s", 
+                      fname, smbcli_errstr(cli1->tree)));
+
+       return correct;
+}
+
+/* Test 20b ... */
+/* This is the delete semantics that the cifsfs client depends on when
+ * trying to delete an open file on a Windows server. It
+ * opens a file with initial delete on close set, renames it then closes
+ * all open handles. The file goes away on Windows.
+ */
+
+static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+       int fnum1 = -1;
+       int fnum2 = -1;
+       bool correct = true;
+
+       del_clean_area(cli1, cli2);
+
+       /* Test 20b. */
+
+       /* Ensure the file doesn't already exist. */
+       smbcli_close(cli1->tree, fnum1);
+       smbcli_close(cli1->tree, fnum2);
+       smbcli_setatr(cli1->tree, fname, 0, 0);
+       smbcli_unlink(cli1->tree, fname);
+       smbcli_setatr(cli1->tree, fname_new, 0, 0);
+       smbcli_unlink(cli1->tree, fname_new);
+
+       /* Firstly open and create with all access */
+       fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, 
+                                     SEC_RIGHTS_FILE_ALL,
+                                     FILE_ATTRIBUTE_NORMAL,
+                                     NTCREATEX_SHARE_ACCESS_READ|
+                                     NTCREATEX_SHARE_ACCESS_WRITE|
+                                     NTCREATEX_SHARE_ACCESS_DELETE,
+                                     NTCREATEX_DISP_CREATE, 
+                                     0, 0);
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
+
+       /* And close - just to create the file. */
+       smbcli_close(cli1->tree, fnum1);
+       
+       /* Firstly open and create with all access */
+       fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, 
+                                     SEC_RIGHTS_FILE_ALL,
+                                     FILE_ATTRIBUTE_NORMAL,
+                                     NTCREATEX_SHARE_ACCESS_READ|
+                                     NTCREATEX_SHARE_ACCESS_WRITE|
+                                     NTCREATEX_SHARE_ACCESS_DELETE,
+                                     NTCREATEX_DISP_OPEN, 
+                                     0, 0);
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
+
+       /* Next open with all access, but add delete on close. */
+       fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, 
+                                     SEC_RIGHTS_FILE_ALL,
+                                     FILE_ATTRIBUTE_NORMAL,
+                                     NTCREATEX_SHARE_ACCESS_READ|
+                                     NTCREATEX_SHARE_ACCESS_WRITE|
+                                     NTCREATEX_SHARE_ACCESS_DELETE,
+                                     NTCREATEX_DISP_OPEN,
+                                     NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
+       
+       torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 2 of %s failed (%s)", 
+                      fname, smbcli_errstr(cli2->tree)));
 
-       if (!NT_STATUS_EQUAL(status, NT_STATUS_DIRECTORY_NOT_EMPTY)) {
-               printf("(%s) setting delete_on_close returned %s, expected "
-                      "NT_STATUS_DIRECTORY_NOT_EMPTY\n", __location__,
-                      smbcli_errstr(cli1->tree));
-               correct = False;
-               goto fail;
+       /* The delete on close bit is *not* reported as being set. */
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__);
+       correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
+
+       smbcli_close(cli1->tree, fnum1);
+
+       correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__);
+
+       /* Rename the file by handle. */
+
+       {
+               union smb_setfileinfo sfinfo;
+               NTSTATUS status;
+
+               memset(&sfinfo, '\0', sizeof(sfinfo));
+               sfinfo.generic.level = RAW_SFILEINFO_RENAME_INFORMATION;
+               sfinfo.generic.in.file.fnum = fnum2;
+               sfinfo.rename_information.in.root_fid  = 0;
+               /* Don't start the filename with '\\', we get NT_STATUS_NOT_SUPPORTED if so. */
+               sfinfo.rename_information.in.new_name  = fname_new + 1;
+               sfinfo.rename_information.in.overwrite = 1;
+
+               status = smb_raw_setfileinfo(cli2->tree, &sfinfo);
+
+               torture_assert_ntstatus_equal(tctx,status,NT_STATUS_OK,talloc_asprintf(tctx, "rename of %s to %s failed (%s)",
+                       fname, fname_new, smbcli_errstr(cli2->tree)));
        }
 
-       smbcli_close(cli1->tree, dnum1);
+       correct &= check_delete_on_close(tctx, cli2, fnum2, fname_new, false, __location__);
 
-       printf("twentieth delete on close test succeeded.\n");
+       smbcli_close(cli2->tree, fnum2);
 
-  fail:
+       /* See if the file is deleted - should be.... */
+       fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+       torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail) - %s", 
+                      fname, smbcli_errstr(cli1->tree)));
+       fnum1 = smbcli_open(cli1->tree, fname_new, O_RDWR, DENY_NONE);
+       torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail) - %s", 
+                      fname_new, smbcli_errstr(cli1->tree)));
 
        return correct;
 }
 
+
 /* Test 21 ... */
-static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2)
+static bool deltest21(struct torture_context *tctx)
 {
        int fnum1 = -1;
-       struct smbcli_state *cli1 = *ppcli1;
-       struct smbcli_state *cli2 = *ppcli2;
-       BOOL correct = True;
+       struct smbcli_state *cli1;
+       struct smbcli_state *cli2;
+       bool correct = true;
+
+       if (!torture_open_connection(&cli1, tctx, 0))
+               return false;
+
+       if (!torture_open_connection(&cli2, tctx, 1))
+               return false;
 
        del_clean_area(cli1, cli2);
 
@@ -1574,31 +1402,29 @@ static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2
                                      FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, 
                                      NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
        
-       if (fnum1 == -1) {
-               printf("(%s) open of %s failed (%s)\n", 
-                      __location__, fname, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", 
+                      fname, smbcli_errstr(cli1->tree)));
        
-       if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) {
-               printf("(%s) setting delete_on_close failed (%s)\n", 
-                      __location__, smbcli_errstr(cli1->tree));
-               return False;
-       }
+       torture_assert_ntstatus_ok(tctx, 
+                               smbcli_nt_delete_on_close(cli1->tree, fnum1, true),
+                               talloc_asprintf(tctx, "setting delete_on_close failed (%s)", 
+                      smbcli_errstr(cli1->tree)));
        
        /* Ensure delete on close is set. */
-       correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__);
+       correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__);
 
        /* Now yank the rug from under cli1. */
-       smbcli_transport_dead(cli1->transport);
+       smbcli_transport_dead(cli1->transport, NT_STATUS_LOCAL_DISCONNECT);
 
        fnum1 = -1;
 
-       if (!torture_open_connection(ppcli1)) {
-               return False;
+       if (!torture_open_connection(&cli1, tctx, 0)) {
+               return false;
        }
 
-       cli1 = *ppcli1;
+       /* On slow build farm machines it might happen that they are not fast
+        * enogh to delete the file for this test */
+       msleep(200);
 
        /* File should not be there. */
        fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, 
@@ -1612,71 +1438,121 @@ static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2
        
        CHECK_STATUS(cli1, NT_STATUS_OBJECT_NAME_NOT_FOUND);
 
-       printf("twenty-first delete on close test succeeded.\n");
-
-  fail:
-
        return correct;
 }
-       
+
+/* Test 22 ... */
+
 /*
-  Test delete on close semantics.
+ * Test whether a second *directory* handle inhibits delete if the first has
+ * del-on-close set and is closed
  */
-BOOL torture_test_delete(void)
+static bool deltest22(struct torture_context *tctx)
 {
-       struct smbcli_state *cli1 = NULL;
-       struct smbcli_state *cli2 = NULL;
-       BOOL correct = True;
-       
-       printf("starting delete test\n");
-       
-       if (!torture_open_connection(&cli1)) {
-               return False;
-       }
+       int dnum1 = -1;
+       int dnum2 = -1;
+       struct smbcli_state *cli1;
+       bool correct = true;
 
-       if (!torture_open_connection(&cli2)) {
-               printf("(%s) failed to open second connection.\n",
-                      __location__);
-               correct = False;
-               goto fail;
-       }
+       if (!torture_open_connection(&cli1, tctx, 0))
+               return false;
 
-       correct &= deltest1(cli1, cli2);
-       correct &= deltest2(cli1, cli2);
-       correct &= deltest3(cli1, cli2);
-       correct &= deltest4(cli1, cli2);
-       correct &= deltest5(cli1, cli2);
-       correct &= deltest6(cli1, cli2);
-       correct &= deltest7(cli1, cli2);
-       correct &= deltest8(cli1, cli2);
-       correct &= deltest9(cli1, cli2);
-       correct &= deltest10(cli1, cli2);
-       correct &= deltest11(cli1, cli2);
-       correct &= deltest12(cli1, cli2);
-       correct &= deltest13(cli1, cli2);
-       correct &= deltest14(cli1, cli2);
-       correct &= deltest15(cli1, cli2);
-       correct &= deltest16(cli1, cli2);
-       correct &= deltest17(cli1, cli2);
-       correct &= deltest18(cli1, cli2);
-       correct &= deltest19(cli1, cli2);
-       correct &= deltest20(cli1, cli2);
-       correct &= deltest21(&cli1, &cli2);
-
-       if (!correct) {
-               printf("Failed delete test\n");
-       } else {
-               printf("delete test ok !\n");
-       }
+       smbcli_deltree(cli1->tree, dname);
 
-  fail:
-       del_clean_area(cli1, cli2);
+       torture_assert_ntstatus_ok(
+               tctx, smbcli_mkdir(cli1->tree, dname),
+               talloc_asprintf(tctx, "smbcli_mdir failed: (%s)\n",
+                               smbcli_errstr(cli1->tree)));
+
+       dnum1 = smbcli_nt_create_full(cli1->tree, dname, 0,
+                                     SEC_FILE_READ_DATA|
+                                     SEC_FILE_WRITE_DATA|
+                                     SEC_STD_DELETE,
+                                     FILE_ATTRIBUTE_DIRECTORY, 
+                                     NTCREATEX_SHARE_ACCESS_READ|
+                                     NTCREATEX_SHARE_ACCESS_WRITE|
+                                     NTCREATEX_SHARE_ACCESS_DELETE,
+                                     NTCREATEX_DISP_OPEN, 
+                                     NTCREATEX_OPTIONS_DIRECTORY, 0);
+
+       torture_assert(tctx, dnum1 != -1,
+                      talloc_asprintf(tctx, "open of %s failed: %s!", 
+                                      dname, smbcli_errstr(cli1->tree)));
+
+       dnum2 = smbcli_nt_create_full(cli1->tree, dname, 0,
+                                     SEC_FILE_READ_DATA|
+                                     SEC_FILE_WRITE_DATA,
+                                     FILE_ATTRIBUTE_DIRECTORY, 
+                                     NTCREATEX_SHARE_ACCESS_READ|
+                                     NTCREATEX_SHARE_ACCESS_WRITE|
+                                     NTCREATEX_SHARE_ACCESS_DELETE,
+                                     NTCREATEX_DISP_OPEN, 
+                                     NTCREATEX_OPTIONS_DIRECTORY, 0);
+
+       torture_assert(tctx, dnum2 != -1,
+                      talloc_asprintf(tctx, "open of %s failed: %s!", 
+                                      dname, smbcli_errstr(cli1->tree)));
+
+       torture_assert_ntstatus_ok(
+               tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, true), 
+               talloc_asprintf(tctx, "setting delete_on_close failed (%s)", 
+                               smbcli_errstr(cli1->tree)));
+
+       smbcli_close(cli1->tree, dnum1);
+
+       dnum1 = smbcli_nt_create_full(cli1->tree, dname, 0,
+                                     SEC_FILE_READ_DATA|
+                                     SEC_FILE_WRITE_DATA|
+                                     SEC_STD_DELETE,
+                                     FILE_ATTRIBUTE_DIRECTORY, 
+                                     NTCREATEX_SHARE_ACCESS_READ|
+                                     NTCREATEX_SHARE_ACCESS_WRITE|
+                                     NTCREATEX_SHARE_ACCESS_DELETE,
+                                     NTCREATEX_DISP_OPEN, 
+                                     NTCREATEX_OPTIONS_DIRECTORY, 0);
+
+       torture_assert(tctx, dnum1 == -1,
+                      talloc_asprintf(tctx, "open of %s succeeded!\n",
+                                      dname));
+
+       CHECK_STATUS(cli1, NT_STATUS_DELETE_PENDING);
 
-       if (!torture_close_connection(cli1)) {
-               correct = False;
-       }
-       if (!torture_close_connection(cli2)) {
-               correct = False;
-       }
        return correct;
 }
+
+/*
+  Test delete on close semantics.
+ */
+struct torture_suite *torture_test_delete(void)
+{
+       struct torture_suite *suite = torture_suite_create(
+               talloc_autofree_context(),
+               "DELETE");
+
+       torture_suite_add_2smb_test(suite, "deltest1", deltest1);
+       torture_suite_add_2smb_test(suite, "deltest2", deltest2);
+       torture_suite_add_2smb_test(suite, "deltest3", deltest3);
+       torture_suite_add_2smb_test(suite, "deltest4", deltest4);
+       torture_suite_add_2smb_test(suite, "deltest5", deltest5);
+       torture_suite_add_2smb_test(suite, "deltest6", deltest6);
+       torture_suite_add_2smb_test(suite, "deltest7", deltest7);
+       torture_suite_add_2smb_test(suite, "deltest8", deltest8);
+       torture_suite_add_2smb_test(suite, "deltest9", deltest9);
+       torture_suite_add_2smb_test(suite, "deltest10", deltest10);
+       torture_suite_add_2smb_test(suite, "deltest11", deltest11);
+       torture_suite_add_2smb_test(suite, "deltest12", deltest12);
+       torture_suite_add_2smb_test(suite, "deltest13", deltest13);
+       torture_suite_add_2smb_test(suite, "deltest14", deltest14);
+       torture_suite_add_2smb_test(suite, "deltest15", deltest15);
+       torture_suite_add_2smb_test(suite, "deltest16", deltest16);
+       torture_suite_add_2smb_test(suite, "deltest17", deltest17);
+       torture_suite_add_2smb_test(suite, "deltest18", deltest18);
+       torture_suite_add_2smb_test(suite, "deltest19", deltest19);
+       torture_suite_add_2smb_test(suite, "deltest20", deltest20);
+       torture_suite_add_2smb_test(suite, "deltest20a", deltest20a);
+       torture_suite_add_2smb_test(suite, "deltest20b", deltest20b);
+       torture_suite_add_simple_test(suite, "deltest21", deltest21);
+       torture_suite_add_simple_test(suite, "deltest22", deltest22);
+
+       return suite;
+}