summaryrefslogtreecommitdiffstats
path: root/source4/torture
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2012-01-27 13:06:09 +0100
committerMichael Adam <obnox@samba.org>2012-02-03 11:10:30 +0100
commit1d8fbff7ffbea58ae8ed55fd887f4be022f1cc97 (patch)
tree57930c469131367cf8dc64f57f9df81bb2330b8e /source4/torture
parentf9e85d09b35345d3161a1fed5040206f7ba1f3d0 (diff)
downloadsamba-1d8fbff7ffbea58ae8ed55fd887f4be022f1cc97.tar.gz
samba-1d8fbff7ffbea58ae8ed55fd887f4be022f1cc97.tar.xz
samba-1d8fbff7ffbea58ae8ed55fd887f4be022f1cc97.zip
s4:torture: add smb2.durable_open test reopen2
durable open, disconnect, new seession, durable reopen
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/smb2/durable_open.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/source4/torture/smb2/durable_open.c b/source4/torture/smb2/durable_open.c
index 34fac768ea..f4219bc0cd 100644
--- a/source4/torture/smb2/durable_open.c
+++ b/source4/torture/smb2/durable_open.c
@@ -375,6 +375,76 @@ done:
return ret;
}
+/**
+ * basic test for doing a durable open
+ * tcp disconnect, reconnect, do a durable reopen (succeeds)
+ */
+bool test_durable_open_reopen2(struct torture_context *tctx,
+ struct smb2_tree *tree)
+{
+ NTSTATUS status;
+ TALLOC_CTX *mem_ctx = talloc_new(tctx);
+ char fname[256];
+ struct smb2_handle _h;
+ struct smb2_handle *h = NULL;
+ struct smb2_create io1, io2;
+ bool ret = true;
+
+ /* Choose a random name in case the state is left a little funky. */
+ snprintf(fname, 256, "durable_open_reopen2_%s.dat",
+ generate_random_str(tctx, 8));
+
+ smb2_util_unlink(tree, fname);
+
+ smb2_oplock_create_share(&io1, fname,
+ smb2_util_share_access(""),
+ smb2_util_oplock_level("b"));
+ io1.in.durable_open = true;
+
+ status = smb2_create(tree, mem_ctx, &io1);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ _h = io1.out.file.handle;
+ h = &_h;
+ CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+ CHECK_VAL(io1.out.durable_open, true);
+ CHECK_VAL(io1.out.oplock_level, smb2_util_oplock_level("b"));
+
+ /* disconnect, reconnect and then do durable reopen */
+ talloc_free(tree);
+ tree = NULL;
+
+ if (!torture_smb2_connection(tctx, &tree)) {
+ torture_warning(tctx, "couldn't reconnect, bailing\n");
+ ret = false;
+ goto done;
+ }
+
+ ZERO_STRUCT(io2);
+ io2.in.fname = fname;
+ io2.in.durable_handle = h;
+
+ status = smb2_create(tree, mem_ctx, &io2);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_CREATED(&io2, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
+ CHECK_VAL(io2.out.durable_open, true);
+ CHECK_VAL(io2.out.oplock_level, smb2_util_oplock_level("b"));
+ _h = io2.out.file.handle;
+ h = &_h;
+
+done:
+ if (h != NULL) {
+ smb2_util_close(tree, *h);
+ }
+
+ smb2_util_unlink(tree, fname);
+
+ talloc_free(tree);
+
+ talloc_free(mem_ctx);
+
+ return ret;
+}
+
/*
basic testing of SMB2 durable opens
regarding the position information on the handle
@@ -847,6 +917,7 @@ struct torture_suite *torture_smb2_durable_open_init(void)
torture_suite_add_1smb2_test(suite, "open1", test_durable_open_open1);
torture_suite_add_1smb2_test(suite, "open2", test_durable_open_open2);
torture_suite_add_1smb2_test(suite, "reopen1", test_durable_open_reopen1);
+ torture_suite_add_1smb2_test(suite, "reopen2", test_durable_open_reopen2);
torture_suite_add_2smb2_test(suite, "file-position",
test_durable_open_file_position);
torture_suite_add_2smb2_test(suite, "oplock", test_durable_open_oplock);