s3-torture: Add WILDDELETE test to smbtorture3 to test old wildcard delete with zero...
authorJeremy Allison <jra@samba.org>
Mon, 19 Oct 2015 23:06:01 +0000 (16:06 -0700)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 21 Oct 2015 06:25:26 +0000 (08:25 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11452

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/selftest/tests.py
source3/torture/torture.c

index 4f6c12366e69abda058f005a1e2debdf9ed59a5f..048675a84cb207eaf8514772e038fcafde0d6d40 100755 (executable)
@@ -48,7 +48,7 @@ tests = ["FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", "LOCK5", "LOCK6", "LOCK7"
         "UNLINK", "BROWSE", "ATTR", "TRANS2", "TORTURE",
         "OPLOCK1", "OPLOCK2", "OPLOCK4", "STREAMERROR",
         "DIR", "DIR1", "DIR-CREATETIME", "TCON", "TCONDEV", "RW1", "RW2", "RW3", "LARGE_READX", "RW-SIGNING",
-        "OPEN", "XCOPY", "RENAME", "DELETE", "DELETE-LN", "PROPERTIES", "W2K",
+        "OPEN", "XCOPY", "RENAME", "DELETE", "DELETE-LN", "WILDDELETE", "PROPERTIES", "W2K",
         "TCON2", "IOCTL", "CHKPATH", "FDSESS", "CHAIN1", "CHAIN2",
         "CHAIN3",
         "GETADDRINFO", "UID-REGRESSION-TEST", "SHORTNAME-TEST",
index 21d2dd25500a8042984a9477cee378b33b4c620f..ef75d2140c4caec235cb83069806d674cb0ff549 100644 (file)
@@ -4409,6 +4409,72 @@ static bool run_deletetest(int dummy)
        return correct;
 }
 
+
+/*
+  Test wildcard delete.
+ */
+static bool run_wild_deletetest(int dummy)
+{
+       struct cli_state *cli = NULL;
+       const char *dname = "\\WTEST";
+       const char *fname = "\\WTEST\\A";
+       const char *wunlink_name = "\\WTEST\\*";
+       uint16_t fnum1 = (uint16_t)-1;
+       bool correct = false;
+       NTSTATUS status;
+
+       printf("starting wildcard delete test\n");
+
+       if (!torture_open_connection(&cli, 0)) {
+               return false;
+       }
+
+       smbXcli_conn_set_sockopt(cli->conn, sockops);
+
+       cli_unlink(cli, fname, 0);
+       cli_rmdir(cli, dname);
+       status = cli_mkdir(cli, dname);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("mkdir of %s failed %s!\n", dname, nt_errstr(status));
+               goto fail;
+       }
+       status = cli_openx(cli, fname, O_CREAT|O_RDONLY, DENY_NONE, &fnum1);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("open of %s failed %s!\n", fname, nt_errstr(status));
+               goto fail;
+       }
+       status = cli_close(cli, fnum1);
+       fnum1 = -1;
+
+       /*
+        * Note the unlink attribute-type of zero. This should
+        * map into FILE_ATTRIBUTE_NORMAL at the server even
+        * on a wildcard delete.
+        */
+
+       status = cli_unlink(cli, wunlink_name, 0);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("unlink of %s failed %s!\n",
+                       wunlink_name, nt_errstr(status));
+               goto fail;
+       }
+
+       printf("finished wildcard delete test\n");
+
+       correct = true;
+
+  fail:
+
+       if (fnum1 != (uint16_t)-1) cli_close(cli, fnum1);
+       cli_unlink(cli, fname, 0);
+       cli_rmdir(cli, dname);
+
+       if (cli && !torture_close_connection(cli)) {
+               correct = false;
+       }
+       return correct;
+}
+
 static bool run_deletetest_ln(int dummy)
 {
        struct cli_state *cli;
@@ -9548,6 +9614,7 @@ static struct {
        {"XCOPY", run_xcopy, 0},
        {"RENAME", run_rename, 0},
        {"DELETE", run_deletetest, 0},
+       {"WILDDELETE", run_wild_deletetest, 0},
        {"DELETE-LN", run_deletetest_ln, 0},
        {"PROPERTIES", run_properties, 0},
        {"MANGLE", torture_mangle, 0},