s3: Add two notify benchmark tests
[kai/samba.git] / source3 / torture / torture.c
index 4a5f7908a314a40c859e34a3bf38634fdf10ad7a..6d60136dae6208dc8e2a4803ee0433ce929c5bd0 100644 (file)
@@ -47,7 +47,7 @@ extern int optind;
 fstring host, workgroup, share, password, username, myname;
 static int max_protocol = PROTOCOL_NT1;
 static const char *sockops="TCP_NODELAY";
-static int nprocs=1;
+int torture_nprocs=1;
 static int port_to_use=0;
 int torture_numops=100;
 int torture_blocksize=1024*1024;
@@ -610,10 +610,10 @@ static bool rw_torture(struct cli_state *c)
 
        memset(buf, '\0', sizeof(buf));
 
-       status = cli_open(c, lockfname, O_RDWR | O_CREAT | O_EXCL, 
+       status = cli_openx(c, lockfname, O_RDWR | O_CREAT | O_EXCL, 
                         DENY_NONE, &fnum2);
        if (!NT_STATUS_IS_OK(status)) {
-               status = cli_open(c, lockfname, O_RDWR, DENY_NONE, &fnum2);
+               status = cli_openx(c, lockfname, O_RDWR, DENY_NONE, &fnum2);
        }
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n",
@@ -633,7 +633,7 @@ static bool rw_torture(struct cli_state *c)
                        return False;
                }
 
-               status = cli_open(c, fname, O_RDWR | O_CREAT | O_TRUNC,
+               status = cli_openx(c, fname, O_RDWR | O_CREAT | O_TRUNC,
                                   DENY_ALL, &fnum);
                if (!NT_STATUS_IS_OK(status)) {
                        printf("open failed (%s)\n", nt_errstr(status));
@@ -751,7 +751,7 @@ static bool rw_torture3(struct cli_state *c, char *lockfname)
                               "not exist)\n", nt_errstr(status));
                }
 
-               status = cli_open(c, lockfname, O_RDWR | O_CREAT | O_EXCL,
+               status = cli_openx(c, lockfname, O_RDWR | O_CREAT | O_EXCL,
                                  DENY_NONE, &fnum);
                if (!NT_STATUS_IS_OK(status)) {
                        printf("first open read/write of %s failed (%s)\n",
@@ -763,7 +763,7 @@ static bool rw_torture3(struct cli_state *c, char *lockfname)
        {
                for (i = 0; i < 500 && fnum == (uint16_t)-1; i++)
                {
-                       status = cli_open(c, lockfname, O_RDONLY, 
+                       status = cli_openx(c, lockfname, O_RDONLY, 
                                         DENY_NONE, &fnum);
                        if (!NT_STATUS_IS_OK(status)) {
                                break;
@@ -852,7 +852,7 @@ static bool rw_torture2(struct cli_state *c1, struct cli_state *c2)
                printf("unlink failed (%s) (normal, this file should not exist)\n", nt_errstr(status));
        }
 
-       status = cli_open(c1, lockfname, O_RDWR | O_CREAT | O_EXCL,
+       status = cli_openx(c1, lockfname, O_RDWR | O_CREAT | O_EXCL,
                          DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("first open read/write of %s failed (%s)\n",
@@ -860,7 +860,7 @@ static bool rw_torture2(struct cli_state *c1, struct cli_state *c2)
                return False;
        }
 
-       status = cli_open(c2, lockfname, O_RDONLY, DENY_NONE, &fnum2);
+       status = cli_openx(c2, lockfname, O_RDONLY, DENY_NONE, &fnum2);
        if (!NT_STATUS_IS_OK(status)) {
                printf("second open read-only of %s failed (%s)\n",
                                lockfname, nt_errstr(status));
@@ -984,7 +984,7 @@ static bool run_readwritelarge_internal(void)
        static struct cli_state *cli1;
        uint16_t fnum1;
        const char *lockfname = "\\large.dat";
-       SMB_OFF_T fsize;
+       off_t fsize;
        char buf[126*1024];
        bool correct = True;
        NTSTATUS status;
@@ -999,7 +999,7 @@ static bool run_readwritelarge_internal(void)
 
        cli_unlink(cli1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-       status = cli_open(cli1, lockfname, O_RDWR | O_CREAT | O_EXCL,
+       status = cli_openx(cli1, lockfname, O_RDWR | O_CREAT | O_EXCL,
                          DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open read/write of %s failed (%s)\n", lockfname, nt_errstr(status));
@@ -1036,7 +1036,7 @@ static bool run_readwritelarge_internal(void)
                correct = False;
        }
 
-       status = cli_open(cli1, lockfname, O_RDWR | O_CREAT | O_EXCL,
+       status = cli_openx(cli1, lockfname, O_RDWR | O_CREAT | O_EXCL,
                          DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open read/write of %s failed (%s)\n", lockfname, nt_errstr(status));
@@ -1211,7 +1211,7 @@ static bool run_nbench(int dummy)
        double t;
        bool correct = True;
 
-       nbio_shmem(nprocs);
+       nbio_shmem(torture_nprocs);
 
        nbio_id = -1;
 
@@ -1252,20 +1252,20 @@ static bool run_locktest1(int dummy)
 
        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-       status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
+       status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
                          &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
        }
 
-       status = cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum2);
+       status = cli_openx(cli1, fname, O_RDWR, DENY_NONE, &fnum2);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open2 of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
        }
 
-       status = cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum3);
+       status = cli_openx(cli2, fname, O_RDWR, DENY_NONE, &fnum3);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open3 of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
@@ -1384,7 +1384,7 @@ static bool run_tcon_test(int dummy)
 
        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-       status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+       status = cli_openx(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
@@ -1399,8 +1399,8 @@ static bool run_tcon_test(int dummy)
                return False;
        }
 
-       status = cli_tcon_andx(cli, share, "?????",
-                              password, strlen(password)+1);
+       status = cli_tree_connect(cli, share, "?????",
+                                 password, strlen(password)+1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("%s refused 2nd tree connect (%s)\n", host,
                       nt_errstr(status));
@@ -1525,8 +1525,8 @@ static bool tcon_devtest(struct cli_state *cli,
        NTSTATUS status;
        bool ret;
 
-       status = cli_tcon_andx(cli, myshare, devtype,
-                              password, strlen(password)+1);
+       status = cli_tree_connect(cli, myshare, devtype,
+                                 password, strlen(password)+1);
 
        if (NT_STATUS_IS_OK(expected_error)) {
                if (NT_STATUS_IS_OK(status)) {
@@ -1553,8 +1553,7 @@ static bool tcon_devtest(struct cli_state *cli,
                               myshare, devtype);
                        ret = False;
                } else {
-                       if (NT_STATUS_EQUAL(cli_nt_error(cli),
-                                           expected_error)) {
+                       if (NT_STATUS_EQUAL(status, expected_error)) {
                                ret = True;
                        } else {
                                printf("Returned unexpected error\n");
@@ -1656,13 +1655,13 @@ static bool run_locktest2(int dummy)
 
        cli_setpid(cli, 1);
 
-       status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+       status = cli_openx(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
        }
 
-       status = cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum2);
+       status = cli_openx(cli, fname, O_RDWR, DENY_NONE, &fnum2);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open2 of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
@@ -1670,7 +1669,7 @@ static bool run_locktest2(int dummy)
 
        cli_setpid(cli, 2);
 
-       status = cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum3);
+       status = cli_openx(cli, fname, O_RDWR, DENY_NONE, &fnum3);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open3 of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
@@ -1817,14 +1816,14 @@ static bool run_locktest3(int dummy)
 
        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-       status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
+       status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
                         &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
        }
 
-       status = cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum2);
+       status = cli_openx(cli2, fname, O_RDWR, DENY_NONE, &fnum2);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open2 of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
@@ -1979,8 +1978,8 @@ static bool run_locktest4(int dummy)
 
        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-       cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
-       cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum2);
+       cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+       cli_openx(cli2, fname, O_RDWR, DENY_NONE, &fnum2);
 
        memset(buf, 0, sizeof(buf));
 
@@ -2121,12 +2120,12 @@ static bool run_locktest4(int dummy)
 
        cli_close(cli1, fnum1);
        cli_close(cli2, fnum2);
-       cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1);
-       cli_open(cli1, fname, O_RDWR, DENY_NONE, &f);
+       cli_openx(cli1, fname, O_RDWR, DENY_NONE, &fnum1);
+       cli_openx(cli1, fname, O_RDWR, DENY_NONE, &f);
        ret = NT_STATUS_IS_OK(cli_lock32(cli1, fnum1, 0, 8, 0, READ_LOCK)) &&
              NT_STATUS_IS_OK(cli_lock32(cli1, f, 0, 1, 0, READ_LOCK)) &&
              NT_STATUS_IS_OK(cli_close(cli1, fnum1)) &&
-             NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1)) &&
+             NT_STATUS_IS_OK(cli_openx(cli1, fname, O_RDWR, DENY_NONE, &fnum1)) &&
              NT_STATUS_IS_OK(cli_lock32(cli1, fnum1, 7, 1, 0, WRITE_LOCK));
         cli_close(cli1, f);
        cli_close(cli1, fnum1);
@@ -2168,9 +2167,9 @@ static bool run_locktest5(int dummy)
 
        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-       cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
-       cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum2);
-       cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum3);
+       cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+       cli_openx(cli2, fname, O_RDWR, DENY_NONE, &fnum2);
+       cli_openx(cli1, fname, O_RDWR, DENY_NONE, &fnum3);
 
        memset(buf, 0, sizeof(buf));
 
@@ -2186,13 +2185,13 @@ static bool run_locktest5(int dummy)
        ret = NT_STATUS_IS_OK(cli_lock32(cli1, fnum1, 0, 8, 0, READ_LOCK)) &&
              NT_STATUS_IS_OK(cli_lock32(cli1, fnum3, 0, 1, 0, READ_LOCK));
        cli_close(cli1, fnum1);
-       cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1);
+       cli_openx(cli1, fname, O_RDWR, DENY_NONE, &fnum1);
        status = cli_lock32(cli1, fnum1, 7, 1, 0, WRITE_LOCK);
        ret = NT_STATUS_IS_OK(status);
        EXPECTED(ret, True);
        printf("this server %s the NT locking bug\n", ret ? "doesn't have" : "has");
        cli_close(cli1, fnum1);
-       cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1);
+       cli_openx(cli1, fname, O_RDWR, DENY_NONE, &fnum1);
        cli_unlock(cli1, fnum3, 0, 1);
 
        ret = NT_STATUS_IS_OK(cli_lock32(cli1, fnum1, 0, 4, 0, WRITE_LOCK)) &&
@@ -2299,12 +2298,12 @@ static bool run_locktest6(int dummy)
 
                cli_unlink(cli, fname[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-               cli_open(cli, fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
+               cli_openx(cli, fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
                status = cli_locktype(cli, fnum, 0, 8, 0, LOCKING_ANDX_CHANGE_LOCKTYPE);
                cli_close(cli, fnum);
                printf("CHANGE_LOCKTYPE gave %s\n", nt_errstr(status));
 
-               cli_open(cli, fname[i], O_RDWR, DENY_NONE, &fnum);
+               cli_openx(cli, fname[i], O_RDWR, DENY_NONE, &fnum);
                status = cli_locktype(cli, fnum, 0, 8, 0, LOCKING_ANDX_CANCEL_LOCK);
                cli_close(cli, fnum);
                printf("CANCEL_LOCK gave %s\n", nt_errstr(status));
@@ -2338,7 +2337,7 @@ static bool run_locktest7(int dummy)
 
        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-       cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+       cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
 
        memset(buf, 0, sizeof(buf));
 
@@ -2515,18 +2514,18 @@ static bool run_locktest8(int dummy)
 
        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-       status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_WRITE,
+       status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_WRITE,
                          &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
-               d_fprintf(stderr, "cli_open returned %s\n", nt_errstr(status));
+               d_fprintf(stderr, "cli_openx returned %s\n", nt_errstr(status));
                return false;
        }
 
        memset(buf, 0, sizeof(buf));
 
-       status = cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum2);
+       status = cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum2);
        if (!NT_STATUS_IS_OK(status)) {
-               d_fprintf(stderr, "cli_open second time returned %s\n",
+               d_fprintf(stderr, "cli_openx second time returned %s\n",
                          nt_errstr(status));
                goto fail;
        }
@@ -2544,9 +2543,9 @@ static bool run_locktest8(int dummy)
                goto fail;
        }
 
-       status = cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1);
+       status = cli_openx(cli1, fname, O_RDWR, DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
-               d_fprintf(stderr, "cli_open third time returned %s\n",
+               d_fprintf(stderr, "cli_openx third time returned %s\n",
                           nt_errstr(status));
                 goto fail;
         }
@@ -2706,10 +2705,10 @@ static bool run_locktest9(int dummy)
 
        cli_sockopt(cli1, sockops);
 
-       status = cli_open(cli1, fname, O_RDWR, DENY_NONE,
+       status = cli_openx(cli1, fname, O_RDWR, DENY_NONE,
                          &fnum);
        if (!NT_STATUS_IS_OK(status)) {
-               d_fprintf(stderr, "cli_open returned %s\n", nt_errstr(status));
+               d_fprintf(stderr, "cli_openx returned %s\n", nt_errstr(status));
                return false;
        }
 
@@ -2790,7 +2789,7 @@ static bool run_fdpasstest(int dummy)
 
        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-       status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
+       status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
                          &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
@@ -2846,7 +2845,7 @@ static bool run_fdsesstest(int dummy)
                return False;
 
        saved_cnum = cli_state_get_tid(cli);
-       if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, share, "?????", "", 1)))
+       if (!NT_STATUS_IS_OK(cli_tree_connect(cli, share, "?????", "", 1)))
                return False;
        new_cnum = cli_state_get_tid(cli);
        cli_state_set_tid(cli, saved_cnum);
@@ -2856,7 +2855,7 @@ static bool run_fdsesstest(int dummy)
        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
        cli_unlink(cli, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-       status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+       status = cli_openx(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
@@ -2878,7 +2877,7 @@ static bool run_fdsesstest(int dummy)
                ret = false;
        }
        /* Try to open a file with different vuid, samba cnum. */
-       if (NT_STATUS_IS_OK(cli_open(cli, fname1, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum2))) {
+       if (NT_STATUS_IS_OK(cli_openx(cli, fname1, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum2))) {
                printf("create with different vuid, same cnum succeeded.\n");
                cli_close(cli, fnum2);
                cli_unlink(cli, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
@@ -2933,7 +2932,7 @@ static bool run_unlinktest(int dummy)
 
        cli_setpid(cli, 1);
 
-       status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
+       status = cli_openx(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
@@ -2986,7 +2985,7 @@ static bool run_maxfidtest(int dummy)
 
        for (i=0; i<0x11000; i++) {
                slprintf(fname,sizeof(fname)-1,"\\maxfid.%d.%d", i,(int)getpid());
-               status = cli_open(cli, fname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE,
+               status = cli_openx(cli, fname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE,
                                  &fnums[i]);
                if (!NT_STATUS_IS_OK(status)) {
                        printf("open of %s failed (%s)\n", 
@@ -3095,7 +3094,7 @@ static bool run_bad_nbt_session(int dummy)
                return false;
        }
 
-       status = open_socket_out(&ss, 139, 10000, &fd);
+       status = open_socket_out(&ss, NBT_SMB_PORT, 10000, &fd);
        if (!NT_STATUS_IS_OK(status)) {
                d_fprintf(stderr, "open_socket_out failed: %s\n",
                          nt_errstr(status));
@@ -3225,7 +3224,7 @@ static bool run_attrtest(int dummy)
        }
 
        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
-       cli_open(cli, fname, 
+       cli_openx(cli, fname, 
                        O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
        cli_close(cli, fnum);
 
@@ -3282,7 +3281,7 @@ static bool run_trans2test(int dummy)
 {
        struct cli_state *cli;
        uint16_t fnum;
-       SMB_OFF_T size;
+       off_t size;
        time_t c_time, a_time, m_time;
        struct timespec c_time_ts, a_time_ts, m_time_ts, w_time_ts, m_time2_ts;
        const char *fname = "\\trans2.tst";
@@ -3307,7 +3306,7 @@ static bool run_trans2test(int dummy)
        }
 
        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
-       cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
+       cli_openx(cli, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
        status = cli_qfileinfo_basic(cli, fnum, NULL, &size, &c_time_ts,
                                     &a_time_ts, &w_time_ts, &m_time_ts, NULL);
        if (!NT_STATUS_IS_OK(status)) {
@@ -3332,7 +3331,7 @@ static bool run_trans2test(int dummy)
        sleep(2);
 
        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
-       status = cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE,
+       status = cli_openx(cli, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE,
                          &fnum);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
@@ -3367,7 +3366,7 @@ static bool run_trans2test(int dummy)
 
 
        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
-       cli_open(cli, fname, 
+       cli_openx(cli, fname, 
                        O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
        cli_close(cli, fnum);
        status = cli_qpathinfo2(cli, fname, &c_time_ts, &a_time_ts, &w_time_ts,
@@ -3401,7 +3400,7 @@ static bool run_trans2test(int dummy)
                correct = False;
        }
 
-       cli_open(cli, fname2, 
+       cli_openx(cli, fname2, 
                        O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
        cli_writeall(cli, fnum,  0, (uint8_t *)&fnum, 0, sizeof(fnum), NULL);
        cli_close(cli, fnum);
@@ -3467,7 +3466,7 @@ static bool run_w2ktest(int dummy)
                return False;
        }
 
-       cli_open(cli, fname, 
+       cli_openx(cli, fname, 
                        O_RDWR | O_CREAT , DENY_NONE, &fnum);
 
        for (level = 1004; level < 1040; level++) {
@@ -3509,7 +3508,7 @@ static bool run_oplock1(int dummy)
 
        cli1->use_oplocks = True;
 
-       status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
+       status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
                          &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
@@ -3579,7 +3578,7 @@ static bool run_oplock2(int dummy)
        cli_sockopt(cli1, sockops);
        cli_sockopt(cli2, sockops);
 
-       status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
+       status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
                          &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
@@ -3592,7 +3591,7 @@ static bool run_oplock2(int dummy)
 
        if (fork() == 0) {
                /* Child code */
-               status = cli_open(cli2, fname, O_RDWR, DENY_NONE, &fnum2);
+               status = cli_openx(cli2, fname, O_RDWR, DENY_NONE, &fnum2);
                if (!NT_STATUS_IS_OK(status)) {
                        printf("second open of %s failed (%s)\n", fname, nt_errstr(status));
                        *shared_correct = False;
@@ -3722,7 +3721,7 @@ static bool run_oplock4(int dummy)
        cli_sockopt(cli2, sockops);
 
        /* Create the file. */
-       status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
+       status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE,
                          &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
@@ -3743,13 +3742,13 @@ static bool run_oplock4(int dummy)
        }
 
        /* Prove that opening hardlinks cause deny modes to conflict. */
-       status = cli_open(cli1, fname, O_RDWR, DENY_ALL, &fnum1);
+       status = cli_openx(cli1, fname, O_RDWR, DENY_ALL, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return false;
        }
 
-       status = cli_open(cli1, fname_ln, O_RDWR, DENY_NONE, &fnum2);
+       status = cli_openx(cli1, fname_ln, O_RDWR, DENY_NONE, &fnum2);
        if (NT_STATUS_IS_OK(status)) {
                printf("open of %s succeeded - should fail with sharing violation.\n",
                        fname_ln);
@@ -3771,7 +3770,7 @@ static bool run_oplock4(int dummy)
        cli1->use_oplocks = true;
        cli2->use_oplocks = true;
 
-       status = cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1);
+       status = cli_openx(cli1, fname, O_RDWR, DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return false;
@@ -3779,7 +3778,7 @@ static bool run_oplock4(int dummy)
 
        ev = tevent_context_init(talloc_tos());
        if (ev == NULL) {
-               printf("tevent_req_create failed\n");
+               printf("tevent_context_init failed\n");
                return false;
        }
 
@@ -3801,10 +3800,10 @@ static bool run_oplock4(int dummy)
        }
        tevent_req_set_callback(oplock_req, oplock4_got_break, state);
 
-       open_req = cli_open_send(
+       open_req = cli_openx_send(
                talloc_tos(), ev, cli2, fname_ln, O_RDWR, DENY_NONE);
-       if (oplock_req == NULL) {
-               printf("cli_open_send failed\n");
+       if (open_req == NULL) {
+               printf("cli_openx_send failed\n");
                return false;
        }
        tevent_req_set_callback(open_req, oplock4_got_open, state);
@@ -3890,9 +3889,9 @@ static void oplock4_got_open(struct tevent_req *req)
                req, struct oplock4_state);
        NTSTATUS status;
 
-       status = cli_open_recv(req, state->fnum2);
+       status = cli_openx_recv(req, state->fnum2);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("cli_open_recv returned %s\n", nt_errstr(status));
+               printf("cli_openx_recv returned %s\n", nt_errstr(status));
                *state->fnum2 = 0xffff;
        }
 }
@@ -3939,7 +3938,7 @@ static bool run_deletetest(int dummy)
                goto fail;
        }
 
-       if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1))) {
+       if (NT_STATUS_IS_OK(cli_openx(cli1, fname, O_RDWR, DENY_NONE, &fnum1))) {
                printf("[1] open of %s succeeded (should fail)\n", fname);
                correct = False;
                goto fail;
@@ -3975,7 +3974,7 @@ static bool run_deletetest(int dummy)
                goto fail;
        }
 
-       if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
+       if (NT_STATUS_IS_OK(cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
                printf("[2] open of %s succeeded should have been deleted on close !\n", fname);
                status = cli_close(cli1, fnum1);
                if (!NT_STATUS_IS_OK(status)) {
@@ -4045,7 +4044,7 @@ static bool run_deletetest(int dummy)
 
        /* This should fail - file should no longer be there. */
 
-       if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
+       if (NT_STATUS_IS_OK(cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
                printf("[3] open of %s succeeded should have been deleted on close !\n", fname);
                status = cli_close(cli1, fnum1);
                if (!NT_STATUS_IS_OK(status)) {
@@ -4118,7 +4117,7 @@ static bool run_deletetest(int dummy)
        cli_setatr(cli1, fname, 0, 0);
        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-       status = cli_open(cli1, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum1);
+       status = cli_openx(cli1, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("[5] open of %s failed (%s)\n", fname, nt_errstr(status));
                correct = False;
@@ -4208,7 +4207,7 @@ static bool run_deletetest(int dummy)
        }
 
        /* This next open should succeed - we reset the flag. */
-       status = cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1);
+       status = cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("[5] open of %s failed (%s)\n", fname, nt_errstr(status));
                correct = False;
@@ -4279,7 +4278,7 @@ static bool run_deletetest(int dummy)
        }
 
        /* This should fail.. */
-       status = cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1);
+       status = cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum1);
        if (NT_STATUS_IS_OK(status)) {
                printf("[8] open of %s succeeded should have been deleted on close !\n", fname);
                goto fail;
@@ -4317,7 +4316,7 @@ static bool run_deletetest(int dummy)
        }
 
        /* This should fail.. */
-       if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
+       if (NT_STATUS_IS_OK(cli_openx(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
                printf("[10] open of %s succeeded should have been deleted on close !\n", fname);
                goto fail;
                correct = False;
@@ -4348,17 +4347,19 @@ static bool run_deletetest(int dummy)
        }
 
        /* Now try open for delete access. */
-       if (NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_ATTRIBUTES|DELETE_ACCESS,
-                                  0, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-                                  FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
+       status = cli_ntcreate(cli1, fname, 0,
+                            FILE_READ_ATTRIBUTES|DELETE_ACCESS,
+                            0,
+                            FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+                            FILE_OVERWRITE_IF, 0, 0, &fnum1);
+       if (NT_STATUS_IS_OK(status)) {
                printf("[11] open of %s succeeded should have been denied with ACCESS_DENIED!\n", fname);
                cli_close(cli1, fnum1);
                goto fail;
                correct = False;
        } else {
-               NTSTATUS nterr = cli_nt_error(cli1);
-               if (!NT_STATUS_EQUAL(nterr,NT_STATUS_ACCESS_DENIED)) {
-                       printf("[11] open of %s should have been denied with ACCESS_DENIED! Got error %s\n", fname, nt_errstr(nterr));
+               if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
+                       printf("[11] open of %s should have been denied with ACCESS_DENIED! Got error %s\n", fname, nt_errstr(status));
                        goto fail;
                        correct = False;
                } else {
@@ -4410,7 +4411,7 @@ static bool run_deletetest_ln(int dummy)
        cli_sockopt(cli, sockops);
 
        /* Create the file. */
-       status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
+       status = cli_openx(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return false;
@@ -4850,7 +4851,7 @@ static bool run_opentest(int dummy)
        const char *fname = "\\readonly.file";
        uint16_t fnum1, fnum2;
        char buf[20];
-       SMB_OFF_T fsize;
+       off_t fsize;
        bool correct = True;
        char *tmp_path;
        NTSTATUS status;
@@ -4866,7 +4867,7 @@ static bool run_opentest(int dummy)
 
        cli_sockopt(cli1, sockops);
 
-       status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+       status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
@@ -4884,14 +4885,14 @@ static bool run_opentest(int dummy)
                return False;
        }
 
-       status = cli_open(cli1, fname, O_RDONLY, DENY_WRITE, &fnum1);
+       status = cli_openx(cli1, fname, O_RDONLY, DENY_WRITE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
        }
 
        /* This will fail - but the error should be ERRnoaccess, not ERRbadshare. */
-       status = cli_open(cli1, fname, O_RDWR, DENY_ALL, &fnum2);
+       status = cli_openx(cli1, fname, O_RDWR, DENY_ALL, &fnum2);
 
         if (check_error(__LINE__, status, ERRDOS, ERRnoaccess,
                        NT_STATUS_ACCESS_DENIED)) {
@@ -4906,14 +4907,14 @@ static bool run_opentest(int dummy)
 
        cli_setatr(cli1, fname, 0, 0);
 
-       status = cli_open(cli1, fname, O_RDONLY, DENY_WRITE, &fnum1);
+       status = cli_openx(cli1, fname, O_RDONLY, DENY_WRITE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
        }
 
        /* This will fail - but the error should be ERRshare. */
-       status = cli_open(cli1, fname, O_RDWR, DENY_ALL, &fnum2);
+       status = cli_openx(cli1, fname, O_RDWR, DENY_ALL, &fnum2);
 
        if (check_error(__LINE__, status, ERRDOS, ERRbadshare,
                        NT_STATUS_SHARING_VIOLATION)) {
@@ -4931,7 +4932,7 @@ static bool run_opentest(int dummy)
        printf("finished open test 2\n");
 
        /* Test truncate open disposition on file opened for read. */
-       status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
+       status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("(3) open (1) of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
@@ -4966,7 +4967,7 @@ static bool run_opentest(int dummy)
        }
 
        /* Now test if we can truncate a file opened for readonly. */
-       status = cli_open(cli1, fname, O_RDONLY|O_TRUNC, DENY_NONE, &fnum1);
+       status = cli_openx(cli1, fname, O_RDONLY|O_TRUNC, DENY_NONE, &fnum1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("(3) open (2) of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
@@ -5859,7 +5860,7 @@ static bool run_dirtest(int dummy)
        for (i=0;i<torture_numops;i++) {
                fstring fname;
                slprintf(fname, sizeof(fname), "\\%x", (int)random());
-               if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum))) {
+               if (!NT_STATUS_IS_OK(cli_openx(cli, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum))) {
                        fprintf(stderr,"Failed to open %s\n", fname);
                        return False;
                }
@@ -5939,7 +5940,7 @@ bool torture_ioctl_test(int dummy)
 
        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 
-       status = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
+       status = cli_openx(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open of %s failed (%s)\n", fname, nt_errstr(status));
                return False;
@@ -6007,7 +6008,7 @@ bool torture_chkpath_test(int dummy)
                return False;
        }
 
-       status = cli_open(cli, "\\chkpath.dir\\foo.txt", O_RDWR|O_CREAT|O_EXCL,
+       status = cli_openx(cli, "\\chkpath.dir\\foo.txt", O_RDWR|O_CREAT|O_EXCL,
                          DENY_NONE, &fnum);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open1 failed (%s)\n", nt_errstr(status));
@@ -6347,6 +6348,9 @@ static bool run_error_map_extract(int dummy) {
                return False;
        }
 
+       c_nt->map_dos_errors = false;
+       c_dos->map_dos_errors = false;
+
        for (error=(0xc0000000 | 0x1); error < (0xc0000000| 0xFFF); error++) {
                fstr_sprintf(user, "%X", error);
 
@@ -6359,11 +6363,11 @@ static bool run_error_map_extract(int dummy) {
                }
 
                /* Case #1: 32-bit NT errors */
-               if (cli_is_nt_error(c_nt)) {
-                       nt_status = cli_nt_error(c_nt);
+               if (!NT_STATUS_IS_DOS(status)) {
+                       nt_status = status;
                } else {
                        printf("/** Dos error on NT connection! (%s) */\n", 
-                              cli_errstr(c_nt));
+                              nt_errstr(status));
                        nt_status = NT_STATUS(0xc0000000);
                }
 
@@ -6376,12 +6380,13 @@ static bool run_error_map_extract(int dummy) {
                }
 
                /* Case #1: 32-bit NT errors */
-               if (!cli_is_dos_error(c_dos)) {
+               if (NT_STATUS_IS_DOS(status)) {
                        printf("/** NT error on DOS connection! (%s) */\n", 
-                              cli_errstr(c_dos));
+                              nt_errstr(status));
                        errnum = errclass = 0;
                } else {
-                       cli_dos_error(c_dos, &errclass, &errnum);
+                       errclass = NT_STATUS_DOS_CLASS(status);
+                       errnum = NT_STATUS_DOS_CODE(status);
                }
 
                if (NT_STATUS_V(nt_status) != error) { 
@@ -6466,10 +6471,10 @@ static void chain1_open_completion(struct tevent_req *req)
 {
        uint16_t fnum;
        NTSTATUS status;
-       status = cli_open_recv(req, &fnum);
+       status = cli_openx_recv(req, &fnum);
        TALLOC_FREE(req);
 
-       d_printf("cli_open_recv returned %s: %d\n",
+       d_printf("cli_openx_recv returned %s: %d\n",
                 nt_errstr(status),
                 NT_STATUS_IS_OK(status) ? fnum : -1);
 }
@@ -6515,7 +6520,7 @@ static bool run_chain1(int dummy)
 
        cli_sockopt(cli1, sockops);
 
-       reqs[0] = cli_open_create(talloc_tos(), evt, cli1, "\\test",
+       reqs[0] = cli_openx_create(talloc_tos(), evt, cli1, "\\test",
                                  O_CREAT|O_RDWR, 0, &smbreqs[0]);
        if (reqs[0] == NULL) return false;
        tevent_req_set_callback(reqs[0], chain1_open_completion, NULL);
@@ -7011,7 +7016,7 @@ static bool run_mangle1(int dummy)
        fstring alt_name;
        NTSTATUS status;
        time_t change_time, access_time, write_time;
-       SMB_OFF_T size;
+       off_t size;
        uint16_t mode;
 
        printf("starting mangle1 test\n");
@@ -7038,9 +7043,9 @@ static bool run_mangle1(int dummy)
        }
        d_printf("alt_name: %s\n", alt_name);
 
-       status = cli_open(cli, alt_name, O_RDONLY, DENY_NONE, &fnum);
+       status = cli_openx(cli, alt_name, O_RDONLY, DENY_NONE, &fnum);
        if (!NT_STATUS_IS_OK(status)) {
-               d_printf("cli_open(%s) failed: %s\n", alt_name,
+               d_printf("cli_openx(%s) failed: %s\n", alt_name,
                         nt_errstr(status));
                return false;
        }
@@ -7089,7 +7094,7 @@ static bool run_windows_write(int dummy)
                return False;
        }
 
-       status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
+       status = cli_openx(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
        if (!NT_STATUS_IS_OK(status)) {
                printf("open failed (%s)\n", nt_errstr(status));
                return False;
@@ -7310,7 +7315,7 @@ static bool run_shortname_test(int dummy)
        bool correct = True;
        int i;
        struct sn_state s;
-       char fname[20];
+       char fname[40];
        NTSTATUS status;
 
        printf("starting shortname test\n");
@@ -7333,8 +7338,14 @@ static bool run_shortname_test(int dummy)
                goto out;
        }
 
-       strlcpy(fname, "\\shortname\\", sizeof(fname));
-       strlcat(fname, "test .txt", sizeof(fname));
+       if (strlcpy(fname, "\\shortname\\", sizeof(fname)) >= sizeof(fname)) {
+               correct = false;
+               goto out;
+       }
+       if (strlcat(fname, "test .txt", sizeof(fname)) >= sizeof(fname)) {
+               correct = false;
+               goto out;
+       }
 
        s.val = false;
 
@@ -7534,10 +7545,10 @@ static bool run_dir_createtime(int dummy)
        /* Sleep 3 seconds, then create a file. */
        sleep(3);
 
-       status = cli_open(cli, fname, O_RDWR | O_CREAT | O_EXCL,
+       status = cli_openx(cli, fname, O_RDWR | O_CREAT | O_EXCL,
                          DENY_NONE, &fnum);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("cli_open failed: %s\n", nt_errstr(status));
+               printf("cli_openx failed: %s\n", nt_errstr(status));
                goto out;
        }
 
@@ -7575,7 +7586,7 @@ static bool run_streamerror(int dummy)
                "testdir:{4c8cc155-6c1e-11d1-8e41-00c04fb9386d}:$DATA";
        NTSTATUS status;
        time_t change_time, access_time, write_time;
-       SMB_OFF_T size;
+       off_t size;
        uint16_t mode, fnum;
        bool ret = true;
 
@@ -7592,10 +7603,8 @@ static bool run_streamerror(int dummy)
                return false;
        }
 
-       cli_qpathinfo1(cli, streamname, &change_time, &access_time, &write_time,
-                     &size, &mode);
-       status = cli_nt_error(cli);
-
+       status = cli_qpathinfo1(cli, streamname, &change_time, &access_time,
+                               &write_time, &size, &mode);
        if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
                printf("pathinfo returned %s, expected "
                       "NT_STATUS_OBJECT_NAME_NOT_FOUND\n",
@@ -7967,7 +7976,8 @@ static bool run_local_talloc_dict(int dummy)
 {
        struct talloc_dict *dict;
        struct talloc_dict_test *t;
-       int key, count;
+       int key, count, res;
+       bool ok;
 
        dict = talloc_dict_init(talloc_tos());
        if (dict == NULL) {
@@ -7981,12 +7991,14 @@ static bool run_local_talloc_dict(int dummy)
 
        key = 1;
        t->content = 1;
-       if (!talloc_dict_set(dict, data_blob_const(&key, sizeof(key)), t)) {
+       ok = talloc_dict_set(dict, data_blob_const(&key, sizeof(key)), &t);
+       if (!ok) {
                return false;
        }
 
        count = 0;
-       if (talloc_dict_traverse(dict, talloc_dict_traverse_fn, &count) != 0) {
+       res = talloc_dict_traverse(dict, talloc_dict_traverse_fn, &count);
+       if (res == -1) {
                return false;
        }
 
@@ -7994,6 +8006,10 @@ static bool run_local_talloc_dict(int dummy)
                return false;
        }
 
+       if (count != res) {
+               return false;
+       }
+
        TALLOC_FREE(dict);
 
        return true;
@@ -8311,7 +8327,7 @@ static bool run_local_memcache(int dummy)
        size_t size1, size2;
        bool ret = false;
 
-       cache = memcache_init(NULL, 100);
+       cache = memcache_init(NULL, sizeof(void *) == 8 ? 200 : 100);
 
        if (cache == NULL) {
                printf("memcache_init failed\n");
@@ -8418,7 +8434,7 @@ static bool run_local_wbclient(int dummy)
                goto fail;
        }
 
-       wb_ctx = talloc_array(ev, struct wb_context *, nprocs);
+       wb_ctx = talloc_array(ev, struct wb_context *, torture_nprocs);
        if (wb_ctx == NULL) {
                goto fail;
        }
@@ -8426,9 +8442,9 @@ static bool run_local_wbclient(int dummy)
        ZERO_STRUCT(wb_req);
        wb_req.cmd = WINBINDD_PING;
 
-       d_printf("nprocs=%d, numops=%d\n", (int)nprocs, (int)torture_numops);
+       d_printf("torture_nprocs=%d, numops=%d\n", (int)torture_nprocs, (int)torture_numops);
 
-       for (i=0; i<nprocs; i++) {
+       for (i=0; i<torture_nprocs; i++) {
                wb_ctx[i] = wb_context_init(ev, NULL);
                if (wb_ctx[i] == NULL) {
                        goto fail;
@@ -8446,7 +8462,7 @@ static bool run_local_wbclient(int dummy)
 
        i = 0;
 
-       while (i < nprocs * torture_numops) {
+       while (i < torture_nprocs * torture_numops) {
                tevent_loop_once(ev);
        }
 
@@ -8512,7 +8528,7 @@ fail:
 static bool dbtrans_inc(struct db_context *db)
 {
        struct db_record *rec;
-       uint32_t *val;
+       uint32_t val;
        bool ret = false;
        NTSTATUS status;
        TDB_DATA value;
@@ -8531,12 +8547,11 @@ static bool dbtrans_inc(struct db_context *db)
                goto fail;
        }
 
-       val = (uint32_t *)value.dptr;
-       *val += 1;
+       memcpy(&val, value.dptr, sizeof(val));
+       val += 1;
 
-       status = dbwrap_record_store(rec, make_tdb_data((uint8_t *)val,
-                                              sizeof(uint32_t)),
-                           0);
+       status = dbwrap_record_store(
+               rec, make_tdb_data((uint8_t *)&val, sizeof(val)), 0);
        if (!NT_STATUS_IS_OK(status)) {
                printf(__location__ "store failed: %s\n",
                       nt_errstr(status));
@@ -8559,7 +8574,7 @@ static bool run_local_dbtrans(int dummy)
        TDB_DATA value;
 
        db = db_open(talloc_tos(), "transtest.tdb", 0, TDB_DEFAULT,
-                    O_RDWR|O_CREAT, 0600);
+                    O_RDWR|O_CREAT, 0600, DBWRAP_LOCK_ORDER_1);
        if (db == NULL) {
                printf("Could not open transtest.db\n");
                return false;
@@ -8691,6 +8706,26 @@ fail:
        return result;
 }
 
+static bool run_local_hex_encode_buf(int dummy)
+{
+       char buf[17];
+       uint8_t src[8];
+       int i;
+
+       for (i=0; i<sizeof(src); i++) {
+               src[i] = i;
+       }
+       hex_encode_buf(buf, src, sizeof(src));
+       if (strcmp(buf, "0001020304050607") != 0) {
+               return false;
+       }
+       hex_encode_buf(buf, NULL, 0);
+       if (buf[0] != '\0') {
+               return false;
+       }
+       return true;
+}
+
 static double create_procs(bool (*fn)(int), bool *result)
 {
        int i, status;
@@ -8702,26 +8737,26 @@ static double create_procs(bool (*fn)(int), bool *result)
 
        synccount = 0;
 
-       child_status = (volatile pid_t *)shm_setup(sizeof(pid_t)*nprocs);
+       child_status = (volatile pid_t *)shm_setup(sizeof(pid_t)*torture_nprocs);
        if (!child_status) {
                printf("Failed to setup shared memory\n");
                return -1;
        }
 
-       child_status_out = (volatile bool *)shm_setup(sizeof(bool)*nprocs);
+       child_status_out = (volatile bool *)shm_setup(sizeof(bool)*torture_nprocs);
        if (!child_status_out) {
                printf("Failed to setup result status shared memory\n");
                return -1;
        }
 
-       for (i = 0; i < nprocs; i++) {
+       for (i = 0; i < torture_nprocs; i++) {
                child_status[i] = 0;
                child_status_out[i] = True;
        }
 
        start = timeval_current();
 
-       for (i=0;i<nprocs;i++) {
+       for (i=0;i<torture_nprocs;i++) {
                procnum = i;
                if (fork() == 0) {
                        pid_t mypid = getpid();
@@ -8749,15 +8784,15 @@ static double create_procs(bool (*fn)(int), bool *result)
 
        do {
                synccount = 0;
-               for (i=0;i<nprocs;i++) {
+               for (i=0;i<torture_nprocs;i++) {
                        if (child_status[i]) synccount++;
                }
-               if (synccount == nprocs) break;
+               if (synccount == torture_nprocs) break;
                smb_msleep(10);
        } while (timeval_elapsed(&start) < 30);
 
-       if (synccount != nprocs) {
-               printf("FAILED TO START %d CLIENTS (started %d)\n", nprocs, synccount);
+       if (synccount != torture_nprocs) {
+               printf("FAILED TO START %d CLIENTS (started %d)\n", torture_nprocs, synccount);
                *result = False;
                return timeval_elapsed(&start);
        }
@@ -8765,19 +8800,19 @@ static double create_procs(bool (*fn)(int), bool *result)
        /* start the client load */
        start = timeval_current();
 
-       for (i=0;i<nprocs;i++) {
+       for (i=0;i<torture_nprocs;i++) {
                child_status[i] = 0;
        }
 
-       printf("%d clients started\n", nprocs);
+       printf("%d clients started\n", torture_nprocs);
 
-       for (i=0;i<nprocs;i++) {
+       for (i=0;i<torture_nprocs;i++) {
                while (waitpid(0, &status, 0) == -1 && errno == EINTR) /* noop */ ;
        }
 
        printf("\n");
 
-       for (i=0;i<nprocs;i++) {
+       for (i=0;i<torture_nprocs;i++) {
                if (!child_status_out[i]) {
                        *result = False;
                }
@@ -8859,6 +8894,7 @@ static struct {
        { "SESSSETUP_BENCH", run_sesssetup_bench, 0},
        { "CHAIN1", run_chain1, 0},
        { "CHAIN2", run_chain2, 0},
+       { "CHAIN3", run_chain3, 0},
        { "WINDOWS-WRITE", run_windows_write, 0},
        { "NTTRANS-CREATE", run_nttrans_create, 0},
        { "NTTRANS-FSCTL", run_nttrans_fsctl, 0},
@@ -8867,13 +8903,24 @@ static struct {
        { "TLDAP", run_tldap },
        { "STREAMERROR", run_streamerror },
        { "NOTIFY-BENCH", run_notify_bench },
+       { "NOTIFY-BENCH2", run_notify_bench2 },
+       { "NOTIFY-BENCH3", run_notify_bench3 },
        { "BAD-NBT-SESSION", run_bad_nbt_session },
        { "SMB-ANY-CONNECT", run_smb_any_connect },
        { "NOTIFY-ONLINE", run_notify_online },
        { "SMB2-BASIC", run_smb2_basic },
+       { "SMB2-NEGPROT", run_smb2_negprot },
+       { "SMB2-SESSION-RECONNECT", run_smb2_session_reconnect },
+       { "SMB2-TCON-DEPENDENCE", run_smb2_tcon_dependence },
+       { "SMB2-MULTI-CHANNEL", run_smb2_multi_channel },
+       { "SMB2-SESSION-REAUTH", run_smb2_session_reauth },
+       { "CLEANUP1", run_cleanup1 },
+       { "CLEANUP2", run_cleanup2 },
        { "LOCAL-SUBSTITUTE", run_local_substitute, 0},
        { "LOCAL-GENCACHE", run_local_gencache, 0},
        { "LOCAL-TALLOC-DICT", run_local_talloc_dict, 0},
+       { "LOCAL-CTDB-CONN", run_ctdb_conn, 0},
+       { "LOCAL-MSG", run_msg_test, 0},
        { "LOCAL-BASE64", run_local_base64, 0},
        { "LOCAL-RBTREE", run_local_rbtree, 0},
        { "LOCAL-MEMCACHE", run_local_memcache, 0},
@@ -8886,6 +8933,7 @@ static struct {
        { "LOCAL-CONVERT-STRING", run_local_convert_string, 0},
        { "LOCAL-CONV-AUTH-INFO", run_local_conv_auth_info, 0},
        { "LOCAL-sprintf_append", run_local_sprintf_append, 0},
+       { "LOCAL-hex_encode_buf", run_local_hex_encode_buf, 0},
        {NULL, NULL, 0}};
 
 
@@ -9060,7 +9108,7 @@ static void usage(void)
                        max_protocol = interpret_protocol(optarg, max_protocol);
                        break;
                case 'N':
-                       nprocs = atoi(optarg);
+                       torture_nprocs = atoi(optarg);
                        break;
                case 'o':
                        torture_numops = atoi(optarg);