s4:torture/smb2: add smb2_create_simple_file() and torture_setup_simple_file()
authorStefan Metzmacher <metze@samba.org>
Tue, 12 Feb 2019 15:51:20 +0000 (16:51 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 28 Mar 2019 23:09:37 +0000 (23:09 +0000)
Instead of the *_complex_file() versions these don't use EA's nor
complex timestamps.

A lot of tests currently using *_complex_file() only fail because
smbd doesn't implement the correct 'change_time' update behavior.
That should not be the reason why all smb2 related tests fail.

Timestamps should be tested in dedicated tests.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13864

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/torture/smb2/util.c

index ac8a0d5df7763d1cdeb0df3dcc5f6ab39905e4ae..04212650c30c60a6f045115911eafbb0e165e59a 100644 (file)
@@ -595,6 +595,40 @@ NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname,
                                           SEC_RIGHTS_DIR_ALL);
 }
 
+/*
+  create a simple file using the SMB2 protocol
+*/
+NTSTATUS smb2_create_simple_file(struct torture_context *tctx,
+                                struct smb2_tree *tree, const char *fname,
+                                struct smb2_handle *handle)
+{
+       char buf[7] = "abc";
+       NTSTATUS status;
+
+       smb2_util_unlink(tree, fname);
+       status = torture_smb2_testfile_access(tree,
+                                             fname, handle,
+                                             SEC_FLAG_MAXIMUM_ALLOWED);
+       NT_STATUS_NOT_OK_RETURN(status);
+
+       status = smb2_util_write(tree, *handle, buf, 0, sizeof(buf));
+       NT_STATUS_NOT_OK_RETURN(status);
+
+       return NT_STATUS_OK;
+}
+
+/*
+  create a simple file using SMB2.
+*/
+NTSTATUS torture_setup_simple_file(struct torture_context *tctx,
+                                  struct smb2_tree *tree, const char *fname)
+{
+       struct smb2_handle handle;
+       NTSTATUS status = smb2_create_simple_file(tctx, tree, fname, &handle);
+       NT_STATUS_NOT_OK_RETURN(status);
+       return smb2_util_close(tree, handle);
+}
+
 /*
   create a complex file using SMB2, to make it easier to
   find fields in SMB2 getinfo levels