Merge torture tests from HEAD - it looks like we had rather an incomplete
authorAndrew Bartlett <abartlet@samba.org>
Wed, 23 Apr 2003 08:12:34 +0000 (08:12 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 23 Apr 2003 08:12:34 +0000 (08:12 +0000)
merge last time.  I hope this might fix a few failures on the build farm too.

Andrew Bartlett
(This used to be commit 0c837126923cc30fa60223a5a68d4f527971cc7b)

source3/libsmb/clifile.c
source3/torture/denytest.c
source3/torture/mangle_test.c
source3/torture/masktest.c
source3/torture/nbio.c
source3/torture/scanner.c
source3/torture/torture.c
source3/torture/utable.c

index 1163b752b1d597a3b13a076cbdb7205f21645b19..b771e135f4e52cc5430fcfeef62acbe27612fa52 100644 (file)
@@ -945,7 +945,6 @@ BOOL cli_setatr(struct cli_state *cli, const char *fname, uint16 attr, time_t t)
 /****************************************************************************
  Check for existance of a dir.
 ****************************************************************************/
-
 BOOL cli_chkpath(struct cli_state *cli, const char *path)
 {
        pstring path2;
@@ -1052,3 +1051,34 @@ int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path)
 
        return SVAL(cli->inbuf,smb_vwv0);
 }
+
+
+/* 
+   send a raw ioctl - used by the torture code
+*/
+NTSTATUS cli_raw_ioctl(struct cli_state *cli, int fnum, uint32 code, DATA_BLOB *blob)
+{
+       memset(cli->outbuf,'\0',smb_size);
+       memset(cli->inbuf,'\0',smb_size);
+
+       set_message(cli->outbuf, 3, 0, True);
+       SCVAL(cli->outbuf,smb_com,SMBioctl);
+       cli_setup_packet(cli);
+
+       SSVAL(cli->outbuf, smb_vwv0, fnum);
+       SSVAL(cli->outbuf, smb_vwv1, code>>16);
+       SSVAL(cli->outbuf, smb_vwv2, (code&0xFFFF));
+
+       cli_send_smb(cli);
+       if (!cli_receive_smb(cli)) {
+               return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
+       }
+
+       if (cli_is_error(cli)) {
+               return cli_nt_error(cli);
+       }
+
+       *blob = data_blob(NULL, 0);
+
+       return NT_STATUS_OK;
+}
index 017bb1c06d6bedac9b0e769d598a499c3c94f1f0..3a7906fb33b3e091e2ee4bc10fc22836a86ac416 100644 (file)
@@ -1408,7 +1408,7 @@ static void progress_bar(unsigned i, unsigned total)
  */
 BOOL torture_denytest1(int dummy)
 {
-       static struct cli_state cli1;
+       struct cli_state *cli1;
        int fnum1, fnum2;
        int i;
        BOOL correct = True;
@@ -1421,10 +1421,10 @@ BOOL torture_denytest1(int dummy)
        printf("starting denytest1\n");
 
        for (i=0;i<2;i++) {
-               cli_unlink(&cli1, fnames[i]);
-               fnum1 = cli_open(&cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
-               cli_write(&cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
-               cli_close(&cli1, fnum1);
+               cli_unlink(cli1, fnames[i]);
+               fnum1 = cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
+               cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
+               cli_close(cli1, fnum1);
        }
 
        printf("testing %d entries\n", ARRAY_SIZE(denytable1));
@@ -1435,10 +1435,10 @@ BOOL torture_denytest1(int dummy)
 
                progress_bar(i, ARRAY_SIZE(denytable1));
 
-               fnum1 = cli_open(&cli1, fname, 
+               fnum1 = cli_open(cli1, fname, 
                                 denytable1[i].mode1,
                                 denytable1[i].deny1);
-               fnum2 = cli_open(&cli1, fname, 
+               fnum2 = cli_open(cli1, fname, 
                                 denytable1[i].mode2,
                                 denytable1[i].deny2);
 
@@ -1449,10 +1449,10 @@ BOOL torture_denytest1(int dummy)
                } else {
                        char x = 1;
                        res = A_0;
-                       if (cli_read(&cli1, fnum2, (void *)&x, 0, 1) == 1) {
+                       if (cli_read(cli1, fnum2, (void *)&x, 0, 1) == 1) {
                                res += A_R;
                        }
-                       if (cli_write(&cli1, fnum2, 0, (void *)&x, 0, 1) == 1) {
+                       if (cli_write(cli1, fnum2, 0, (void *)&x, 0, 1) == 1) {
                                res += A_W;
                        }
                }
@@ -1472,15 +1472,15 @@ BOOL torture_denytest1(int dummy)
                               resultstr(denytable1[i].result));
                }
 
-               cli_close(&cli1, fnum1);
-               cli_close(&cli1, fnum2);
+               cli_close(cli1, fnum1);
+               cli_close(cli1, fnum2);
        }
 
        for (i=0;i<2;i++) {
-               cli_unlink(&cli1, fnames[i]);
+               cli_unlink(cli1, fnames[i]);
        }
                
-       if (!torture_close_connection(&cli1)) {
+       if (!torture_close_connection(cli1)) {
                correct = False;
        }
        
@@ -1494,7 +1494,7 @@ BOOL torture_denytest1(int dummy)
  */
 BOOL torture_denytest2(int dummy)
 {
-       static struct cli_state cli1, cli2;
+       static struct cli_state *cli1, *cli2;
        int fnum1, fnum2;
        int i;
        BOOL correct = True;
@@ -1507,10 +1507,10 @@ BOOL torture_denytest2(int dummy)
        printf("starting denytest2\n");
 
        for (i=0;i<2;i++) {
-               cli_unlink(&cli1, fnames[i]);
-               fnum1 = cli_open(&cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
-               cli_write(&cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
-               cli_close(&cli1, fnum1);
+               cli_unlink(cli1, fnames[i]);
+               fnum1 = cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
+               cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
+               cli_close(cli1, fnum1);
        }
 
        for (i=0; i<ARRAY_SIZE(denytable2); i++) {
@@ -1519,10 +1519,10 @@ BOOL torture_denytest2(int dummy)
 
                progress_bar(i, ARRAY_SIZE(denytable1));
 
-               fnum1 = cli_open(&cli1, fname, 
+               fnum1 = cli_open(cli1, fname, 
                                 denytable2[i].mode1,
                                 denytable2[i].deny1);
-               fnum2 = cli_open(&cli2, fname, 
+               fnum2 = cli_open(cli2, fname, 
                                 denytable2[i].mode2,
                                 denytable2[i].deny2);
 
@@ -1533,10 +1533,10 @@ BOOL torture_denytest2(int dummy)
                } else {
                        char x = 1;
                        res = A_0;
-                       if (cli_read(&cli2, fnum2, (void *)&x, 0, 1) == 1) {
+                       if (cli_read(cli2, fnum2, (void *)&x, 0, 1) == 1) {
                                res += A_R;
                        }
-                       if (cli_write(&cli2, fnum2, 0, (void *)&x, 0, 1) == 1) {
+                       if (cli_write(cli2, fnum2, 0, (void *)&x, 0, 1) == 1) {
                                res += A_W;
                        }
                }
@@ -1556,18 +1556,18 @@ BOOL torture_denytest2(int dummy)
                               resultstr(denytable2[i].result));
                }
 
-               cli_close(&cli1, fnum1);
-               cli_close(&cli2, fnum2);
+               cli_close(cli1, fnum1);
+               cli_close(cli2, fnum2);
        }
                
        for (i=0;i<2;i++) {
-               cli_unlink(&cli1, fnames[i]);
+               cli_unlink(cli1, fnames[i]);
        }
 
-       if (!torture_close_connection(&cli1)) {
+       if (!torture_close_connection(cli1)) {
                correct = False;
        }
-       if (!torture_close_connection(&cli2)) {
+       if (!torture_close_connection(cli2)) {
                correct = False;
        }
        
index 6d127a918ebc377a89ce36e640f3d5cbfb3c9bd3..e4ccfc1b834361d5746d8df6ee5b004c93284474 100644 (file)
@@ -107,7 +107,7 @@ static BOOL test_one(struct cli_state *cli, const char *name)
 
 static void gen_name(char *name)
 {
-       const char *chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-$~...";
+       const char *chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-$~... ";
        unsigned max_idx = strlen(chars);
        unsigned len;
        int i;
@@ -135,7 +135,12 @@ static void gen_name(char *name)
 
        /* and a medium probability of a common lead string */
        if (random() % 10 == 0) {
-               strncpy(p, "ABCDE", 5);
+               if (strlen(p) <= 5) {
+                       fstrcpy(p, "ABCDE");
+               } else {
+                       /* try not to kill off the null termination */
+                       memcpy(p, "ABCDE", 5);
+               }
        }
 
        /* and a high probability of a good extension length */
@@ -151,8 +156,9 @@ static void gen_name(char *name)
 BOOL torture_mangle(int dummy)
 {
        extern int torture_numops;
-       static struct cli_state cli;
+       static struct cli_state *cli;
        int i;
+       BOOL ret = True;
 
        printf("starting mangle test\n");
 
@@ -167,20 +173,22 @@ BOOL torture_mangle(int dummy)
                return False;
        }
 
-       cli_unlink(&cli, "\\mangle_test\\*");
-       cli_rmdir(&cli, "\\mangle_test");
+       cli_unlink(cli, "\\mangle_test\\*");
+       cli_rmdir(cli, "\\mangle_test");
 
-       if (!cli_mkdir(&cli, "\\mangle_test")) {
+       if (!cli_mkdir(cli, "\\mangle_test")) {
                printf("ERROR: Failed to make directory\n");
                return False;
        }
 
        for (i=0;i<torture_numops;i++) {
                fstring name;
+               ZERO_STRUCT(name);
 
                gen_name(name);
-
-               if (!test_one(&cli, name)) {
+               
+               if (!test_one(cli, name)) {
+                       ret = False;
                        break;
                }
                if (total && total % 100 == 0) {
@@ -189,8 +197,8 @@ BOOL torture_mangle(int dummy)
                }
        }
 
-       cli_unlink(&cli, "\\mangle_test\\*");
-       if (!cli_rmdir(&cli, "\\mangle_test")) {
+       cli_unlink(cli, "\\mangle_test\\*");
+       if (!cli_rmdir(cli, "\\mangle_test")) {
                printf("ERROR: Failed to remove directory\n");
                return False;
        }
@@ -198,8 +206,8 @@ BOOL torture_mangle(int dummy)
        printf("\nTotal collisions %u/%u  - %.2f%%   (%u failures)\n",
               collisions, total, (100.0*collisions) / total, failures);
 
-       torture_close_connection(&cli);
+       torture_close_connection(cli);
 
        printf("mangle test finished\n");
-       return (failures == 0);
+       return (ret && (failures == 0));
 }
index 7d751fb789ae5f537f59d2335be6b371b5060615..06dead3f16f26a70e2e3a745ff88a2621e74e54f 100644 (file)
@@ -33,6 +33,7 @@ static const char *filechars = "abcdefghijklm.";
 static int verbose;
 static int die_on_error;
 static int NumLoops = 0;
+static int ignore_dot_errors = 0;
 
 /* a test fn for LANMAN mask support */
 int ms_fnmatch_lanman_core(const char *pattern, const char *string)
@@ -324,7 +325,9 @@ static void testpair(struct cli_state *cli, char *mask, char *file)
 
        res2 = reg_test(cli, mask, long_name, short_name);
 
-       if (showall || strcmp(res1, res2)) {
+       if (showall || 
+           ((strcmp(res1, res2) && !ignore_dot_errors) ||
+            (strcmp(res1+2, res2+2) && ignore_dot_errors))) {
                DEBUG(0,("%s %s %d mask=[%s] file=[%s] rfile=[%s/%s]\n",
                         res1, res2, count, mask, file, long_name, short_name));
                if (die_on_error) exit(1);
@@ -409,6 +412,7 @@ static void usage(void)
        -v                             verbose mode\n\
        -E                             die on error\n\
         -a                             show all tests\n\
+        -i                             ignore . and .. errors\n\
 \n\
   This program tests wildcard matching between two servers. It generates\n\
   random pairs of filenames/masks and tests that they match in the same\n\
@@ -461,7 +465,7 @@ static void usage(void)
 
        seed = time(NULL);
 
-       while ((opt = getopt(argc, argv, "n:d:U:s:hm:f:aoW:M:vE")) != EOF) {
+       while ((opt = getopt(argc, argv, "n:d:U:s:hm:f:aoW:M:vEi")) != EOF) {
                switch (opt) {
                case 'n':
                        NumLoops = atoi(optarg);
@@ -472,6 +476,9 @@ static void usage(void)
                case 'E':
                        die_on_error = 1;
                        break;
+               case 'i':
+                       ignore_dot_errors = 1;
+                       break;
                case 'v':
                        verbose++;
                        break;
index d8d3ca0c098216de60aebfa1f2f80c4fd7ef8ea2..6c51db3cf3020f93104d836a0f6a74d501338d5a 100644 (file)
@@ -125,7 +125,7 @@ void nb_setup(struct cli_state *cli)
 }
 
 
-void nb_unlink(char *fname)
+void nb_unlink(const char *fname)
 {
        if (!cli_unlink(c, fname)) {
 #if NBDEBUG
@@ -136,7 +136,7 @@ void nb_unlink(char *fname)
 }
 
 
-void nb_createx(char *fname, 
+void nb_createx(const char *fname, 
                unsigned create_options, unsigned create_disposition, int handle)
 {
        int fd, i;
@@ -217,7 +217,7 @@ void nb_close(int handle)
        ftable[i].handle = 0;
 }
 
-void nb_rmdir(char *fname)
+void nb_rmdir(const char *fname)
 {
        if (!cli_rmdir(c, fname)) {
                printf("ERROR: rmdir %s failed (%s)\n", 
@@ -226,7 +226,7 @@ void nb_rmdir(char *fname)
        }
 }
 
-void nb_rename(char *old, char *new)
+void nb_rename(const char *old, const char *new)
 {
        if (!cli_rename(c, old, new)) {
                printf("ERROR: rename %s %s failed (%s)\n", 
@@ -236,7 +236,7 @@ void nb_rename(char *old, char *new)
 }
 
 
-void nb_qpathinfo(char *fname)
+void nb_qpathinfo(const char *fname)
 {
        cli_qpathinfo(c, fname, NULL, NULL, NULL, NULL, NULL);
 }
@@ -260,7 +260,7 @@ static void find_fn(file_info *finfo, const char *name, void *state)
        /* noop */
 }
 
-void nb_findfirst(char *mask)
+void nb_findfirst(const char *mask)
 {
        cli_list(c, mask, 0, find_fn, NULL);
 }
@@ -295,7 +295,7 @@ static void delete_fn(file_info *finfo, const char *name, void *state)
        free(n);
 }
 
-void nb_deltree(char *dname)
+void nb_deltree(const char *dname)
 {
        char *mask;
        asprintf(&mask, "%s\\*", dname);
index 7db3dde9c09fb596b65c50693dcb7fc224f10a2f..93f89c105cf667700be040356e2fb54ee8ffaf0d 100644 (file)
@@ -191,7 +191,7 @@ static BOOL scan_trans2(struct cli_state *cli, int op, int level,
 
 BOOL torture_trans2_scan(int dummy)
 {
-       static struct cli_state cli;
+       static struct cli_state *cli;
        int op, level;
        const char *fname = "\\scanner.dat";
        int fnum, dnum;
@@ -202,26 +202,26 @@ BOOL torture_trans2_scan(int dummy)
                return False;
        }
 
-       fnum = cli_open(&cli, fname, O_RDWR | O_CREAT | O_TRUNC, 
+       fnum = cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC, 
                         DENY_NONE);
-       dnum = cli_open(&cli, "\\", O_RDONLY, DENY_NONE);
+       dnum = cli_open(cli, "\\", O_RDONLY, DENY_NONE);
 
        for (op=OP_MIN; op<=OP_MAX; op++) {
                printf("Scanning op=%d\n", op);
                for (level = 0; level <= 50; level++) {
-                       scan_trans2(&cli, op, level, fnum, dnum, fname);
+                       scan_trans2(cli, op, level, fnum, dnum, fname);
                }
 
                for (level = 0x100; level <= 0x130; level++) {
-                       scan_trans2(&cli, op, level, fnum, dnum, fname);
+                       scan_trans2(cli, op, level, fnum, dnum, fname);
                }
 
                for (level = 1000; level < 1050; level++) {
-                       scan_trans2(&cli, op, level, fnum, dnum, fname);
+                       scan_trans2(cli, op, level, fnum, dnum, fname);
                }
        }
 
-       torture_close_connection(&cli);
+       torture_close_connection(cli);
 
        printf("trans2 scan finished\n");
        return True;
@@ -393,7 +393,7 @@ static BOOL scan_nttrans(struct cli_state *cli, int op, int level,
 
 BOOL torture_nttrans_scan(int dummy)
 {
-       static struct cli_state cli;
+       static struct cli_state *cli;
        int op, level;
        const char *fname = "\\scanner.dat";
        int fnum, dnum;
@@ -404,26 +404,26 @@ BOOL torture_nttrans_scan(int dummy)
                return False;
        }
 
-       fnum = cli_open(&cli, fname, O_RDWR | O_CREAT | O_TRUNC, 
+       fnum = cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC, 
                         DENY_NONE);
-       dnum = cli_open(&cli, "\\", O_RDONLY, DENY_NONE);
+       dnum = cli_open(cli, "\\", O_RDONLY, DENY_NONE);
 
        for (op=OP_MIN; op<=OP_MAX; op++) {
                printf("Scanning op=%d\n", op);
                for (level = 0; level <= 50; level++) {
-                       scan_nttrans(&cli, op, level, fnum, dnum, fname);
+                       scan_nttrans(cli, op, level, fnum, dnum, fname);
                }
 
                for (level = 0x100; level <= 0x130; level++) {
-                       scan_nttrans(&cli, op, level, fnum, dnum, fname);
+                       scan_nttrans(cli, op, level, fnum, dnum, fname);
                }
 
                for (level = 1000; level < 1050; level++) {
-                       scan_nttrans(&cli, op, level, fnum, dnum, fname);
+                       scan_nttrans(cli, op, level, fnum, dnum, fname);
                }
        }
 
-       torture_close_connection(&cli);
+       torture_close_connection(cli);
 
        printf("nttrans scan finished\n");
        return True;
index dfeb5a875dacf2be3d51561bbeb4390b2a84d059..740fae44251474f82034e355b6d79b67866ef5e0 100644 (file)
@@ -499,18 +499,21 @@ static BOOL rw_torture2(struct cli_state *c1, struct cli_state *c2)
                if (cli_write(c1, fnum1, 0, buf, 0, buf_size) != buf_size) {
                        printf("write failed (%s)\n", cli_errstr(c1));
                        correct = False;
+                       break;
                }
 
                if ((bytes_read = cli_read(c2, fnum2, buf_rd, 0, buf_size)) != buf_size) {
                        printf("read failed (%s)\n", cli_errstr(c2));
                        printf("read %d, expected %d\n", bytes_read, buf_size); 
                        correct = False;
+                       break;
                }
 
                if (memcmp(buf_rd, buf, buf_size) != 0)
                {
                        printf("read/write compare failed\n");
                        correct = False;
+                       break;
                }
        }
 
@@ -547,8 +550,10 @@ static BOOL run_readwritetest(int dummy)
        test1 = rw_torture2(cli1, cli2);
        printf("Passed readwritetest v1: %s\n", BOOLSTR(test1));
 
-       test2 = rw_torture2(cli1, cli1);
-       printf("Passed readwritetest v2: %s\n", BOOLSTR(test2));
+       if (test1) {
+               test2 = rw_torture2(cli1, cli1);
+               printf("Passed readwritetest v2: %s\n", BOOLSTR(test2));
+       }
 
        if (!torture_close_connection(cli1)) {
                test1 = False;
@@ -568,12 +573,12 @@ static BOOL run_readwritemulti(int dummy)
 
        cli = current_cli;
 
-       cli_sockopt(&cli, sockops);
+       cli_sockopt(cli, sockops);
 
        printf("run_readwritemulti: fname %s\n", randomfname);
-       test = rw_torture3(&cli, randomfname);
+       test = rw_torture3(cli, randomfname);
 
-       if (!torture_close_connection(&cli)) {
+       if (!torture_close_connection(cli)) {
                test = False;
        }
        
@@ -692,7 +697,7 @@ static BOOL run_netbench(int client)
        pstring line;
        char cname[20];
        FILE *f;
-       char *params[20];
+       const char *params[20];
        BOOL correct = True;
 
        cli = current_cli;
@@ -4075,6 +4080,60 @@ static void del_fn(file_info *finfo, const char *mask, void *state)
 }
 
 
+/*
+  sees what IOCTLs are supported
+ */
+BOOL torture_ioctl_test(int dummy)
+{
+       static struct cli_state *cli;
+       uint16 device, function;
+       int fnum;
+       const char *fname = "\\ioctl.dat";
+       DATA_BLOB blob;
+       NTSTATUS status;
+
+       if (!torture_open_connection(&cli)) {
+               return False;
+       }
+
+       printf("starting ioctl test\n");
+
+       cli_unlink(cli, fname);
+
+       fnum = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+       if (fnum == -1) {
+               printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+               return False;
+       }
+
+       status = cli_raw_ioctl(cli, fnum, 0x2d0000 | (0x0420<<2), &blob);
+       printf("ioctl device info: %s\n", cli_errstr(cli));
+
+       status = cli_raw_ioctl(cli, fnum, IOCTL_QUERY_JOB_INFO, &blob);
+       printf("ioctl job info: %s\n", cli_errstr(cli));
+
+       for (device=0;device<0x100;device++) {
+               printf("testing device=0x%x\n", device);
+               for (function=0;function<0x100;function++) {
+                       uint32 code = (device<<16) | function;
+
+                       status = cli_raw_ioctl(cli, fnum, code, &blob);
+
+                       if (NT_STATUS_IS_OK(status)) {
+                               printf("ioctl 0x%x OK : %d bytes\n", code, blob.length);
+                               data_blob_free(&blob);
+                       }
+               }
+       }
+
+       if (!torture_close_connection(cli)) {
+               return False;
+       }
+
+       return True;
+}
+
+
 /*
   tries varients of chkpath
  */
@@ -4494,6 +4553,7 @@ static struct {
        {"ERRMAPEXTRACT", run_error_map_extract, 0},
        {"PIPE_NUMBER", run_pipe_number, 0},
        {"TCON2",  run_tcon2_test, 0},
+       {"IOCTL",  torture_ioctl_test, 0},
        {"CHKPATH",  torture_chkpath_test, 0},
        {"FDSESS", run_fdsesstest, 0},
        {NULL, NULL, 0}};
index 720614cea37a51b6fc1b91f0123a9cb43e904818..3ec5932b79140f7e897c686caf76f7c63fa83f26 100644 (file)
@@ -24,7 +24,7 @@
 
 BOOL torture_utable(int dummy)
 {
-       static struct cli_state cli;
+       struct cli_state *cli;
        fstring fname, alt_name;
        int fnum;
        smb_ucs2_t c2;
@@ -40,8 +40,8 @@ BOOL torture_utable(int dummy)
 
        memset(valid, 0, sizeof(valid));
 
-       cli_mkdir(&cli, "\\utable");
-       cli_unlink(&cli, "\\utable\\*");
+       cli_mkdir(cli, "\\utable");
+       cli_unlink(cli, "\\utable\\*");
 
        for (c=1; c < 0x10000; c++) {
                char *p;
@@ -55,13 +55,13 @@ BOOL torture_utable(int dummy)
                p[len] = 0;
                fstrcat(fname,"_a_long_extension");
 
-               fnum = cli_open(&cli, fname, O_RDWR | O_CREAT | O_TRUNC, 
+               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);
+               cli_qpathinfo_alt_name(cli, fname, alt_name);
 
                if (strncmp(alt_name, "X_A_L", 5) != 0) {
                        alt_allowed++;
@@ -69,8 +69,8 @@ BOOL torture_utable(int dummy)
                        d_printf("fname=[%s] alt_name=[%s]\n", fname, alt_name);
                }
 
-               cli_close(&cli, fnum);
-               cli_unlink(&cli, fname);
+               cli_close(cli, fnum);
+               cli_unlink(cli, fname);
 
                if (c % 100 == 0) {
                        printf("%d (%d/%d)\r", c, chars_allowed, alt_allowed);
@@ -78,7 +78,7 @@ BOOL torture_utable(int dummy)
        }
        printf("%d (%d/%d)\n", c, chars_allowed, alt_allowed);
 
-       cli_rmdir(&cli, "\\utable");
+       cli_rmdir(cli, "\\utable");
 
        d_printf("%d chars allowed   %d alt chars allowed\n", chars_allowed, alt_allowed);
 
@@ -115,7 +115,7 @@ static char *form_name(int c)
 
 BOOL torture_casetable(int dummy)
 {
-       static struct cli_state cli;
+       static struct cli_state *cli;
        char *fname;
        int fnum;
        int c, i;
@@ -129,28 +129,35 @@ BOOL torture_casetable(int dummy)
 
        memset(equiv, 0, sizeof(equiv));
 
-       cli_mkdir(&cli, "\\utable");
-       cli_unlink(&cli, "\\utable\\*");
+       cli_unlink(cli, "\\utable\\*");
+       cli_rmdir(cli, "\\utable");
+       if (!cli_mkdir(cli, "\\utable")) {
+               printf("Failed to create utable directory!\n");
+               return False;
+       }
 
        for (c=1; c < 0x10000; c++) {
                size_t size;
 
                if (c == '.' || c == '\\') continue;
 
-               printf("%04x\n", c);
+               printf("%04x (%c)\n", c, isprint(c)?c:'.');
 
                fname = form_name(c);
-               fnum = cli_nt_create_full(&cli, fname, 0,
+               fnum = cli_nt_create_full(cli, fname, 0,
                                          GENERIC_ALL_ACCESS, 
                                          FILE_ATTRIBUTE_NORMAL,
                                          FILE_SHARE_NONE,
                                          FILE_OPEN_IF, 0, 0);
 
-               if (fnum == -1) continue;
+               if (fnum == -1) {
+                       printf("Failed to create file with char %04x\n", c);
+                       continue;
+               }
 
                size = 0;
 
-               if (!cli_qfileinfo(&cli, fnum, NULL, &size, 
+               if (!cli_qfileinfo(cli, fnum, NULL, &size, 
                                   NULL, NULL, NULL, NULL, NULL)) continue;
 
                if (size > 0) {
@@ -160,11 +167,11 @@ BOOL torture_casetable(int dummy)
                        if (size/sizeof(int) >= MAX_EQUIVALENCE) {
                                printf("too many chars match?? size=%d c=0x%04x\n",
                                       size, c);
-                               cli_close(&cli, fnum);
+                               cli_close(cli, fnum);
                                return False;
                        }
 
-                       cli_read(&cli, fnum, (char *)c2, 0, size);
+                       cli_read(cli, fnum, (char *)c2, 0, size);
                        printf("%04x: ", c);
                        equiv[c][0] = c;
                        for (i=0; i<size/sizeof(int); i++) {
@@ -175,12 +182,12 @@ BOOL torture_casetable(int dummy)
                        fflush(stdout);
                }
 
-               cli_write(&cli, fnum, 0, (char *)&c, size, sizeof(c));
-               cli_close(&cli, fnum);
+               cli_write(cli, fnum, 0, (char *)&c, size, sizeof(c));
+               cli_close(cli, fnum);
        }
 
-       cli_unlink(&cli, "\\utable\\*");
-       cli_rmdir(&cli, "\\utable");
+       cli_unlink(cli, "\\utable\\*");
+       cli_rmdir(cli, "\\utable");
 
        return True;
 }