TESTING smb2.read.eof...
authorStefan Metzmacher <metze@samba.org>
Thu, 29 Sep 2011 17:45:52 +0000 (19:45 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 16 Jan 2018 06:43:36 +0000 (07:43 +0100)
source4/torture/smb2/read.c

index 4bf3bb74be0a39ca2f05e6cf329975717f4d980c..df33c516953ee71023893e4e59d7749954d60cef 100644 (file)
@@ -22,6 +22,7 @@
 #include "includes.h"
 #include "libcli/smb2/smb2.h"
 #include "libcli/smb2/smb2_calls.h"
+#include "../libcli/smb/smbXcli_base.h"
 
 #include "torture/torture.h"
 #include "torture/smb2/proto.h"
@@ -43,12 +44,17 @@ static bool test_read_eof(struct torture_context *torture, struct smb2_tree *tre
        bool ret = true;
        NTSTATUS status;
        struct smb2_handle h;
-       uint8_t buf[64*1024];
+       uint8_t buf[2*1024*1024];
        struct smb2_read rd;
        TALLOC_CTX *tmp_ctx = talloc_new(tree);
-
+       uint32_t size;
        ZERO_STRUCT(buf);
 
+       smb2cli_conn_set_max_credits(tree->session->transport->conn, 30);
+
+       size = smb2cli_conn_max_write_size(tree->session->transport->conn);
+       size = MIN(ARRAY_SIZE(buf), size);
+
        smb2_util_unlink(tree, FNAME);
 
        status = torture_smb2_testfile(tree, FNAME, &h);
@@ -61,7 +67,7 @@ static bool test_read_eof(struct torture_context *torture, struct smb2_tree *tre
        status = smb2_read(tree, tree, &rd);
        CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
 
-       status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
+       status = smb2_util_write(tree, h, buf, 0, size);
        CHECK_STATUS(status, NT_STATUS_OK);
 
        ZERO_STRUCT(rd);
@@ -76,33 +82,33 @@ static bool test_read_eof(struct torture_context *torture, struct smb2_tree *tre
 
        rd.in.min_count = 0;
        rd.in.length = 10;
-       rd.in.offset = sizeof(buf);
+       rd.in.offset = size;
        status = smb2_read(tree, tmp_ctx, &rd);
        CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
 
        rd.in.min_count = 0;
        rd.in.length = 0;
-       rd.in.offset = sizeof(buf);
+       rd.in.offset = size;
        status = smb2_read(tree, tmp_ctx, &rd);
        CHECK_STATUS(status, NT_STATUS_OK);
        CHECK_VALUE(rd.out.data.length, 0);
 
        rd.in.min_count = 1;
        rd.in.length = 0;
-       rd.in.offset = sizeof(buf);
+       rd.in.offset = size;
        status = smb2_read(tree, tmp_ctx, &rd);
        CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
 
        rd.in.min_count = 0;
        rd.in.length = 2;
-       rd.in.offset = sizeof(buf) - 1;
+       rd.in.offset = size - 1;
        status = smb2_read(tree, tmp_ctx, &rd);
        CHECK_STATUS(status, NT_STATUS_OK);
        CHECK_VALUE(rd.out.data.length, 1);
 
        rd.in.min_count = 2;
        rd.in.length = 1;
-       rd.in.offset = sizeof(buf) - 1;
+       rd.in.offset = size - 1;
        status = smb2_read(tree, tmp_ctx, &rd);
        CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
 
@@ -124,6 +130,12 @@ static bool test_read_eof(struct torture_context *torture, struct smb2_tree *tre
        status = smb2_read(tree, tmp_ctx, &rd);
        CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
 
+       rd.in.min_count = 0;
+       rd.in.length = size;
+       rd.in.offset = 0;
+       status = smb2_read(tree, tmp_ctx, &rd);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
 done:
        talloc_free(tmp_ctx);
        return ret;