s4:torture/smb2/read: add test for cancelling SMB aio
authorRalph Boehme <slow@samba.org>
Sun, 28 Oct 2018 18:29:26 +0000 (19:29 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 2 Nov 2018 20:21:14 +0000 (21:21 +0100)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/samba3.smb2 [new file with mode: 0644]
selftest/target/Samba3.pm
source3/selftest/tests.py
source4/selftest/tests.py
source4/torture/smb2/read.c
source4/torture/smb2/smb2.c

diff --git a/selftest/knownfail.d/samba3.smb2 b/selftest/knownfail.d/samba3.smb2
new file mode 100644 (file)
index 0000000..f4e2ecf
--- /dev/null
@@ -0,0 +1 @@
+^samba3.smb2.aio_delay.aio_cancel\(nt4_dc\)
index f7957cf3a7d57d389b0fb6e70af85ee52463382e..f8fda35366b719dc87ed2ada8ce965a72f6ed10b 100755 (executable)
@@ -2250,6 +2250,12 @@ sub provision($$$$$$$$$)
        kernel oplocks = no
        posix locking = no
        include = $libdir/delay_inject.conf
        kernel oplocks = no
        posix locking = no
        include = $libdir/delay_inject.conf
+
+[aio_delay_inject]
+       copy = tmp
+       vfs objects = delay_inject
+       delay_inject:pread_send = 2000
+       delay_inject:pwrite_send = 2000
        ";
        close(CONF);
 
        ";
        close(CONF);
 
index 08395c1c096058504eb93ca00f7e9643e0498096..ae569258a7830fb412b3bc33bae36b622b0b8a21 100755 (executable)
@@ -620,6 +620,8 @@ for t in tests:
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
         plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/streams_xattr -U$USERNAME%$PASSWORD', 'streams_xattr')
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
         plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/streams_xattr -U$USERNAME%$PASSWORD', 'streams_xattr')
+    elif t == "smb2.aio_delay":
+        plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/aio_delay_inject -U$USERNAME%$PASSWORD')
     else:
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
         plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
     else:
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
         plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
index 24817e40fb5ccac46958ec56ee8894187cd0b88e..3737efbd6c442bdfbd3a4c2401c5f199686de697 100755 (executable)
@@ -331,6 +331,7 @@ smb2_s3only = [
     "smb2.credits",
     "smb2.kernel-oplocks",
     "smb2.durable-v2-delay",
     "smb2.credits",
     "smb2.kernel-oplocks",
     "smb2.durable-v2-delay",
+    "smb2.aio_delay",
 ]
 smb2 = [x for x in smbtorture4_testsuites("smb2.") if x not in smb2_s3only]
 
 ]
 smb2 = [x for x in smbtorture4_testsuites("smb2.") if x not in smb2_s3only]
 
index 4bf3bb74be0a39ca2f05e6cf329975717f4d980c..b26bc18ddacda5b67ad47b190d76809914c75be1 100644 (file)
@@ -22,6 +22,7 @@
 #include "includes.h"
 #include "libcli/smb2/smb2.h"
 #include "libcli/smb2/smb2_calls.h"
 #include "includes.h"
 #include "libcli/smb2/smb2.h"
 #include "libcli/smb2/smb2_calls.h"
+#include <tevent.h>
 
 #include "torture/torture.h"
 #include "torture/smb2/proto.h"
 
 #include "torture/torture.h"
 #include "torture/smb2/proto.h"
@@ -317,3 +318,118 @@ struct torture_suite *torture_smb2_read_init(TALLOC_CTX *ctx)
        return suite;
 }
 
        return suite;
 }
 
+static bool test_aio_cancel(struct torture_context *tctx,
+                           struct smb2_tree *tree)
+{
+       struct smb2_handle h;
+       uint8_t buf[64 * 1024];
+       struct smb2_read r;
+       struct smb2_request *req = NULL;
+       int rc;
+       NTSTATUS status;
+       bool ret = true;
+
+       ZERO_STRUCT(buf);
+
+       smb2_util_unlink(tree, FNAME);
+
+       status = torture_smb2_testfile(tree, FNAME, &h);
+       torture_assert_ntstatus_ok_goto(
+               tctx,
+               status,
+               ret,
+               done,
+               "torture_smb2_testfile failed\n");
+
+       status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
+       torture_assert_ntstatus_ok_goto(
+               tctx,
+               status,
+               ret,
+               done,
+               "smb2_util_write failed\n");
+
+       status = smb2_util_close(tree, h);
+       torture_assert_ntstatus_ok_goto(
+               tctx,
+               status,
+               ret,
+               done,
+               "smb2_util_close failed\n");
+
+       status = torture_smb2_testfile_access(
+               tree, FNAME, &h, SEC_RIGHTS_FILE_ALL);
+       torture_assert_ntstatus_ok_goto(
+               tctx,
+               status,
+               ret,
+               done,
+               "torture_smb2_testfile_access failed\n");
+
+       r = (struct smb2_read) {
+               .in.file.handle = h,
+               .in.length      = 1,
+               .in.offset      = 0,
+               .in.min_count   = 1,
+       };
+
+       req = smb2_read_send(tree, &r);
+       torture_assert_goto(
+               tctx,
+               req != NULL,
+               ret,
+               done,
+               "smb2_read_send failed\n");
+
+       while (!req->cancel.can_cancel) {
+               rc = tevent_loop_once(tctx->ev);
+               torture_assert_goto(
+                       tctx,
+                       rc == 0,
+                       ret,
+                       done,
+                       "tevent_loop_once failed\n");
+       }
+
+       status = smb2_cancel(req);
+       torture_assert_ntstatus_ok_goto(
+               tctx,
+               status,
+               ret,
+               done,
+               "smb2_cancel failed\n");
+
+       status = smb2_read_recv(req, tree, &r);
+       torture_assert_ntstatus_ok_goto(
+               tctx,
+               status,
+               ret,
+               done,
+               "smb2_read_recv failed\n");
+
+       status = smb2_util_close(tree, h);
+       torture_assert_ntstatus_ok_goto(
+               tctx,
+               status,
+               ret,
+               done,
+               "smb2_util_close failed\n");
+
+done:
+       smb2_util_unlink(tree, FNAME);
+       return ret;
+}
+
+/*
+ * aio testing against share with VFS module "delay_inject"
+ */
+struct torture_suite *torture_smb2_aio_delay_init(TALLOC_CTX *ctx)
+{
+       struct torture_suite *suite = torture_suite_create(ctx, "aio_delay");
+
+       torture_suite_add_1smb2_test(suite, "aio_cancel", test_aio_cancel);
+
+       suite->description = talloc_strdup(suite, "SMB2 delayed aio tests");
+
+       return suite;
+}
index 12f7edf8f86154f75700be5f613d64e4f5145086..6f9884e3c27ee49fbb9473d611296189e6c2df7c 100644 (file)
@@ -152,6 +152,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
        torture_suite_add_simple_test(suite, "setinfo", torture_smb2_setinfo);
        torture_suite_add_suite(suite, torture_smb2_lock_init(suite));
        torture_suite_add_suite(suite, torture_smb2_read_init(suite));
        torture_suite_add_simple_test(suite, "setinfo", torture_smb2_setinfo);
        torture_suite_add_suite(suite, torture_smb2_lock_init(suite));
        torture_suite_add_suite(suite, torture_smb2_read_init(suite));
+       torture_suite_add_suite(suite, torture_smb2_aio_delay_init(suite));
        torture_suite_add_suite(suite, torture_smb2_create_init(suite));
        torture_suite_add_suite(suite, torture_smb2_acls_init(suite));
        torture_suite_add_suite(suite, torture_smb2_notify_init(suite));
        torture_suite_add_suite(suite, torture_smb2_create_init(suite));
        torture_suite_add_suite(suite, torture_smb2_acls_init(suite));
        torture_suite_add_suite(suite, torture_smb2_notify_init(suite));