r3182: separate out the BASE-RENAME test into torture/basic/rename.c
authorAndrew Tridgell <tridge@samba.org>
Mon, 25 Oct 2004 02:59:48 +0000 (02:59 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:04:37 +0000 (13:04 -0500)
(This used to be commit c5e72b05d73ff0d57a98b6065bab573e2a226747)

source4/torture/basic/rename.c [new file with mode: 0644]
source4/torture/config.mk
source4/torture/torture.c

diff --git a/source4/torture/basic/rename.c b/source4/torture/basic/rename.c
new file mode 100644 (file)
index 0000000..96fef82
--- /dev/null
@@ -0,0 +1,128 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   rename testing
+
+   Copyright (C) Andrew Tridgell 2003
+   
+   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
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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.
+*/
+
+#include "includes.h"
+
+/*
+  Test rename on files open with share delete and no share delete.
+ */
+BOOL torture_test_rename(int dummy)
+{
+       struct smbcli_state *cli1;
+       const char *fname = "\\test.txt";
+       const char *fname1 = "\\test1.txt";
+       BOOL correct = True;
+       int fnum1;
+
+       printf("starting rename test\n");
+       
+       if (!torture_open_connection(&cli1)) {
+               return False;
+       }
+       
+       smbcli_unlink(cli1->tree, fname);
+       smbcli_unlink(cli1->tree, fname1);
+       fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
+                                  NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
+
+       if (fnum1 == -1) {
+               printf("(%s) First open failed - %s\n", 
+                      __location__, smbcli_errstr(cli1->tree));
+               return False;
+       }
+
+       if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) {
+               printf("First rename failed (this is correct) - %s\n", smbcli_errstr(cli1->tree));
+       } else {
+               printf("(%s) First rename succeeded - this should have failed !\n",
+                      __location__);
+               correct = False;
+       }
+
+       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+               printf("(%s) close - 1 failed (%s)\n", __location__, smbcli_errstr(cli1->tree));
+               return False;
+       }
+
+       smbcli_unlink(cli1->tree, fname);
+       smbcli_unlink(cli1->tree, fname1);
+       fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, 
+                                     GENERIC_RIGHTS_FILE_READ, 
+                                     FILE_ATTRIBUTE_NORMAL,
+                                     NTCREATEX_SHARE_ACCESS_DELETE|NTCREATEX_SHARE_ACCESS_READ, 
+                                     NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
+
+       if (fnum1 == -1) {
+               printf("(%s) Second open failed - %s\n", __location__, smbcli_errstr(cli1->tree));
+               return False;
+       }
+
+       if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) {
+               printf("(%s) Second rename failed - this should have succeeded - %s\n", 
+                      __location__, smbcli_errstr(cli1->tree));
+               correct = False;
+       } else {
+               printf("Second rename succeeded\n");
+       }
+
+       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+               printf("(%s) close - 2 failed (%s)\n", 
+                      __location__, smbcli_errstr(cli1->tree));
+               return False;
+       }
+
+       smbcli_unlink(cli1->tree, fname);
+       smbcli_unlink(cli1->tree, fname1);
+
+       fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_READ_CONTROL_ACCESS, FILE_ATTRIBUTE_NORMAL,
+                                  NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
+
+       if (fnum1 == -1) {
+               printf("(%s) Third open failed - %s\n", __location__, smbcli_errstr(cli1->tree));
+               return False;
+       }
+
+
+       if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) {
+               printf("(%s) Third rename failed - this should have succeeded - %s\n", 
+                      __location__, smbcli_errstr(cli1->tree));
+               correct = False;
+       } else {
+               printf("Third rename succeeded\n");
+       }
+
+       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
+               printf("(%s) close - 3 failed (%s)\n", 
+                      __location__, smbcli_errstr(cli1->tree));
+               return False;
+       }
+
+       smbcli_unlink(cli1->tree, fname);
+       smbcli_unlink(cli1->tree, fname1);
+
+       if (!torture_close_connection(cli1)) {
+               correct = False;
+       }
+       
+       return correct;
+}
+
index 714f3b7ffb5fd28150cc41ad0761b9315f847c87..b9f28ed98f324c9ff489fd677f24dc8fa389e19e 100644 (file)
@@ -12,6 +12,7 @@ ADD_OBJ_FILES = \
                torture/basic/aliases.o \
                torture/basic/locking.o \
                torture/basic/secleak.o \
                torture/basic/aliases.o \
                torture/basic/locking.o \
                torture/basic/secleak.o \
+               torture/basic/rename.o \
                torture/basic/delete.o 
 REQUIRED_SUBSYSTEMS = \
                LIBSMB
                torture/basic/delete.o 
 REQUIRED_SUBSYSTEMS = \
                LIBSMB
index e05dba7ee763ec47475cee9724f30de9959537ab..3bc0b6303b6f5bfe82710dbbc2efb07cfffcf0d8 100644 (file)
@@ -1437,101 +1437,6 @@ static BOOL run_xcopy(int dummy)
        return correct;
 }
 
        return correct;
 }
 
-/*
-  Test rename on files open with share delete and no share delete.
- */
-static BOOL run_rename(int dummy)
-{
-       struct smbcli_state *cli1;
-       const char *fname = "\\test.txt";
-       const char *fname1 = "\\test1.txt";
-       BOOL correct = True;
-       int fnum1;
-
-       printf("starting rename test\n");
-       
-       if (!torture_open_connection(&cli1)) {
-               return False;
-       }
-       
-       smbcli_unlink(cli1->tree, fname);
-       smbcli_unlink(cli1->tree, fname1);
-       fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
-                                  NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
-
-       if (fnum1 == -1) {
-               printf("First open failed - %s\n", smbcli_errstr(cli1->tree));
-               return False;
-       }
-
-       if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) {
-               printf("First rename failed (this is correct) - %s\n", smbcli_errstr(cli1->tree));
-       } else {
-               printf("First rename succeeded - this should have failed !\n");
-               correct = False;
-       }
-
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
-               printf("close - 1 failed (%s)\n", smbcli_errstr(cli1->tree));
-               return False;
-       }
-
-       smbcli_unlink(cli1->tree, fname);
-       smbcli_unlink(cli1->tree, fname1);
-       fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
-                                  NTCREATEX_SHARE_ACCESS_DELETE|NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
-
-       if (fnum1 == -1) {
-               printf("Second open failed - %s\n", smbcli_errstr(cli1->tree));
-               return False;
-       }
-
-       if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) {
-               printf("Second rename failed - this should have succeeded - %s\n", smbcli_errstr(cli1->tree));
-               correct = False;
-       } else {
-               printf("Second rename succeeded\n");
-       }
-
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
-               printf("close - 2 failed (%s)\n", smbcli_errstr(cli1->tree));
-               return False;
-       }
-
-       smbcli_unlink(cli1->tree, fname);
-       smbcli_unlink(cli1->tree, fname1);
-
-       fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_READ_CONTROL_ACCESS, FILE_ATTRIBUTE_NORMAL,
-                                  NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
-
-       if (fnum1 == -1) {
-               printf("Third open failed - %s\n", smbcli_errstr(cli1->tree));
-               return False;
-       }
-
-
-       if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) {
-               printf("Third rename failed - this should have succeeded - %s\n", smbcli_errstr(cli1->tree));
-               correct = False;
-       } else {
-               printf("Third rename succeeded\n");
-       }
-
-       if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) {
-               printf("close - 3 failed (%s)\n", smbcli_errstr(cli1->tree));
-               return False;
-       }
-
-       smbcli_unlink(cli1->tree, fname);
-       smbcli_unlink(cli1->tree, fname1);
-
-       if (!torture_close_connection(cli1)) {
-               correct = False;
-       }
-       
-       return correct;
-}
-
 
 /*
   see how many RPC pipes we can open at once
 
 /*
   see how many RPC pipes we can open at once
@@ -2896,7 +2801,7 @@ static struct {
        {"BASE-DENY3", run_deny3test, 0},
        {"BASE-DEFER_OPEN", run_deferopen, FLAG_MULTIPROC},
        {"BASE-XCOPY", run_xcopy, 0},
        {"BASE-DENY3", run_deny3test, 0},
        {"BASE-DEFER_OPEN", run_deferopen, FLAG_MULTIPROC},
        {"BASE-XCOPY", run_xcopy, 0},
-       {"BASE-RENAME", run_rename, 0},
+       {"BASE-RENAME", torture_test_rename, 0},
        {"BASE-DELETE", torture_test_delete, 0},
        {"BASE-PROPERTIES", run_properties, 0},
        {"BASE-MANGLE", torture_mangle, 0},
        {"BASE-DELETE", torture_test_delete, 0},
        {"BASE-PROPERTIES", run_properties, 0},
        {"BASE-MANGLE", torture_mangle, 0},