the start of a SMB2 create test suite
authorAndrew Tridgell <tridge@samba.org>
Tue, 27 May 2008 02:41:50 +0000 (12:41 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 27 May 2008 02:41:50 +0000 (12:41 +1000)
(This used to be commit 16787e99f3de7255e315651c095486f90f65f2ca)

source4/torture/smb2/config.mk
source4/torture/smb2/create.c [new file with mode: 0644]
source4/torture/smb2/smb2.c

index 11c4e1fa2c83d1e9e08d6cfb927af1b555b23bd2..6c69f3043cc0683533c93da0633467b656a5a64b 100644 (file)
@@ -20,7 +20,8 @@ TORTURE_SMB2_OBJ_FILES = $(addprefix $(torturesrcdir)/smb2/, \
                notify.o \
                smb2.o \
                persistent_handles.o \
-               oplocks.o)
+               oplocks.o \
+               create.o)
 
 
 $(eval $(call proto_header_template,$(torturesrcdir)/smb2/proto.h,$(TORTURE_SMB2_OBJ_FILES:.o=.c)))
diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c
new file mode 100644 (file)
index 0000000..fba7b84
--- /dev/null
@@ -0,0 +1,102 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   SMB2 create test suite
+
+   Copyright (C) Andrew Tridgell 2008
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+#include "param/param.h"
+#include "librpc/gen_ndr/ndr_security.h"
+
+#define FNAME "test_create.dat"
+
+#define CHECK_STATUS(status, correct) do { \
+       if (!NT_STATUS_EQUAL(status, correct)) { \
+               printf("(%s) Incorrect status %s - should be %s\n", \
+                      __location__, nt_errstr(status), nt_errstr(correct)); \
+               return false; \
+       }} while (0)
+
+/*
+  test some interesting combinations found by gentest
+ */
+bool torture_smb2_create_gentest(struct torture_context *torture, struct smb2_tree *tree)
+{
+       struct smb2_create io;
+       NTSTATUS status;
+       TALLOC_CTX *tmp_ctx = talloc_new(tree);
+
+       ZERO_STRUCT(io);
+       io.in.desired_access     = SEC_FLAG_MAXIMUM_ALLOWED;
+       io.in.file_attributes    = FILE_ATTRIBUTE_NORMAL;
+       io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
+       io.in.share_access = 
+               NTCREATEX_SHARE_ACCESS_DELETE|
+               NTCREATEX_SHARE_ACCESS_READ|
+               NTCREATEX_SHARE_ACCESS_WRITE;
+       io.in.create_options = 0;
+       io.in.fname = FNAME;
+
+       status = smb2_create(tree, tmp_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       status = smb2_util_close(tree, io.out.file.handle);
+       CHECK_STATUS(status, NT_STATUS_OK);
+
+       io.in.create_options = 0xF0000000;
+       status = smb2_create(tree, tmp_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+       io.in.create_options = 0x00100000;
+       status = smb2_create(tree, tmp_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_NOT_SUPPORTED);
+
+       io.in.create_options = 0xF0100000;
+       status = smb2_create(tree, tmp_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_NOT_SUPPORTED);
+
+       talloc_free(tmp_ctx);
+       
+       return true;
+}
+
+/* 
+   basic testing of SMB2 create calls
+*/
+bool torture_smb2_create(struct torture_context *torture)
+{
+       TALLOC_CTX *mem_ctx = talloc_new(NULL);
+       struct smb2_tree *tree;
+       bool ret = true;
+
+       if (!torture_smb2_connection(torture, &tree)) {
+               return false;
+       }
+
+       ret &= torture_smb2_create_gentest(torture, tree);
+
+       smb2_deltree(tree, FNAME);
+
+       talloc_free(mem_ctx);
+
+       return ret;
+}
index 37eadcf7fd5b006d927e09cc1b8b409c95f88e3b..852effe3e2fac5bcba18f086052410ae8b30e66a 100644 (file)
@@ -135,6 +135,7 @@ NTSTATUS torture_smb2_init(void)
        torture_suite_add_simple_test(suite, "GETINFO", torture_smb2_getinfo);
        torture_suite_add_simple_test(suite, "SETINFO", torture_smb2_setinfo);
        torture_suite_add_simple_test(suite, "FIND", torture_smb2_find);
+       torture_suite_add_simple_test(suite, "CREATE", torture_smb2_create);
        torture_suite_add_suite(suite, torture_smb2_lock_init());
        torture_suite_add_simple_test(suite, "NOTIFY", torture_smb2_notify);
        torture_suite_add_2smb2_test(suite, "PERSISTENT-HANDLES1", torture_smb2_persistent_handles1);