torture: Extend the smb2.oplock.doc1 test
authorVolker Lendecke <vl@samba.org>
Thu, 26 Sep 2013 06:04:50 +0000 (23:04 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 11 Oct 2013 22:07:37 +0000 (15:07 -0700)
If delete_on_close is set, there is no oplock break. Check that.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail
source4/torture/smb2/oplock.c

index e349c63e133923c5c96774aea2c0ec4669295575..1653ceaf31e161f4dadb1413f18c543348d07490 100644 (file)
 ^samba4.smb2.rename.share_delete_no_delete_access\(.*\)$
 ^samba4.smb2.rename.no_share_delete_no_delete_access\(.*\)$
 ^samba4.smb2.rename.msword
+^samba4.smb2.oplock.doc
 ^samba4.smb2.compound.related3
 ^samba4.smb2.compound.compound-break
 ^samba4.winbind.struct.*.show_sequence     # Not yet working in winbind
index 4cf7c7d72ffe32b3738840a59650ac10b409659c..5070d009b3bbffada61804d12c9c6acf13210e87 100644 (file)
@@ -2896,16 +2896,19 @@ static bool test_raw_oplock_stream1(struct torture_context *tctx,
        return ret;
 }
 
-static bool test_smb2_oplock_doc(struct torture_context *tctx, struct smb2_tree *tree)
+static bool test_smb2_oplock_doc(struct torture_context *tctx, struct smb2_tree *tree,
+                                struct smb2_tree *tree2)
 {
        const char *fname = BASEDIR "\\test_oplock_doc.dat";
        NTSTATUS status;
        bool ret = true;
        union smb_open io;
        struct smb2_handle h, h1;
+       union smb_setfileinfo sfinfo;
 
        status = torture_smb2_testdir(tree, BASEDIR, &h);
        torture_assert_ntstatus_ok(tctx, status, "Error creating directory");
+       smb2_util_close(tree, h);
 
        /* cleanup */
        smb2_util_unlink(tree, fname);
@@ -2920,15 +2923,15 @@ static bool test_smb2_oplock_doc(struct torture_context *tctx, struct smb2_tree
        io.smb2.in.desired_access = SEC_RIGHTS_FILE_ALL;
        io.smb2.in.alloc_size = 0;
        io.smb2.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
-       io.smb2.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+       io.smb2.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
+               NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE;
        io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
-       io.smb2.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE;
+       io.smb2.in.create_options = 0;
        io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
        io.smb2.in.security_flags = 0;
        io.smb2.in.fname = fname;
 
-       torture_comment(tctx, "open a delete-on-close file with a batch "
-                       "oplock\n");
+       torture_comment(tctx, "open a file with a batch oplock\n");
        ZERO_STRUCT(break_info);
        io.smb2.in.create_flags = NTCREATEX_FLAGS_EXTENDED;
        io.smb2.in.oplock_level = SMB2_OPLOCK_LEVEL_BATCH;
@@ -2938,6 +2941,25 @@ static bool test_smb2_oplock_doc(struct torture_context *tctx, struct smb2_tree
        h1 = io.smb2.out.file.handle;
        CHECK_VAL(io.smb2.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH);
 
+       torture_comment(tctx, "Set delete on close\n");
+       ZERO_STRUCT(sfinfo);
+       sfinfo.generic.level = RAW_SFILEINFO_DISPOSITION_INFORMATION;
+       sfinfo.generic.in.file.handle = h1;
+       sfinfo.disposition_info.in.delete_on_close = 1;
+       status = smb2_setinfo_file(tree, &sfinfo);
+       torture_assert_ntstatus_ok(tctx, status, "Incorrect status");
+
+       torture_comment(tctx, "2nd open should not break and get "
+                       "DELETE_PENDING\n");
+       ZERO_STRUCT(break_info);
+       io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
+       io.smb2.in.create_options = 0;
+       io.smb2.in.desired_access = SEC_FILE_READ_DATA;
+       status = smb2_create(tree2, tctx, &io.smb2);
+       torture_assert_ntstatus_equal(tctx, status, NT_STATUS_DELETE_PENDING,
+                                     "Incorrect status");
+       CHECK_VAL(break_info.count, 0);
+
        smb2_util_close(tree, h1);
 
        smb2_util_unlink(tree, fname);
@@ -3412,7 +3434,7 @@ struct torture_suite *torture_smb2_oplocks_init(void)
        torture_suite_add_2smb2_test(suite, "batch24", test_smb2_oplock_batch24);
        torture_suite_add_1smb2_test(suite, "batch25", test_smb2_oplock_batch25);
        torture_suite_add_2smb2_test(suite, "stream1", test_raw_oplock_stream1);
-       torture_suite_add_1smb2_test(suite, "doc", test_smb2_oplock_doc);
+       torture_suite_add_2smb2_test(suite, "doc", test_smb2_oplock_doc);
        torture_suite_add_2smb2_test(suite, "brl1", test_smb2_oplock_brl1);
        torture_suite_add_1smb2_test(suite, "brl2", test_smb2_oplock_brl2);
        torture_suite_add_1smb2_test(suite, "brl3", test_smb2_oplock_brl3);