s4:torture: add a durable-open-disconnect test (suite)
authorMichael Adam <obnox@samba.org>
Tue, 12 Feb 2013 16:45:23 +0000 (17:45 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 18 Feb 2013 14:54:20 +0000 (15:54 +0100)
this opens a durable, disconnects it and exits

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
selftest/skip
source4/torture/smb2/durable_open.c
source4/torture/smb2/smb2.c

index 5c4930643e74a6d8fc3ddc78ccacad1f84a4ced9..6ea9b25f40477221f1c184d3b50053e336878252 100644 (file)
@@ -41,6 +41,7 @@
 ^samba3.*raw.qfsinfo
 ^samba3.*raw.sfileinfo.base
 ^samba3.smb2.hold-oplock                # Not a test, but a way to block other clients for a test
+^samba3.smb2.durable-open-disconnect    # Not a test, but a way to create a disconnected durable
 ^samba3.smb2.scan                       # No tests
 ^samba4.base.iometer
 ^samba4.base.casetable
index 5a61a5652c0e20c6853041d955547b50830b2b7f..afb8e60316f6c2dd75fe9239352ca1cf5b9955fc 100644 (file)
@@ -1784,6 +1784,54 @@ done:
        return ret;
 }
 
+/**
+ * durable open with oplock, disconnect, exit
+ */
+static bool test_durable_open_oplock_disconnect(struct torture_context *tctx,
+                                               struct smb2_tree *tree)
+{
+       TALLOC_CTX *mem_ctx = talloc_new(tctx);
+       struct smb2_create io;
+       struct smb2_handle _h;
+       struct smb2_handle *h = NULL;
+       NTSTATUS status;
+       char fname[256];
+       bool ret = true;
+
+       snprintf(fname, 256, "durable_open_oplock_disconnect_%s.dat",
+                generate_random_str(tctx, 8));
+
+       smb2_util_unlink(tree, fname);
+
+       smb2_oplock_create(&io, fname, SMB2_OPLOCK_LEVEL_BATCH);
+       io.in.durable_open = true;
+
+       status = smb2_create(tree, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       _h = io.out.file.handle;
+       h = &_h;
+
+       CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_VAL(io.out.durable_open, true);
+       CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH);
+
+       /* disconnect */
+       talloc_free(tree);
+       tree = NULL;
+
+done:
+       if (tree != NULL) {
+               if (h != NULL) {
+                       smb2_util_close(tree, *h);
+               }
+               smb2_util_unlink(tree, fname);
+       }
+
+       return ret;
+}
+
+
 struct torture_suite *torture_smb2_durable_open_init(void)
 {
        struct torture_suite *suite =
@@ -1819,3 +1867,18 @@ struct torture_suite *torture_smb2_durable_open_init(void)
 
        return suite;
 }
+
+struct torture_suite *torture_smb2_durable_open_disconnect_init(void)
+{
+       struct torture_suite *suite =
+           torture_suite_create(talloc_autofree_context(),
+                                "durable-open-disconnect");
+
+       torture_suite_add_1smb2_test(suite, "open-oplock-disconnect",
+                                    test_durable_open_oplock_disconnect);
+
+       suite->description = talloc_strdup(suite,
+                                       "SMB2-DURABLE-OPEN-DISCONNECT tests");
+
+       return suite;
+}
index a396a2eda2c9502586297a06e1fee115b51bec39..65dc92466213174e3c5b37bec421ad77dcdcd9b3 100644 (file)
@@ -156,6 +156,7 @@ NTSTATUS torture_smb2_init(void)
        torture_suite_add_suite(suite, torture_smb2_acls_init());
        torture_suite_add_suite(suite, torture_smb2_notify_init());
        torture_suite_add_suite(suite, torture_smb2_durable_open_init());
+       torture_suite_add_suite(suite, torture_smb2_durable_open_disconnect_init());
        torture_suite_add_suite(suite, torture_smb2_durable_v2_open_init());
        torture_suite_add_suite(suite, torture_smb2_dir_init());
        torture_suite_add_suite(suite, torture_smb2_lease_init());