summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-11-14 05:10:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:46:17 -0500
commit695e37d8e75c95af24cb3f02cfb6d44d95067671 (patch)
tree4da0e87a6f6924772b4fa0b27b01ce11d24c78dc /source4/torture
parentc6395a30b057c87de8ce410d5ea5ebe2e017093d (diff)
downloadsamba-695e37d8e75c95af24cb3f02cfb6d44d95067671.tar.gz
samba-695e37d8e75c95af24cb3f02cfb6d44d95067671.tar.bz2
samba-695e37d8e75c95af24cb3f02cfb6d44d95067671.zip
r11716: added a read/write test
(This used to be commit 7c229e5b9fc8774207b647214b9d03d26a60aae3)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/smb2/connect.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/source4/torture/smb2/connect.c b/source4/torture/smb2/connect.c
index 54991e27ba..4907aadecb 100644
--- a/source4/torture/smb2/connect.c
+++ b/source4/torture/smb2/connect.c
@@ -64,6 +64,53 @@ static NTSTATUS torture_smb2_close(struct smb2_tree *tree, struct smb2_handle ha
/*
+ test writing
+*/
+static NTSTATUS torture_smb2_write(struct smb2_tree *tree, struct smb2_handle handle)
+{
+ struct smb2_write w;
+ struct smb2_read r;
+ NTSTATUS status;
+ DATA_BLOB data;
+
+ data = data_blob_talloc(tree, NULL, 700);
+ generate_random_buffer(data.data, data.length);
+
+ ZERO_STRUCT(w);
+ w.in.buffer_code = 0x31;
+ w.in.offset = 0;
+ w.in.handle = handle;
+ w.in.data = data;
+
+ status = smb2_write(tree, &w);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("write failed - %s\n", nt_errstr(status));
+ return status;
+ }
+
+ ZERO_STRUCT(r);
+ r.in.buffer_code = 0x31;
+ r.in.length = data.length;
+ r.in.offset = 0;
+ r.in.handle = handle;
+
+ status = smb2_read(tree, tree, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("read failed - %s\n", nt_errstr(status));
+ return status;
+ }
+
+ if (data.length != r.out.data.length ||
+ memcmp(data.data, r.out.data.data, data.length) != 0) {
+ printf("read data mismatch\n");
+ return NT_STATUS_NET_WRITE_FAULT;
+ }
+
+ return status;
+}
+
+
+/*
send a create
*/
static struct smb2_handle torture_smb2_create(struct smb2_tree *tree,
@@ -136,6 +183,7 @@ BOOL torture_smb2_connect(void)
h1 = torture_smb2_create(tree, "test9.dat");
h2 = torture_smb2_create(tree, "test9.dat");
+ torture_smb2_write(tree, h1);
torture_smb2_close(tree, h1);
torture_smb2_close(tree, h2);