r23792: convert Samba4 to GPLv3
[jra/samba/.git] / source4 / torture / raw / write.c
index a00a5dd9c91eb691e7aa276310ac943b1cfc2e8d..9b043bfe2ca4084fd9996f4927f55d11339f08e4 100644 (file)
@@ -6,7 +6,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,
@@ -15,8 +15,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"
@@ -182,7 +181,17 @@ static BOOL test_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        printf("Setting file as sparse\n");
        status = torture_set_sparse(cli->tree, fnum);
        CHECK_STATUS(status, NT_STATUS_OK);
+
+       if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
+               printf("skipping large file tests - CAP_LARGE_FILES not set\n");
+               goto done;
+       }
        
+       if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
+               printf("skipping large file tests - CAP_LARGE_FILES not set\n");
+               goto done;
+       }
+
        printf("Trying 2^32 offset\n");
        setup_buffer(buf, seed, maxsize);
        io.write.in.file.fnum = fnum;
@@ -193,7 +202,7 @@ static BOOL test_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        CHECK_STATUS(status, NT_STATUS_OK);
        CHECK_VALUE(io.write.out.nwritten, 4000);
        CHECK_ALL_INFO(io.write.in.count + (uint64_t)io.write.in.offset, size);
-
+       
        memset(buf, 0, maxsize);
        if (smbcli_read(cli->tree, fnum, buf, io.write.in.offset, 4000) != 4000) {
                printf("read failed at %s\n", __location__);
@@ -224,6 +233,12 @@ static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        const char *fname = BASEDIR "\\test.txt";
        uint_t seed = time(NULL);
        union smb_fileinfo finfo;
+       int max_bits=63;
+
+       if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
+               max_bits=33;
+               printf("dangerous not set - limiting range of test to 2^%d\n", max_bits);
+       }
 
        buf = talloc_zero_size(mem_ctx, maxsize);
 
@@ -331,6 +346,11 @@ static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        status = torture_set_sparse(cli->tree, fnum);
        CHECK_STATUS(status, NT_STATUS_OK);
        
+       if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
+               printf("skipping large file tests - CAP_LARGE_FILES not set\n");
+               goto done;
+       }
+
        printf("Trying 2^32 offset\n");
        setup_buffer(buf, seed, maxsize);
        io.writex.in.file.fnum = fnum;
@@ -350,7 +370,7 @@ static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        }
        CHECK_BUFFER(buf, seed, 4000);
 
-       for (i=33;i<64;i++) {
+       for (i=33;i<max_bits;i++) {
                printf("Trying 2^%d offset\n", i);
                setup_buffer(buf, seed+1, maxsize);
                io.writex.in.file.fnum = fnum;
@@ -494,6 +514,11 @@ static BOOL test_writeunlock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        status = torture_set_sparse(cli->tree, fnum);
        CHECK_STATUS(status, NT_STATUS_OK);
        
+       if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
+               printf("skipping large file tests - CAP_LARGE_FILES not set\n");
+               goto done;
+       }
+
        printf("Trying 2^32 offset\n");
        setup_buffer(buf, seed, maxsize);
        io.writeunlock.in.file.fnum = fnum;
@@ -644,6 +669,11 @@ static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        status = torture_set_sparse(cli->tree, fnum);
        CHECK_STATUS(status, NT_STATUS_OK);
        
+       if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
+               printf("skipping large file tests - CAP_LARGE_FILES not set\n");
+               goto done;
+       }
+
        printf("Trying 2^32 offset\n");
        setup_buffer(buf, seed, maxsize);
        io.writeclose.in.file.fnum = fnum;
@@ -676,13 +706,13 @@ done:
 /* 
    basic testing of write calls
 */
-BOOL torture_raw_write(void)
+BOOL torture_raw_write(struct torture_context *torture)
 {
        struct smbcli_state *cli;
        BOOL ret = True;
        TALLOC_CTX *mem_ctx;
 
-       if (!torture_open_connection(&cli)) {
+       if (!torture_open_connection(&cli, 0)) {
                return False;
        }