From 672c22831032b862a11259ddb1e0cc8ef9ba0d26 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 25 Sep 2013 23:04:50 -0700 Subject: torture: Extend the smb2.oplock.doc1 test If delete_on_close is set, there is no oplock break. Check that. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source4/torture/smb2/oplock.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'source4') diff --git a/source4/torture/smb2/oplock.c b/source4/torture/smb2/oplock.c index 4cf7c7d72f..5070d009b3 100644 --- a/source4/torture/smb2/oplock.c +++ b/source4/torture/smb2/oplock.c @@ -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); -- cgit