torture/ioctl: test compression responses when unsupported
authorDavid Disseldorp <ddiss@samba.org>
Mon, 3 Oct 2016 23:15:20 +0000 (01:15 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 6 Oct 2016 04:14:34 +0000 (06:14 +0200)
Confirm that Samba matches Windows Server 2016 ReFS behaviour here.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12144

Reported-by: Nick Barrett
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Oct  6 06:14:34 CEST 2016 on sn-devel-144

selftest/knownfail
source4/torture/smb2/ioctl.c

index 076880f1bd25febe48a90d5e962042a451934c97..976761b94b440220e9bcac30332fe0251236075e 100644 (file)
 ^samba3.smb2.replay.replay3
 ^samba3.smb2.replay.replay4
 ^samba3.smb2.lock.*replay
+^samba4.smb2.ioctl.compress_notsup.*\(ad_dc_ntvfs\)
 ^samba3.raw.session.*reauth2 # maybe fix this?
 ^samba3.rpc.lsa.secrets.seal # This gives NT_STATUS_LOCAL_USER_SESSION_KEY
 ^samba3.rpc.samr.passwords.badpwdcount.samr.badPwdCount\(nt4_dc\) # We fail this test currently
index 2baf7b677542975c5bc4b63bd30476403459c6b5..01cc1500aabe3807a8287fb80010871d91cf06a5 100644 (file)
@@ -2543,6 +2543,78 @@ static bool test_ioctl_compress_perms(struct torture_context *torture,
        return true;
 }
 
+static bool test_ioctl_compress_notsup_get(struct torture_context *torture,
+                                          struct smb2_tree *tree)
+{
+       struct smb2_handle fh;
+       NTSTATUS status;
+       TALLOC_CTX *tmp_ctx = talloc_new(tree);
+       bool ok;
+       uint16_t compression_fmt;
+
+       ok = test_setup_create_fill(torture, tree, tmp_ctx,
+                                   FNAME, &fh, 0, SEC_RIGHTS_FILE_ALL,
+                                   FILE_ATTRIBUTE_NORMAL);
+       torture_assert(torture, ok, "setup compression file");
+
+       /* skip if the server DOES support compression */
+       status = test_ioctl_compress_fs_supported(torture, tree, tmp_ctx, &fh,
+                                                 &ok);
+       torture_assert_ntstatus_ok(torture, status, "SMB2_GETINFO_FS");
+       if (ok) {
+               smb2_util_close(tree, fh);
+               torture_skip(torture, "FS compression supported\n");
+       }
+
+       /*
+        * Despite not supporting compression, we should get a successful
+        * response indicating that the file is uncompressed - like WS2016.
+        */
+       status = test_ioctl_compress_get(torture, tmp_ctx, tree, fh,
+                                        &compression_fmt);
+       torture_assert_ntstatus_ok(torture, status, "FSCTL_GET_COMPRESSION");
+
+       torture_assert(torture, (compression_fmt == COMPRESSION_FORMAT_NONE),
+                      "initial compression state not NONE");
+
+       smb2_util_close(tree, fh);
+       talloc_free(tmp_ctx);
+       return true;
+}
+
+static bool test_ioctl_compress_notsup_set(struct torture_context *torture,
+                                          struct smb2_tree *tree)
+{
+       struct smb2_handle fh;
+       NTSTATUS status;
+       TALLOC_CTX *tmp_ctx = talloc_new(tree);
+       bool ok;
+
+       ok = test_setup_create_fill(torture, tree, tmp_ctx,
+                                   FNAME, &fh, 0, SEC_RIGHTS_FILE_ALL,
+                                   FILE_ATTRIBUTE_NORMAL);
+       torture_assert(torture, ok, "setup compression file");
+
+       /* skip if the server DOES support compression */
+       status = test_ioctl_compress_fs_supported(torture, tree, tmp_ctx, &fh,
+                                                 &ok);
+       torture_assert_ntstatus_ok(torture, status, "SMB2_GETINFO_FS");
+       if (ok) {
+               smb2_util_close(tree, fh);
+               torture_skip(torture, "FS compression supported\n");
+       }
+
+       status = test_ioctl_compress_set(torture, tmp_ctx, tree, fh,
+                                        COMPRESSION_FORMAT_DEFAULT);
+       torture_assert_ntstatus_equal(torture, status,
+                                     NT_STATUS_NOT_SUPPORTED,
+                                     "FSCTL_GET_COMPRESSION");
+
+       smb2_util_close(tree, fh);
+       talloc_free(tmp_ctx);
+       return true;
+}
+
 /*
    basic testing of the SMB2 FSCTL_QUERY_NETWORK_INTERFACE_INFO ioctl
 */
@@ -6169,6 +6241,10 @@ struct torture_suite *torture_smb2_ioctl_init(void)
                                     test_ioctl_compress_set_file_attr);
        torture_suite_add_1smb2_test(suite, "compress_perms",
                                     test_ioctl_compress_perms);
+       torture_suite_add_1smb2_test(suite, "compress_notsup_get",
+                                    test_ioctl_compress_notsup_get);
+       torture_suite_add_1smb2_test(suite, "compress_notsup_set",
+                                    test_ioctl_compress_notsup_set);
        torture_suite_add_1smb2_test(suite, "network_interface_info",
                                     test_ioctl_network_interface_info);
        torture_suite_add_1smb2_test(suite, "sparse_file_flag",