summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-05-28 20:06:38 +1000
committerAndrew Tridgell <tridge@samba.org>2008-05-28 20:06:38 +1000
commitf7bf79043e664b83e62dae6ea187b5c019968d28 (patch)
treea1145f00cee24dabe60faa8c8951b719a0c22a15 /source4
parente814586bddd081d85a216533bf47a1ac9d8b025f (diff)
downloadsamba-f7bf79043e664b83e62dae6ea187b5c019968d28.tar.gz
samba-f7bf79043e664b83e62dae6ea187b5c019968d28.tar.bz2
samba-f7bf79043e664b83e62dae6ea187b5c019968d28.zip
added testing of some strange read semantics on windows
(This used to be commit 46a0b65742bc0e4277da53df9df823abd4a0d150)
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/smb2/read.c61
1 files changed, 59 insertions, 2 deletions
diff --git a/source4/torture/smb2/read.c b/source4/torture/smb2/read.c
index b3c13ad667..1f306028f6 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,59 @@ 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;
+ uint8_t buf[100];
+ 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 +237,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");