r23792: convert Samba4 to GPLv3
[kai/samba.git] / source4 / torture / raw / unlink.c
index 0caf55ebf79ae17f3831707b0cec2046886f893c..3e4580d2d32dce841e6413d97eedea9b9596da91 100644 (file)
@@ -5,7 +5,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,
@@ -14,8 +14,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"
@@ -128,7 +127,21 @@ static BOOL test_unlink(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.unlink.in.pattern = BASEDIR "\\z*";
        io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY;
        status = smb_raw_unlink(cli->tree, &io);
-       CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE);
+
+       if (lp_parm_bool(-1, "torture", "samba3", False)) {
+               /*
+                * In Samba3 we gave up upon getting the error codes in
+                * wildcard unlink correct. Trying gentest showed that this is
+                * irregular beyond our capabilities. So for
+                * FILE_ATTRIBUTE_DIRECTORY we always return NAME_INVALID.
+                * Tried by jra and vl. If others feel like solving this
+                * puzzle, please tell us :-)
+                */
+               CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
+       }
+       else {
+               CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE);
+       }
 
        io.unlink.in.pattern = BASEDIR "\\*";
        io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY;
@@ -143,19 +156,34 @@ static BOOL test_unlink(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.unlink.in.pattern = BASEDIR "\\t*";
        io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY;
        status = smb_raw_unlink(cli->tree, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       if (lp_parm_bool(-1, "torture", "samba3", False)) {
+               CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
+       }
+       else {
+               CHECK_STATUS(status, NT_STATUS_OK);
+       }
 
        smbcli_close(cli->tree, smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE));
 
        io.unlink.in.pattern = BASEDIR "\\*.dat";
        io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY;
        status = smb_raw_unlink(cli->tree, &io);
-       CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE);
+       if (lp_parm_bool(-1, "torture", "samba3", False)) {
+               CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
+       }
+       else {
+               CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE);
+       }
 
        io.unlink.in.pattern = BASEDIR "\\*.tx?";
        io.unlink.in.attrib = 0;
        status = smb_raw_unlink(cli->tree, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       if (lp_parm_bool(-1, "torture", "samba3", False)) {
+               CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE);
+       }
+       else {
+               CHECK_STATUS(status, NT_STATUS_OK);
+       }
 
        status = smb_raw_unlink(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE);
@@ -252,34 +280,41 @@ static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
 
 
-       printf("Testing with non-empty directory delete_on_close\n");
-       status = create_directory_handle(cli->tree, dname, &fnum);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       
-       fnum2 = create_complex_file(cli, mem_ctx, inside);
+       if (!lp_parm_bool(-1, "torture", "samba3", False)) {
 
-       sfinfo.disposition_info.in.file.fnum = fnum;
-       sfinfo.disposition_info.in.delete_on_close = 1;
-       status = smb_raw_setfileinfo(cli->tree, &sfinfo);
-       CHECK_STATUS(status, NT_STATUS_DIRECTORY_NOT_EMPTY);
+               /*
+                * Known deficiency, also skipped in base-delete.
+                */
 
-       sfinfo.disposition_info.in.file.fnum = fnum2;
-       status = smb_raw_setfileinfo(cli->tree, &sfinfo);
-       CHECK_STATUS(status, NT_STATUS_OK);
+               printf("Testing with non-empty directory delete_on_close\n");
+               status = create_directory_handle(cli->tree, dname, &fnum);
+               CHECK_STATUS(status, NT_STATUS_OK);
 
-       sfinfo.disposition_info.in.file.fnum = fnum;
-       status = smb_raw_setfileinfo(cli->tree, &sfinfo);
-       CHECK_STATUS(status, NT_STATUS_DIRECTORY_NOT_EMPTY);
+               fnum2 = create_complex_file(cli, mem_ctx, inside);
 
-       smbcli_close(cli->tree, fnum2);
+               sfinfo.disposition_info.in.file.fnum = fnum;
+               sfinfo.disposition_info.in.delete_on_close = 1;
+               status = smb_raw_setfileinfo(cli->tree, &sfinfo);
+               CHECK_STATUS(status, NT_STATUS_DIRECTORY_NOT_EMPTY);
 
-       status = smb_raw_setfileinfo(cli->tree, &sfinfo);
-       CHECK_STATUS(status, NT_STATUS_OK);
+               sfinfo.disposition_info.in.file.fnum = fnum2;
+               status = smb_raw_setfileinfo(cli->tree, &sfinfo);
+               CHECK_STATUS(status, NT_STATUS_OK);
 
-       smbcli_close(cli->tree, fnum);
+               sfinfo.disposition_info.in.file.fnum = fnum;
+               status = smb_raw_setfileinfo(cli->tree, &sfinfo);
+               CHECK_STATUS(status, NT_STATUS_DIRECTORY_NOT_EMPTY);
 
-       status = smb_raw_rmdir(cli->tree, &dio);
-       CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+               smbcli_close(cli->tree, fnum2);
+
+               status = smb_raw_setfileinfo(cli->tree, &sfinfo);
+               CHECK_STATUS(status, NT_STATUS_OK);
+
+               smbcli_close(cli->tree, fnum);
+
+               status = smb_raw_rmdir(cli->tree, &dio);
+               CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+       }
 
        printf("Testing open dir with delete_on_close\n");
        status = create_directory_handle(cli->tree, dname, &fnum);
@@ -407,7 +442,7 @@ BOOL torture_raw_unlink(struct torture_context *torture)
        BOOL ret = True;
        TALLOC_CTX *mem_ctx;
 
-       if (!torture_open_connection(&cli)) {
+       if (!torture_open_connection(&cli, 0)) {
                return False;
        }