added a little smbtorture test for dumping the unicode table of a
authorAndrew Tridgell <tridge@samba.org>
Tue, 25 Sep 2001 05:20:43 +0000 (05:20 +0000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 25 Sep 2001 05:20:43 +0000 (05:20 +0000)
server. This is just a framework right now - I want this to eventually
replace the win32 test code from monyo

The interesting this about this test is that it shows up a really
horrible performance bug in our stat cache code. I'll see if I can fix
it.

source/Makefile.in
source/include/client.h
source/lib/charcnv.c
source/torture/torture.c
source/torture/utable.c [new file with mode: 0644]

index 8dd1dbbdd1c33dc22e1b31d559067123e4e47a8f..f0236a7d78a20b14fabc9b58f71ce55b88e2f1e6 100644 (file)
@@ -320,7 +320,7 @@ UMOUNT_OBJ = client/smbumount.o \
 NMBLOOKUP_OBJ = utils/nmblookup.o $(PARAM_OBJ) $(UBIQX_OBJ) \
                 $(LIBSMB_OBJ) $(LIB_OBJ)
 
-SMBTORTURE_OBJ = torture/torture.o torture/nbio.o torture/scanner.o \
+SMBTORTURE_OBJ = torture/torture.o torture/nbio.o torture/scanner.o torture/utable.o \
                torture/denytest.o \
        $(LIBSMB_OBJ) $(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ)
 
index 61a5633b981390923d5cd01bcd169e85af03df8b..d694afd72b36de47d94fbf13adc2cc5cc8f4a18c 100644 (file)
@@ -45,7 +45,7 @@ typedef struct file_info
        time_t atime;
        time_t ctime;
        pstring name;
-       char short_name[13];
+       char short_name[13*3]; /* the *3 is to cope with multi-byte */
 } file_info;
 
 struct print_job_info
index 0e7d5241f4a1cd678c045a633cfa06ae0c636cac..5afc638a8d84e44110e4d0285b24c6bb245a60ad 100644 (file)
@@ -100,7 +100,6 @@ size_t convert_string(charset_t from, charset_t to,
        smb_iconv_t descriptor;
 
        if (srclen == -1) srclen = strlen(src)+1;
-       if (destlen == -1) destlen = strlen(dest)+1;
 
        if (!initialised) {
                initialised = 1;
index 33260dcc544f6543426de8ace2021f6fa804d50f..a34f9aa085312bc57b350d4efd46390282a40e18 100644 (file)
@@ -424,7 +424,7 @@ static BOOL rw_torture3(struct cli_state *c, char *lockfname)
 
 static BOOL rw_torture2(struct cli_state *c1, struct cli_state *c2)
 {
-       char *lockfname = "\\torture.lck";
+       char *lockfname = "\\torture2.lck";
        int fnum1;
        int fnum2;
        int i;
@@ -2989,6 +2989,7 @@ static struct {
        {"W2K", run_w2ktest, 0},
        {"TRANS2SCAN", torture_trans2_scan, 0},
        {"NTTRANSSCAN", torture_nttrans_scan, 0},
+       {"UTABLE", torture_utable, 0},
        {NULL, NULL, 0}};
 
 
diff --git a/source/torture/utable.c b/source/torture/utable.c
new file mode 100644 (file)
index 0000000..c710815
--- /dev/null
@@ -0,0 +1,82 @@
+/* 
+   Unix SMB/Netbios implementation.
+   Version 3.0
+   SMB torture tester - unicode table dumper
+   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.
+*/
+
+#define NO_SYSLOG
+
+#include "includes.h"
+
+BOOL torture_utable(int dummy)
+{
+       static struct cli_state cli;
+       fstring fname, alt_name;
+       int fnum;
+       smb_ucs2_t c2;
+       int c, len;
+       int chars_allowed=0, alt_allowed=0;
+
+       printf("starting utable\n");
+
+       if (!torture_open_connection(&cli)) {
+               return False;
+       }
+
+       cli_mkdir(&cli, "\\utable");
+
+       for (c=1; c < 0x10000; c++) {
+               char *p;
+
+               SSVAL(&c2, 0, c);
+               fstrcpy(fname, "\\utable\\x");
+               p = fname+strlen(fname);
+               len = convert_string(CH_UCS2, CH_UNIX, 
+                                    &c2, 2, 
+                                    p, sizeof(fname)-strlen(fname));
+               p[len] = 0;
+               fstrcat(fname,"_a_long_extension");
+
+               fnum = cli_open(&cli, fname, O_RDWR | O_CREAT | O_TRUNC, 
+                               DENY_NONE);
+               if (fnum == -1) continue;
+
+               chars_allowed++;
+
+               cli_qpathinfo_alt_name(&cli, fname, alt_name);
+
+               if (strncmp(alt_name, "X_A_L", 5) != 0) {
+                       alt_allowed++;
+                       /* d_printf("fname=[%s] alt_name=[%s]\n", fname, alt_name); */
+               }
+
+               cli_close(&cli, fnum);
+               cli_unlink(&cli, fname);
+
+               if (c % 100 == 0) {
+                       printf("%d (%d/%d)\r", c, chars_allowed, alt_allowed);
+               }
+       }
+       printf("%d (%d/%d)\n", c, chars_allowed, alt_allowed);
+
+       cli_rmdir(&cli, "\\utable");
+
+       d_printf("%d chars allowed   %d alt chars allowed\n", chars_allowed, alt_allowed);
+
+       return True;
+}