summaryrefslogtreecommitdiff
path: root/source4/torture/smb2/read.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-05-30 12:18:07 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-05-30 12:18:07 +0200
commit5107f093c270f7a0dfc359de088b475fffc4e279 (patch)
tree99f616c6e352f87fbd41e60ad7fae3adf67e72fa /source4/torture/smb2/read.c
parent46f22add9ae03b95f4b22235c297737475427f41 (diff)
parentbe1927cd80838a6807827cef4431c03160d52582 (diff)
downloadsamba-5107f093c270f7a0dfc359de088b475fffc4e279.tar.gz
samba-5107f093c270f7a0dfc359de088b475fffc4e279.tar.bz2
samba-5107f093c270f7a0dfc359de088b475fffc4e279.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-defs
Conflicts: source/samba4-skip (This used to be commit 7b0e0eb346c2f6a240b20fbcf14029539c6512b9)
Diffstat (limited to 'source4/torture/smb2/read.c')
-rw-r--r--source4/torture/smb2/read.c60
1 files changed, 58 insertions, 2 deletions
diff --git a/source4/torture/smb2/read.c b/source4/torture/smb2/read.c
index b3c13ad667..548bd1ce61 100644
--- a/source4/torture/smb2/read.c
+++ b/source4/torture/smb2/read.c
@@ -44,6 +44,9 @@
goto done; \
}} while (0)
+#define FNAME "smb2_readtest.dat"
+#define DNAME "smb2_readtest.dir"
+
static bool test_read_eof(struct torture_context *torture, struct smb2_tree *tree)
{
bool ret = true;
@@ -55,7 +58,7 @@ static bool test_read_eof(struct torture_context *torture, struct smb2_tree *tre
ZERO_STRUCT(buf);
- status = torture_smb2_testfile(tree, "lock1.txt", &h);
+ status = torture_smb2_testfile(tree, FNAME, &h);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
@@ -139,7 +142,7 @@ static bool test_read_position(struct torture_context *torture, struct smb2_tree
ZERO_STRUCT(buf);
- status = torture_smb2_testfile(tree, "lock1.txt", &h);
+ status = torture_smb2_testfile(tree, FNAME, &h);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
@@ -172,6 +175,58 @@ done:
return ret;
}
+static bool test_read_dir(struct torture_context *torture, struct smb2_tree *tree)
+{
+ bool ret = true;
+ NTSTATUS status;
+ struct smb2_handle h;
+ struct smb2_read rd;
+ TALLOC_CTX *tmp_ctx = talloc_new(tree);
+
+ status = torture_smb2_testdir(tree, DNAME, &h);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf(__location__ " Unable to create test directory '%s' - %s\n", DNAME, nt_errstr(status));
+ return false;
+ }
+
+ ZERO_STRUCT(rd);
+ rd.in.file.handle = h;
+ rd.in.length = 10;
+ rd.in.offset = 0;
+ rd.in.min_count = 1;
+
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_INVALID_DEVICE_REQUEST);
+
+ rd.in.min_count = 11;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_INVALID_DEVICE_REQUEST);
+
+ rd.in.length = 0;
+ rd.in.min_count = 2592;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ if (torture_setting_bool(torture, "windows", false)) {
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+ } else {
+ CHECK_STATUS(status, NT_STATUS_INVALID_DEVICE_REQUEST);
+ }
+
+ rd.in.length = 0;
+ rd.in.min_count = 0;
+ rd.in.channel = 0;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ if (torture_setting_bool(torture, "windows", false)) {
+ CHECK_STATUS(status, NT_STATUS_OK);
+ } else {
+ CHECK_STATUS(status, NT_STATUS_INVALID_DEVICE_REQUEST);
+ }
+
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
+
/*
basic testing of SMB2 read
*/
@@ -181,6 +236,7 @@ struct torture_suite *torture_smb2_read_init(void)
torture_suite_add_1smb2_test(suite, "EOF", test_read_eof);
torture_suite_add_1smb2_test(suite, "POSITION", test_read_position);
+ torture_suite_add_1smb2_test(suite, "DIR", test_read_dir);
suite->description = talloc_strdup(suite, "SMB2-READ tests");