s4:torture/smb2: split replay_smb3_specification into durable handle and multichannel
authorStefan Metzmacher <metze@samba.org>
Fri, 3 Jul 2020 08:09:16 +0000 (10:09 +0200)
committerGünther Deschner <gd@samba.org>
Tue, 14 Jul 2020 13:38:35 +0000 (13:38 +0000)
It's better to have durable handles and multichannel tested separate:
1. we test both cases in the server
2. it makes it easier to deal with knownfail entries if only one
   of these features is active on the server.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
selftest/knownfail
source4/torture/smb2/lock.c

index 4fe503f4cc1f35ecccd2933b1bbaad46011029e1..6c005d1f4deb7afc6db6269b44e5d59870d5710a 100644 (file)
 ^samba3.smb2.compound.aio.interim2 # wrong return code (STATUS_CANCELLED)
 ^samba3.smb2.replay.replay3 # This requires multi-chanel
 ^samba3.smb2.replay.replay4 # This requires multi-chanel
-^samba3.smb2.lock.replay_smb3_specification # This requires multi-chanel or durable handles
+^samba3.smb2.lock.replay_smb3_specification_multi # This requires multi-chanel
+^samba3.smb2.lock.replay_smb3_specification_durable\(nt4_dc\) # Requires durable handles
 ^samba3.smb2.lock.*replay_broken_windows # This tests the windows behaviour
 ^samba3.smb2.lease.statopen3
 ^samba3.smb2.lease.unlink # we currently do not downgrade RH lease to R after unlink
index 1c515c865e5119d9f6c6849040fa61ae879da457..eac0d557fc38659f47a591623bec1e08b26aad8d 100644 (file)
@@ -3167,8 +3167,10 @@ done:
  * Hopefully this will be fixed in future Windows versions and they
  * will avoid Note <314>.
  */
-static bool test_replay_smb3_specification(struct torture_context *torture,
-                                          struct smb2_tree *tree)
+static bool _test_replay_smb3_specification(struct torture_context *torture,
+                                           struct smb2_tree *tree,
+                                           const char *testname,
+                                           bool use_durable)
 {
        NTSTATUS status;
        bool ret = true;
@@ -3176,7 +3178,7 @@ static bool test_replay_smb3_specification(struct torture_context *torture,
        struct smb2_handle h;
        struct smb2_lock lck;
        struct smb2_lock_element el;
-       const char *fname = BASEDIR "\\replay_smb3_specification.txt";
+       char fname[256];
        struct smb2_transport *transport = tree->session->transport;
 
        if (smbXcli_conn_protocol(transport->conn) < PROTOCOL_SMB3_00) {
@@ -3184,22 +3186,24 @@ static bool test_replay_smb3_specification(struct torture_context *torture,
                                required for Lock Replay tests\n");
        }
 
+       snprintf(fname, sizeof(fname), "%s\\%s.dat", BASEDIR, testname);
+
        status = torture_smb2_testdir(tree, BASEDIR, &h);
        CHECK_STATUS(status, NT_STATUS_OK);
        smb2_util_close(tree, h);
 
-       torture_comment(torture, "Testing Open File:\n");
+       torture_comment(torture, "%s: Testing Open File:\n", testname);
 
        smb2_oplock_create_share(&io, fname,
                                 smb2_util_share_access(""),
                                 smb2_util_oplock_level("b"));
-       io.in.durable_open = true;
+       io.in.durable_open = use_durable;
 
        status = smb2_create(tree, torture, &io);
        CHECK_STATUS(status, NT_STATUS_OK);
        h = io.out.file.handle;
        CHECK_VALUE(io.out.oplock_level, smb2_util_oplock_level("b"));
-       CHECK_VALUE(io.out.durable_open, true);
+       CHECK_VALUE(io.out.durable_open, use_durable);
        CHECK_VALUE(io.out.durable_open_v2, false);
        CHECK_VALUE(io.out.persistent_open, false);
 
@@ -3363,6 +3367,41 @@ done:
        return ret;
 }
 
+static bool test_replay_smb3_specification_durable(struct torture_context *torture,
+                                                  struct smb2_tree *tree)
+{
+       const char *testname = "replay_smb3_specification_durable";
+       struct smb2_transport *transport = tree->session->transport;
+
+       if (smbXcli_conn_protocol(transport->conn) < PROTOCOL_SMB2_10) {
+               torture_skip(torture, "SMB 2.1.0 Dialect family or above \
+                               required for Lock Replay tests on durable handles\n");
+       }
+
+       return _test_replay_smb3_specification(torture, tree, testname, true);
+}
+
+static bool test_replay_smb3_specification_multi(struct torture_context *torture,
+                                                struct smb2_tree *tree)
+{
+       const char *testname = "replay_smb3_specification_multi";
+       struct smb2_transport *transport = tree->session->transport;
+       uint32_t server_capabilities;
+
+       if (smbXcli_conn_protocol(transport->conn) < PROTOCOL_SMB3_00) {
+               torture_skip(torture, "SMB 3.0.0 Dialect family or above \
+                       required for Lock Replay tests on without durable handles\n");
+       }
+
+       server_capabilities = smb2cli_conn_server_capabilities(transport->conn);
+       if (!(server_capabilities & SMB2_CAP_MULTI_CHANNEL)) {
+               torture_skip(torture, "MULTI_CHANNEL is \
+                       required for Lock Replay tests on without durable handles\n");
+       }
+
+       return _test_replay_smb3_specification(torture, tree, testname, false);
+}
+
 /**
  * Test lock interaction between smbd and ctdb with tombstone records.
  *
@@ -3462,8 +3501,10 @@ struct torture_suite *torture_smb2_lock_init(TALLOC_CTX *ctx)
        torture_suite_add_1smb2_test(suite, "truncate", test_truncate);
        torture_suite_add_1smb2_test(suite, "replay_broken_windows",
                                     test_replay_broken_windows);
-       torture_suite_add_1smb2_test(suite, "replay_smb3_specification",
-                                    test_replay_smb3_specification);
+       torture_suite_add_1smb2_test(suite, "replay_smb3_specification_durable",
+                                    test_replay_smb3_specification_durable);
+       torture_suite_add_1smb2_test(suite, "replay_smb3_specification_multi",
+                                    test_replay_smb3_specification_multi);
        torture_suite_add_1smb2_test(suite, "ctdb-delrec-deadlock", test_deadlock);
 
        suite->description = talloc_strdup(suite, "SMB2-LOCK tests");