summaryrefslogtreecommitdiffstats
path: root/source4/torture/basic
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-05-23 21:14:05 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:52:49 -0500
commit2087e1ce6a5efd6639daaf79f0eef0b11ac7857a (patch)
tree8d1ad134c68cc3b4cba4d59277752b3e9e590530 /source4/torture/basic
parenta2a49c5af702bd5cd8a84d9dcc57abf71497b22e (diff)
downloadsamba-2087e1ce6a5efd6639daaf79f0eef0b11ac7857a.tar.gz
samba-2087e1ce6a5efd6639daaf79f0eef0b11ac7857a.tar.xz
samba-2087e1ce6a5efd6639daaf79f0eef0b11ac7857a.zip
r23099: New interesting delete on close tests :-).
This will break all delete tests on the build farm until I check in my server patch. Jeremy. (This used to be commit c31f775f1c8f6f7e50d038d093898a1f4280be23)
Diffstat (limited to 'source4/torture/basic')
-rw-r--r--source4/torture/basic/delete.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c
index 0c9016ca884..fbeec05d276 100644
--- a/source4/torture/basic/delete.c
+++ b/source4/torture/basic/delete.c
@@ -1197,6 +1197,66 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s
return correct;
}
+/* Test 20a ... */
+static bool deltest20a(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ int fnum1 = -1;
+ int fnum2 = -1;
+ bool correct = True;
+
+ del_clean_area(cli1, cli2);
+
+ /* Test 20a. */
+
+ /* Ensure the file doesn't already exist. */
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_close(cli1->tree, fnum2);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
+
+ /* Firstly open and create with all access */
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,
+ SEC_RIGHTS_FILE_ALL,
+ FILE_ATTRIBUTE_NORMAL,
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE,
+ NTCREATEX_DISP_CREATE,
+ 0, 0);
+ torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)",
+ fname, smbcli_errstr(cli1->tree)));
+
+ /* Next open with all access, but add delete on close. */
+ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0,
+ SEC_RIGHTS_FILE_ALL,
+ FILE_ATTRIBUTE_NORMAL,
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE,
+ NTCREATEX_DISP_OPEN,
+ NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
+
+ torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 2 of %s failed (%s)",
+ fname, smbcli_errstr(cli2->tree)));
+
+ /* The delete on close bit is *not* reported as being set. */
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__);
+
+ smbcli_close(cli1->tree, fnum1);
+
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__);
+
+ smbcli_close(cli2->tree, fnum2);
+
+ /* See if the file is deleted - should be.... */
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail) - %s",
+ fname, smbcli_errstr(cli1->tree)));
+
+ return correct;
+}
+
/* Test 21 ... */
static bool deltest21(struct torture_context *tctx)
{
@@ -1337,7 +1397,7 @@ static bool deltest22(struct torture_context *tctx)
return correct;
}
-
+
/*
Test delete on close semantics.
*/
@@ -1367,6 +1427,7 @@ struct torture_suite *torture_test_delete(void)
torture_suite_add_2smb_test(suite, "deltest18", deltest18);
torture_suite_add_2smb_test(suite, "deltest19", deltest19);
torture_suite_add_2smb_test(suite, "deltest20", deltest20);
+ torture_suite_add_2smb_test(suite, "deltest20a", deltest20a);
torture_suite_add_simple_test(suite, "deltest21", deltest21);
torture_suite_add_simple_test(suite, "deltest22", deltest22);