summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-03-26 02:39:48 +0000
committerAndrew Tridgell <tridge@samba.org>2004-03-26 02:39:48 +0000
commit47dfe299c8a5a64ade88d15ecf71f99800ea40cd (patch)
tree0cf7ed8fbcb122f397f6c9f541d656bb1344b42c
parent9a29b393775e29dea2ba1048e86fed60b7a38e3d (diff)
downloadsamba-47dfe299c8a5a64ade88d15ecf71f99800ea40cd.tar.gz
samba-47dfe299c8a5a64ade88d15ecf71f99800ea40cd.tar.bz2
samba-47dfe299c8a5a64ade88d15ecf71f99800ea40cd.zip
- moved some of the base tests into torture/basic/
- added a CHARSET set of tests, which determines how the server deals with some specific charset issues related to UTF-16 support. Interestingly, Samba3 already passes all but one of these tests, because our incorrect UCS-2 and UTF-8 implementations where we don't check the validity of characters actually matches what Windows does! This means that adding UTF-16 support to Samba is going to be _much_ easier than we expected. (This used to be commit c8497a42364d186f08102224d5062d176ee81f5b)
-rw-r--r--source4/Makefile.in5
-rw-r--r--source4/torture/basic/aliases.c (renamed from source4/torture/aliases.c)0
-rw-r--r--source4/torture/basic/charset.c269
-rw-r--r--source4/torture/basic/denytest.c (renamed from source4/torture/denytest.c)0
-rw-r--r--source4/torture/basic/dfstest.c (renamed from source4/torture/dfstest.c)0
-rw-r--r--source4/torture/basic/mangle_test.c (renamed from source4/torture/mangle_test.c)0
-rw-r--r--source4/torture/basic/scanner.c (renamed from source4/torture/scanner.c)0
-rw-r--r--source4/torture/basic/utable.c (renamed from source4/torture/utable.c)0
-rwxr-xr-xsource4/torture/config.m413
-rw-r--r--source4/torture/nbench/nbio.c2
-rw-r--r--source4/torture/torture.c1
11 files changed, 284 insertions, 6 deletions
diff --git a/source4/Makefile.in b/source4/Makefile.in
index e240afb766..f095007c99 100644
--- a/source4/Makefile.in
+++ b/source4/Makefile.in
@@ -143,6 +143,8 @@ TORTURE_RPC_OBJS = @TORTURE_RPC_OBJS@
TORTURE_NBENCH_OBJS = @TORTURE_NBENCH_OBJS@
+TORTURE_BASIC_OBJS = @TORTURE_BASIC_OBJS@
+
TORTURE_OBJS = @TORTURE_OBJS@
TORTURE_LIBS = @TORTURE_LIBS@
@@ -188,6 +190,7 @@ PROTO_OBJ = $(SERVER_OBJS) $(PROCESS_MODEL_OBJS) $(CLIENT_OBJS) $(TORTURE_OBJS)
$(DCERPC_OBJS) $(SMB_OBJS) $(AUTH_OBJS) $(PASSDB_OBJS) $(NTVFS_OBJS) \
$(LIBBASIC_OBJS) $(CONFIG_OBJS) $(LIBCMDLINE_OBJS) $(LIBSMB_OBJS)
+
######################################################################
# now the rules...
######################################################################
@@ -453,5 +456,5 @@ $(srcdir)/configure: $(srcdir)/configure.in
config.status: $(srcdir)/configure
@echo "WARNING: you need to run configure"
-Makefile: $(srcdir)/Makefile.in config.status
+Makefile: $(srcdir)/Makefile.in config.status smb_server/config.m4
@echo "WARNING: you need to run ./config.status"
diff --git a/source4/torture/aliases.c b/source4/torture/basic/aliases.c
index c4d6f94700..c4d6f94700 100644
--- a/source4/torture/aliases.c
+++ b/source4/torture/basic/aliases.c
diff --git a/source4/torture/basic/charset.c b/source4/torture/basic/charset.c
new file mode 100644
index 0000000000..1a708ac055
--- /dev/null
+++ b/source4/torture/basic/charset.c
@@ -0,0 +1,269 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ SMB torture tester - charset test routines
+
+ Copyright (C) Andrew Tridgell 2001
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+#define BASEDIR "\\chartest\\"
+
+/*
+ open a file using a set of unicode code points for the name
+
+ the prefix BASEDIR is added before the name
+*/
+static NTSTATUS unicode_open(struct cli_tree *tree,
+ TALLOC_CTX *mem_ctx,
+ uint32 open_disposition,
+ const uint32 *u_name,
+ size_t u_name_len)
+{
+ union smb_open io;
+ char *fname, *fname2=NULL, *ucs_name;
+ int i;
+ NTSTATUS status;
+
+ ucs_name = malloc((1+u_name_len)*2);
+ if (!ucs_name) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0;i<u_name_len;i++) {
+ SSVAL(ucs_name, i*2, u_name[i]);
+ }
+ SSVAL(ucs_name, i*2, 0);
+
+ i = convert_string_allocate(CH_UCS2, CH_UNIX, ucs_name, (1+u_name_len)*2, &fname);
+ if (i == -1) {
+ free(ucs_name);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ asprintf(&fname2, "%s%s", BASEDIR, fname);
+ if (!fname2) {
+ free(fname);
+ free(ucs_name);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = GENERIC_RIGHTS_FILE_ALL_ACCESS;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname2;
+ io.ntcreatex.in.open_disposition = open_disposition;
+
+ status = smb_raw_open(tree, mem_ctx, &io);
+
+ free(fname);
+ free(fname2);
+ free(ucs_name);
+
+ return status;
+}
+
+
+/*
+ see if the server recognises composed characters
+*/
+static BOOL test_composed(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+{
+ const uint32 name1[] = {0x61, 0x308};
+ const uint32 name2[] = {0xe4};
+ NTSTATUS status1, status2;
+
+ printf("Testing composite character (a umlaut)\n");
+
+ status1 = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 2);
+ if (!NT_STATUS_IS_OK(status1)) {
+ printf("Failed to create composed name - %s\n",
+ nt_errstr(status1));
+ return False;
+ }
+
+ status2 = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1);
+
+ if (!NT_STATUS_IS_OK(status2)) {
+ printf("Failed to create accented character - %s\n",
+ nt_errstr(status2));
+ return False;
+ }
+
+ return True;
+}
+
+/*
+ see if the server recognises a naked diacritical
+*/
+static BOOL test_diacritical(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+{
+ const uint32 name1[] = {0x308};
+ const uint32 name2[] = {0x308, 0x308};
+ NTSTATUS status1, status2;
+
+ printf("Testing naked diacritical (umlaut)\n");
+
+ status1 = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1);
+
+ if (!NT_STATUS_IS_OK(status1)) {
+ printf("Failed to create naked diacritical - %s\n",
+ nt_errstr(status1));
+ return False;
+ }
+
+ /* try a double diacritical */
+ status2 = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 2);
+
+ if (!NT_STATUS_IS_OK(status2)) {
+ printf("Failed to create double naked diacritical - %s\n",
+ nt_errstr(status2));
+ return False;
+ }
+
+ return True;
+}
+
+/*
+ see if the server recognises a partial surrogate pair
+*/
+static BOOL test_surrogate(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+{
+ const uint32 name1[] = {0xd800};
+ const uint32 name2[] = {0xdc00};
+ const uint32 name3[] = {0xd800, 0xdc00};
+ NTSTATUS status;
+
+ printf("Testing partial surrogate\n");
+
+ status = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to create partial surrogate 1 - %s\n",
+ nt_errstr(status));
+ return False;
+ }
+
+ status = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to create partial surrogate 2 - %s\n",
+ nt_errstr(status));
+ return False;
+ }
+
+ status = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name3, 2);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to create full surrogate - %s\n",
+ nt_errstr(status));
+ return False;
+ }
+
+ return True;
+}
+
+/*
+ see if the server recognises wide-a characters
+*/
+static BOOL test_widea(struct cli_state *cli, TALLOC_CTX *mem_ctx)
+{
+ const uint32 name1[] = {'a'};
+ const uint32 name2[] = {0xff41};
+ const uint32 name3[] = {0xff21};
+ NTSTATUS status;
+
+ printf("Testing wide-a\n");
+
+ status = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to create 'a' - %s\n",
+ nt_errstr(status));
+ return False;
+ }
+
+ status = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to create wide-a - %s\n",
+ nt_errstr(status));
+ return False;
+ }
+
+ status = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name3, 1);
+
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
+ printf("Expected %s creating wide-A - %s\n",
+ nt_errstr(NT_STATUS_OBJECT_NAME_COLLISION),
+ nt_errstr(status));
+ return False;
+ }
+
+ return True;
+}
+
+BOOL torture_charset(int dummy)
+{
+ static struct cli_state *cli;
+ BOOL ret = True;
+ TALLOC_CTX *mem_ctx;
+
+ mem_ctx = talloc_init("torture_charset");
+
+ if (!torture_open_connection(&cli)) {
+ return False;
+ }
+
+ printf("Starting charset tests\n");
+
+ if (cli_deltree(cli->tree, BASEDIR) == -1) {
+ printf("Failed to clean " BASEDIR "\n");
+ return False;
+ }
+ if (NT_STATUS_IS_ERR(cli_mkdir(cli->tree, BASEDIR))) {
+ printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli->tree));
+ return False;
+ }
+
+ if (!test_composed(cli, mem_ctx)) {
+ ret = False;
+ }
+
+ if (!test_diacritical(cli, mem_ctx)) {
+ ret = False;
+ }
+
+ if (!test_surrogate(cli, mem_ctx)) {
+ ret = False;
+ }
+
+ if (!test_widea(cli, mem_ctx)) {
+ ret = False;
+ }
+
+ return ret;
+}
diff --git a/source4/torture/denytest.c b/source4/torture/basic/denytest.c
index 0e4f5251da..0e4f5251da 100644
--- a/source4/torture/denytest.c
+++ b/source4/torture/basic/denytest.c
diff --git a/source4/torture/dfstest.c b/source4/torture/basic/dfstest.c
index 79d49aded3..79d49aded3 100644
--- a/source4/torture/dfstest.c
+++ b/source4/torture/basic/dfstest.c
diff --git a/source4/torture/mangle_test.c b/source4/torture/basic/mangle_test.c
index 94dac45b9d..94dac45b9d 100644
--- a/source4/torture/mangle_test.c
+++ b/source4/torture/basic/mangle_test.c
diff --git a/source4/torture/scanner.c b/source4/torture/basic/scanner.c
index 7368528200..7368528200 100644
--- a/source4/torture/scanner.c
+++ b/source4/torture/basic/scanner.c
diff --git a/source4/torture/utable.c b/source4/torture/basic/utable.c
index ec37edab82..ec37edab82 100644
--- a/source4/torture/utable.c
+++ b/source4/torture/basic/utable.c
diff --git a/source4/torture/config.m4 b/source4/torture/config.m4
index f7ad78611c..f2fb4cbac2 100755
--- a/source4/torture/config.m4
+++ b/source4/torture/config.m4
@@ -19,9 +19,14 @@ SMB_SUBSYSTEM(TORTURE_RPC,[],
SMB_SUBSYSTEM(TORTURE_NBENCH,[],
[torture/nbench/nbio.o torture/nbench/nbench.o])
+SMB_SUBSYSTEM(TORTURE_BASIC,[],
+ [torture/basic/scanner.o torture/basic/utable.o \
+ torture/basic/charset.o torture/basic/mangle_test.o \
+ torture/basic/denytest.o \
+ torture/basic/aliases.o])
+
SMB_SUBSYSTEM(TORTURE,[],
- [torture/torture.o torture/torture_util.o torture/scanner.o \
- torture/utable.o torture/denytest.o torture/mangle_test.o \
- torture/aliases.o libcli/raw/clirewrite.o \$(TORTURE_RAW_OBJS) \
- \$(TORTURE_RPC_OBJS) \$(TORTURE_NBENCH_OBJS)],
+ [torture/torture.o torture/torture_util.o \
+ libcli/raw/clirewrite.o \$(TORTURE_RAW_OBJS) \
+ \$(TORTURE_RPC_OBJS) \$(TORTURE_NBENCH_OBJS) \$(TORTURE_BASIC_OBJS)],
torture/torture_public_proto.h)
diff --git a/source4/torture/nbench/nbio.c b/source4/torture/nbench/nbio.c
index 608e87e681..99393df7df 100644
--- a/source4/torture/nbench/nbio.c
+++ b/source4/torture/nbench/nbio.c
@@ -227,7 +227,7 @@ void nb_createx(const char *fname,
SA_RIGHT_FILE_WRITE_DATA |
SA_RIGHT_FILE_READ_ATTRIBUTES |
SA_RIGHT_FILE_WRITE_ATTRIBUTES;
- flags = NTCREATEX_FLAGS_EXTENDED \
+ flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
}
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index 5caabc87ed..5c1ede6919 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -3927,6 +3927,7 @@ static struct {
{"MANGLE", torture_mangle, 0},
{"UTABLE", torture_utable, 0},
{"CASETABLE", torture_casetable, 0},
+ {"CHARSET", torture_charset, 0},
{"PIPE_NUMBER", run_pipe_number, 0},
{"IOCTL", torture_ioctl_test, 0},
{"CHKPATH", torture_chkpath_test, 0},