]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:torture: use torture api instead of printf for RAW-LOCK
authorStefan Metzmacher <metze@samba.org>
Fri, 24 Apr 2009 10:28:59 +0000 (12:28 +0200)
committerStefan Metzmacher <metze@samba.org>
Sat, 25 Apr 2009 01:15:58 +0000 (03:15 +0200)
metze

source4/torture/raw/lock.c

index 7e3ac2980955246c4f1aedcbdbabef3676cfa8f4..f756622f8fd25117c0f130b7f95e23ed5abe0387 100644 (file)
 
 #define CHECK_STATUS(status, correct) do { \
        if (!NT_STATUS_EQUAL(status, correct)) { \
-               printf("(%s) Incorrect status %s - should be %s\n", \
-                      __location__, nt_errstr(status), nt_errstr(correct)); \
+               torture_result(tctx, TORTURE_FAIL, \
+                       "(%s) Incorrect status %s - should be %s\n", \
+                       __location__, nt_errstr(status), nt_errstr(correct)); \
                ret = false; \
                goto done; \
        }} while (0)
 
 #define CHECK_STATUS_CONT(status, correct) do { \
        if (!NT_STATUS_EQUAL(status, correct)) { \
-               printf("(%s) Incorrect status %s - should be %s\n", \
-                      __location__, nt_errstr(status), nt_errstr(correct)); \
+               torture_result(tctx, TORTURE_FAIL, \
+                       "(%s) Incorrect status %s - should be %s\n", \
+                       __location__, nt_errstr(status), nt_errstr(correct)); \
                ret = false; \
        }} while (0)
 
 #define CHECK_STATUS_OR(status, correct1, correct2) do { \
        if ((!NT_STATUS_EQUAL(status, correct1)) && \
            (!NT_STATUS_EQUAL(status, correct2))) { \
-               printf("(%s) Incorrect status %s - should be %s or %s\n", \
-                      __location__, nt_errstr(status), nt_errstr(correct1), \
-                      nt_errstr(correct2)); \
+               torture_result(tctx, TORTURE_FAIL, \
+                       "(%s) Incorrect status %s - should be %s or %s\n", \
+                       __location__, nt_errstr(status), nt_errstr(correct1), \
+                       nt_errstr(correct2)); \
                ret = false; \
                goto done; \
        }} while (0)
 #define CHECK_STATUS_OR_CONT(status, correct1, correct2) do { \
        if ((!NT_STATUS_EQUAL(status, correct1)) && \
            (!NT_STATUS_EQUAL(status, correct2))) { \
-               printf("(%s) Incorrect status %s - should be %s or %s\n", \
-                      __location__, nt_errstr(status), nt_errstr(correct1), \
-                      nt_errstr(correct2)); \
+               torture_result(tctx, TORTURE_FAIL, \
+                       "(%s) Incorrect status %s - should be %s or %s\n", \
+                       __location__, nt_errstr(status), nt_errstr(correct1), \
+                       nt_errstr(correct2)); \
                ret = false; \
        }} while (0)
 #define BASEDIR "\\testlock"
@@ -82,17 +86,15 @@ static bool test_lock(struct torture_context *tctx, struct smbcli_state *cli)
                return false;
        }
 
-       printf("Testing RAW_LOCK_LOCK\n");
+       torture_comment(tctx, "Testing RAW_LOCK_LOCK\n");
        io.generic.level = RAW_LOCK_LOCK;
        
        fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum == -1) {
-               printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+                      "Failed to create %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
 
-       printf("Trying 0/0 lock\n");
+       torture_comment(tctx, "Trying 0/0 lock\n");
        io.lock.level = RAW_LOCK_LOCK;
        io.lock.in.file.fnum = fnum;
        io.lock.in.count = 0;
@@ -107,7 +109,7 @@ static bool test_lock(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       printf("Trying 0/1 lock\n");
+       torture_comment(tctx, "Trying 0/1 lock\n");
        io.lock.level = RAW_LOCK_LOCK;
        io.lock.in.file.fnum = fnum;
        io.lock.in.count = 1;
@@ -125,7 +127,7 @@ static bool test_lock(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       printf("Trying 0xEEFFFFFF lock\n");
+       torture_comment(tctx, "Trying 0xEEFFFFFF lock\n");
        io.lock.level = RAW_LOCK_LOCK;
        io.lock.in.file.fnum = fnum;
        io.lock.in.count = 4000;
@@ -143,7 +145,7 @@ static bool test_lock(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       printf("Trying 0xEF000000 lock\n");
+       torture_comment(tctx, "Trying 0xEF000000 lock\n");
        io.lock.level = RAW_LOCK_LOCK;
        io.lock.in.file.fnum = fnum;
        io.lock.in.count = 4000;
@@ -161,7 +163,7 @@ static bool test_lock(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       printf("Trying max lock\n");
+       torture_comment(tctx, "Trying max lock\n");
        io.lock.level = RAW_LOCK_LOCK;
        io.lock.in.file.fnum = fnum;
        io.lock.in.count = 4000;
@@ -179,7 +181,7 @@ static bool test_lock(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       printf("Trying wrong pid unlock\n");
+       torture_comment(tctx, "Trying wrong pid unlock\n");
        io.lock.level = RAW_LOCK_LOCK;
        io.lock.in.file.fnum = fnum;
        io.lock.in.count = 4002;
@@ -218,15 +220,13 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli)
                return false;
        }
 
-       printf("Testing RAW_LOCK_LOCKX\n");
+       torture_comment(tctx, "Testing RAW_LOCK_LOCKX\n");
        io.generic.level = RAW_LOCK_LOCKX;
        
        fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum == -1) {
-               printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+                      "Failed to create %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
 
        io.lockx.level = RAW_LOCK_LOCKX;
        io.lockx.in.file.fnum = fnum;
@@ -242,7 +242,7 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli)
        CHECK_STATUS(status, NT_STATUS_OK);
 
 
-       printf("Trying 0xEEFFFFFF lock\n");
+       torture_comment(tctx, "Trying 0xEEFFFFFF lock\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        lock[0].count = 4000;
@@ -260,7 +260,7 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       printf("Trying 0xEF000000 lock\n");
+       torture_comment(tctx, "Trying 0xEF000000 lock\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        lock[0].count = 4000;
@@ -278,7 +278,7 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       printf("Trying zero lock\n");
+       torture_comment(tctx, "Trying zero lock\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        lock[0].count = 0;
@@ -296,7 +296,7 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       printf("Trying max lock\n");
+       torture_comment(tctx, "Trying max lock\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        lock[0].count = 0;
@@ -314,7 +314,7 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       printf("Trying 2^63\n");
+       torture_comment(tctx, "Trying 2^63\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        lock[0].count = 1;
@@ -333,7 +333,7 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       printf("Trying 2^63 - 1\n");
+       torture_comment(tctx, "Trying 2^63 - 1\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        lock[0].count = 1;
@@ -353,7 +353,7 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       printf("Trying max lock 2\n");
+       torture_comment(tctx, "Trying max lock 2\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        lock[0].count = 1;
@@ -408,20 +408,20 @@ static bool test_pidhigh(struct torture_context *tctx,
                return false;
        }
 
-       printf("Testing high pid\n");
+       torture_comment(tctx, "Testing high pid\n");
        io.generic.level = RAW_LOCK_LOCKX;
 
        cli->session->pid = 1;
        
        fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum == -1) {
-               printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+                      "Failed to create %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
 
        if (smbcli_write(cli->tree, fnum, 0, &c, 0, 1) != 1) {
-               printf("Failed to write 1 byte - %s\n", smbcli_errstr(cli->tree));
+               torture_result(tctx, TORTURE_FAIL,
+                       "Failed to write 1 byte - %s\n",
+                       smbcli_errstr(cli->tree));
                ret = false;
                goto done;
        }
@@ -440,7 +440,9 @@ static bool test_pidhigh(struct torture_context *tctx,
        CHECK_STATUS(status, NT_STATUS_OK);
 
        if (smbcli_read(cli->tree, fnum, &c, 0, 1) != 1) {
-               printf("Failed to read 1 byte - %s\n", smbcli_errstr(cli->tree));
+               torture_result(tctx, TORTURE_FAIL,
+                       "Failed to read 1 byte - %s\n",
+                       smbcli_errstr(cli->tree));
                ret = false;
                goto done;
        }
@@ -448,7 +450,8 @@ static bool test_pidhigh(struct torture_context *tctx,
        cli->session->pid = 2;
 
        if (smbcli_read(cli->tree, fnum, &c, 0, 1) == 1) {
-               printf("pid is incorrect handled for read with lock!\n");
+               torture_result(tctx, TORTURE_FAIL,
+                       "pid is incorrect handled for read with lock!\n");
                ret = false;
                goto done;
        }
@@ -456,10 +459,11 @@ static bool test_pidhigh(struct torture_context *tctx,
        cli->session->pid = 0x10001;
 
        if (smbcli_read(cli->tree, fnum, &c, 0, 1) != 1) {
-               printf("High pid is used on this server!\n");
+               torture_result(tctx, TORTURE_FAIL,
+                       "High pid is used on this server!\n");
                ret = false;
        } else {
-               printf("High pid is not used on this server (correct)\n");
+               torture_warning(tctx, "High pid is not used on this server (correct)\n");
        }
 
 done:
@@ -497,15 +501,13 @@ static bool test_async(struct torture_context *tctx,
 
        lp_smbcli_session_options(tctx->lp_ctx, &options);
 
-       printf("Testing LOCKING_ANDX_CANCEL_LOCK\n");
+       torture_comment(tctx, "Testing LOCKING_ANDX_CANCEL_LOCK\n");
        io.generic.level = RAW_LOCK_LOCKX;
 
        fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum == -1) {
-               printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+                      "Failed to create %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
 
        io.lockx.level = RAW_LOCK_LOCKX;
        io.lockx.in.file.fnum = fnum;
@@ -522,16 +524,13 @@ static bool test_async(struct torture_context *tctx,
 
        t = time(NULL);
 
-       printf("testing cancel by CANCEL_LOCK\n");
+       torture_comment(tctx, "testing cancel by CANCEL_LOCK\n");
 
        /* setup a timed lock */
        io.lockx.in.timeout = 10000;
        req = smb_raw_lock_send(cli->tree, &io);
-       if (req == NULL) {
-               printf("Failed to setup timed lock (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+                      "Failed to setup timed lock (%s)\n", __location__));
 
        /* cancel the wrong range */
        lock[0].offset = 0;
@@ -558,13 +557,10 @@ static bool test_async(struct torture_context *tctx,
        status = smbcli_request_simple_recv(req);
        CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
 
-       if (time(NULL) > t+2) {
-               printf("lock cancel was not immediate (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx,
+                      "lock cancel was not immediate (%s)\n", __location__));
 
-       printf("testing cancel by unlock\n");
+       torture_comment(tctx, "testing cancel by unlock\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
@@ -574,11 +570,8 @@ static bool test_async(struct torture_context *tctx,
 
        io.lockx.in.timeout = 5000;
        req = smb_raw_lock_send(cli->tree, &io);
-       if (req == NULL) {
-               printf("Failed to setup timed lock (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+                      "Failed to setup timed lock (%s)\n", __location__));
 
        io.lockx.in.ulock_cnt = 1;
        io.lockx.in.lock_cnt = 0;
@@ -589,14 +582,11 @@ static bool test_async(struct torture_context *tctx,
        status = smbcli_request_simple_recv(req);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       if (time(NULL) > t+2) {
-               printf("lock cancel by unlock was not immediate (%s) - took %d secs\n", 
-                      __location__, (int)(time(NULL)-t));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx,
+                      "lock cancel by unlock was not immediate (%s) - took %d secs\n",
+                      __location__, (int)(time(NULL)-t)));
 
-       printf("testing cancel by close\n");
+       torture_comment(tctx, "testing cancel by close\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
@@ -607,11 +597,8 @@ static bool test_async(struct torture_context *tctx,
        t = time(NULL);
        io.lockx.in.timeout = 10000;
        req = smb_raw_lock_send(cli->tree, &io);
-       if (req == NULL) {
-               printf("Failed to setup timed lock (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+                      "Failed to setup timed lock (%s)\n", __location__));
 
        status = smbcli_close(cli->tree, fnum);
        CHECK_STATUS(status, NT_STATUS_OK);
@@ -619,13 +606,10 @@ static bool test_async(struct torture_context *tctx,
        status = smbcli_request_simple_recv(req);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       if (time(NULL) > t+2) {
-               printf("lock cancel by close was not immediate (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx,
+                      "lock cancel by close was not immediate (%s)\n", __location__));
 
-       printf("create a new sessions\n");
+       torture_comment(tctx, "create a new sessions\n");
        session = smbcli_session_init(cli->transport, tctx, false, options);
        setup.in.sesskey = cli->transport->negotiate.sesskey;
        setup.in.capabilities = cli->transport->negotiate.capabilities;
@@ -636,7 +620,7 @@ static bool test_async(struct torture_context *tctx,
        CHECK_STATUS(status, NT_STATUS_OK);
        session->vuid = setup.out.vuid;
 
-       printf("create new tree context\n");
+       torture_comment(tctx, "create new tree context\n");
        share = torture_setting_string(tctx, "share", NULL);
        host  = torture_setting_string(tctx, "host", NULL);
        tree = smbcli_tree_init(session, tctx, false);
@@ -649,14 +633,13 @@ static bool test_async(struct torture_context *tctx,
        CHECK_STATUS(status, NT_STATUS_OK);
        tree->tid = tcon.tconx.out.tid;
 
-       printf("testing cancel by exit\n");
+       torture_comment(tctx, "testing cancel by exit\n");
        fname = BASEDIR "\\test_exit.txt";
        fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum == -1) {
-               printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+                      "Failed to reopen %s - %s\n",
+                      fname, smbcli_errstr(tree)));
+
        io.lockx.level = RAW_LOCK_LOCKX;
        io.lockx.in.file.fnum = fnum;
        io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
@@ -680,11 +663,8 @@ static bool test_async(struct torture_context *tctx,
        io.lockx.in.timeout = 10000;
        t = time(NULL);
        req = smb_raw_lock_send(tree, &io);
-       if (req == NULL) {
-               printf("Failed to setup timed lock (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+                      "Failed to setup timed lock (%s)\n", __location__));
 
        status = smb_raw_exit(session);
        CHECK_STATUS(status, NT_STATUS_OK);
@@ -692,20 +672,16 @@ static bool test_async(struct torture_context *tctx,
        status = smbcli_request_simple_recv(req);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       if (time(NULL) > t+2) {
-               printf("lock cancel by exit was not immediate (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx,
+                      "lock cancel by exit was not immediate (%s)\n", __location__));
 
-       printf("testing cancel by ulogoff\n");
+       torture_comment(tctx, "testing cancel by ulogoff\n");
        fname = BASEDIR "\\test_ulogoff.txt";
        fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum == -1) {
-               printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+                      "Failed to reopen %s - %s\n",
+                      fname, smbcli_errstr(tree)));
+
        io.lockx.level = RAW_LOCK_LOCKX;
        io.lockx.in.file.fnum = fnum;
        io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
@@ -729,18 +705,16 @@ static bool test_async(struct torture_context *tctx,
        io.lockx.in.timeout = 10000;
        t = time(NULL);
        req = smb_raw_lock_send(tree, &io);
-       if (req == NULL) {
-               printf("Failed to setup timed lock (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+                      "Failed to setup timed lock (%s)\n", __location__));
 
        status = smb_raw_ulogoff(session);
        CHECK_STATUS(status, NT_STATUS_OK);
 
        status = smbcli_request_simple_recv(req);
        if (NT_STATUS_EQUAL(NT_STATUS_FILE_LOCK_CONFLICT, status)) {
-               printf("lock not canceled by ulogoff - %s (ignored because of vfs_vifs fails it)\n",
+               torture_result(tctx, TORTURE_FAIL,
+                       "lock not canceled by ulogoff - %s (ignored because of vfs_vifs fails it)\n",
                        nt_errstr(status));
                smb_tree_disconnect(tree);
                smb_raw_exit(session);
@@ -748,22 +722,18 @@ static bool test_async(struct torture_context *tctx,
        }
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       if (time(NULL) > t+2) {
-               printf("lock cancel by ulogoff was not immediate (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx,
+                      "lock cancel by ulogoff was not immediate (%s)\n", __location__));
 
-       printf("testing cancel by tdis\n");
+       torture_comment(tctx, "testing cancel by tdis\n");
        tree->session = cli->session;
 
        fname = BASEDIR "\\test_tdis.txt";
        fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum == -1) {
-               printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+                      "Failed to reopen %s - %s\n",
+                      fname, smbcli_errstr(tree)));
+
        io.lockx.level = RAW_LOCK_LOCKX;
        io.lockx.in.file.fnum = fnum;
        io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
@@ -783,11 +753,8 @@ static bool test_async(struct torture_context *tctx,
        io.lockx.in.timeout = 10000;
        t = time(NULL);
        req = smb_raw_lock_send(tree, &io);
-       if (req == NULL) {
-               printf("Failed to setup timed lock (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+                      "Failed to setup timed lock (%s)\n", __location__));
 
        status = smb_tree_disconnect(tree);
        CHECK_STATUS(status, NT_STATUS_OK);
@@ -795,11 +762,8 @@ static bool test_async(struct torture_context *tctx,
        status = smbcli_request_simple_recv(req);
        CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
 
-       if (time(NULL) > t+2) {
-               printf("lock cancel by tdis was not immediate (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx,
+                      "lock cancel by tdis was not immediate (%s)\n", __location__));
 
 done:
        smb_raw_exit(cli->session);
@@ -828,9 +792,9 @@ static bool test_errorcode(struct torture_context *tctx,
                return false;
        }
 
-       printf("Testing LOCK_NOT_GRANTED vs. FILE_LOCK_CONFLICT\n");
+       torture_comment(tctx, "Testing LOCK_NOT_GRANTED vs. FILE_LOCK_CONFLICT\n");
 
-       printf("testing with timeout = 0\n");
+       torture_comment(tctx, "testing with timeout = 0\n");
        fname = BASEDIR "\\test0.txt";
        t = 0;
 
@@ -1126,7 +1090,7 @@ next_run:
        /* end of the loop */
        if (t == 0) {
                smb_raw_exit(cli->session);
-               printf("testing with timeout > 0 (=1)\n");
+               torture_comment(tctx, "testing with timeout > 0 (=1)\n");
                fname = BASEDIR "\\test1.txt";
                t = 1;
                goto next_run;
@@ -1138,14 +1102,13 @@ next_run:
         * to the client (after the timeout went by)
         */
        smb_raw_exit(cli->session);
-       printf("testing a conflict while a lock is pending\n");
+       torture_comment(tctx, "testing a conflict while a lock is pending\n");
        fname = BASEDIR "\\test2.txt";
        fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum == -1) {
-               printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+                      "Failed to reopen %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
+
        io.lockx.level = RAW_LOCK_LOCKX;
        io.lockx.in.file.fnum = fnum;
        io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
@@ -1162,11 +1125,8 @@ next_run:
        start = time(NULL);
        io.lockx.in.timeout = 1000;
        req = smb_raw_lock_send(cli->tree, &io);
-       if (req == NULL) {
-               printf("Failed to setup timed lock (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+                      "Failed to setup timed lock (%s)\n", __location__));
 
        io.lockx.in.timeout = 0;
        lock[0].offset = 105;
@@ -1180,20 +1140,16 @@ next_run:
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
 
-       if (time(NULL) < start+1) {
-               printf("lock comes back to early (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,!(time(NULL) < start+1), talloc_asprintf(tctx,
+                      "lock comes back to early (%s)\n", __location__));
 
        smbcli_close(cli->tree, fnum);
        fname = BASEDIR "\\test3.txt";
        fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum == -1) {
-               printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+                      "Failed to reopen %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
+
        io.lockx.level = RAW_LOCK_LOCKX;
        io.lockx.in.file.fnum = fnum;
        io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
@@ -1210,11 +1166,8 @@ next_run:
        start = time(NULL);
        io.lockx.in.timeout = 1000;
        req = smb_raw_lock_send(cli->tree, &io);
-       if (req == NULL) {
-               printf("Failed to setup timed lock (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+                      "Failed to setup timed lock (%s)\n", __location__));
 
        io.lockx.in.timeout = 0;
        lock[0].offset = 105;
@@ -1230,20 +1183,16 @@ next_run:
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
 
-       if (time(NULL) < start+1) {
-               printf("lock comes back to early (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,!(time(NULL) < start+1), talloc_asprintf(tctx,
+                      "lock comes back to early (%s)\n", __location__));
 
        smbcli_close(cli->tree, fnum);
        fname = BASEDIR "\\test4.txt";
        fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum == -1) {
-               printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+                      "Failed to reopen %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
+
        io.lockx.level = RAW_LOCK_LOCKX;
        io.lockx.in.file.fnum = fnum;
        io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
@@ -1260,11 +1209,8 @@ next_run:
        start = time(NULL);
        io.lockx.in.timeout = 1000;
        req = smb_raw_lock_send(cli->tree, &io);
-       if (req == NULL) {
-               printf("Failed to setup timed lock (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+                      "Failed to setup timed lock (%s)\n", __location__));
 
        io.lockx.in.timeout = 0;
        status = smb_raw_lock(cli->tree, &io);
@@ -1276,11 +1222,8 @@ next_run:
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
 
-       if (time(NULL) < start+1) {
-               printf("lock comes back to early (%s)\n", __location__);
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,!(time(NULL) < start+1), talloc_asprintf(tctx,
+                      "lock comes back to early (%s)\n", __location__));
 
 done:
        smb_raw_exit(cli->session);
@@ -1307,15 +1250,13 @@ static bool test_changetype(struct torture_context *tctx,
                return false;
        }
 
-       printf("Testing LOCKING_ANDX_CHANGE_LOCKTYPE\n");
+       torture_comment(tctx, "Testing LOCKING_ANDX_CHANGE_LOCKTYPE\n");
        io.generic.level = RAW_LOCK_LOCKX;
        
        fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum == -1) {
-               printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+                      "Failed to create %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
 
        io.lockx.level = RAW_LOCK_LOCKX;
        io.lockx.in.file.fnum = fnum;
@@ -1331,7 +1272,8 @@ static bool test_changetype(struct torture_context *tctx,
        CHECK_STATUS(status, NT_STATUS_OK);
 
        if (smbcli_write(cli->tree, fnum, 0, &c, 100, 1) == 1) {
-               printf("allowed write on read locked region (%s)\n", __location__);
+               torture_result(tctx, TORTURE_FAIL,
+                       "allowed write on read locked region (%s)\n", __location__);
                ret = false;
                goto done;
        }
@@ -1342,7 +1284,8 @@ static bool test_changetype(struct torture_context *tctx,
        CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRnoatomiclocks));
 
        if (smbcli_write(cli->tree, fnum, 0, &c, 100, 1) == 1) {
-               printf("allowed write after lock change (%s)\n", __location__);
+               torture_result(tctx, TORTURE_FAIL,
+                       "allowed write after lock change (%s)\n", __location__);
                ret = false;
                goto done;
        }
@@ -1403,7 +1346,7 @@ static bool test_zerobytelocks(struct torture_context *tctx, struct smbcli_state
        int fnum, i;
        const char *fname = BASEDIR "\\zero.txt";
 
-       printf("Testing zero length byte range locks:\n");
+       torture_comment(tctx, "Testing zero length byte range locks:\n");
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return false;
@@ -1412,11 +1355,9 @@ static bool test_zerobytelocks(struct torture_context *tctx, struct smbcli_state
        io.generic.level = RAW_LOCK_LOCKX;
 
        fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum == -1) {
-               printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+                      "Failed to create %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
 
        /* Setup initial parameters */
        io.lockx.level = RAW_LOCK_LOCKX;
@@ -1430,7 +1371,7 @@ static bool test_zerobytelocks(struct torture_context *tctx, struct smbcli_state
        for (i = 0;
             i < sizeof(zero_byte_tests) / sizeof(struct double_lock_test);
             i++) {
-               printf("  ... {%d, %llu, %llu} + {%d, %llu, %llu} = %s\n",
+               torture_comment(tctx, "  ... {%d, %llu, %llu} + {%d, %llu, %llu} = %s\n",
                    zero_byte_tests[i].lock1.pid,
                    zero_byte_tests[i].lock1.offset,
                    zero_byte_tests[i].lock1.count,
@@ -1494,24 +1435,21 @@ static bool test_unlock(struct torture_context *tctx, struct smbcli_state *cli)
        struct smb_lock_entry lock1;
        struct smb_lock_entry lock2;
 
-       printf("Testing LOCKX unlock:\n");
+       torture_comment(tctx, "Testing LOCKX unlock:\n");
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return false;
        }
 
        fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum1 == -1) {
-               printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum1 != -1), talloc_asprintf(tctx,
+                      "Failed to create %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
+
        fnum2 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum2 == -1) {
-               printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum2 != -1), talloc_asprintf(tctx,
+                      "Failed to create %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
 
        /* Setup initial parameters */
        io.lockx.level = RAW_LOCK_LOCKX;
@@ -1527,7 +1465,7 @@ static bool test_unlock(struct torture_context *tctx, struct smbcli_state *cli)
        /**
         * Take exclusive lock, then unlock it with a shared-unlock call.
         */
-       printf("  taking exclusive lock.\n");
+       torture_comment(tctx, "  taking exclusive lock.\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        io.lockx.in.mode = 0;
@@ -1536,7 +1474,7 @@ static bool test_unlock(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       printf("  unlock the exclusive with a shared unlock call.\n");
+       torture_comment(tctx, "  unlock the exclusive with a shared unlock call.\n");
        io.lockx.in.ulock_cnt = 1;
        io.lockx.in.lock_cnt = 0;
        io.lockx.in.mode = LOCKING_ANDX_SHARED_LOCK;
@@ -1545,7 +1483,7 @@ static bool test_unlock(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       printf("  try shared lock on pid2/fnum2, testing the unlock.\n");
+       torture_comment(tctx, "  try shared lock on pid2/fnum2, testing the unlock.\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        io.lockx.in.mode = LOCKING_ANDX_SHARED_LOCK;
@@ -1557,7 +1495,7 @@ static bool test_unlock(struct torture_context *tctx, struct smbcli_state *cli)
        /**
         * Unlock a shared lock with an exclusive-unlock call.
         */
-       printf("  unlock new shared lock with exclusive unlock call.\n");
+       torture_comment(tctx, "  unlock new shared lock with exclusive unlock call.\n");
        io.lockx.in.ulock_cnt = 1;
        io.lockx.in.lock_cnt = 0;
        io.lockx.in.mode = 0;
@@ -1566,7 +1504,7 @@ static bool test_unlock(struct torture_context *tctx, struct smbcli_state *cli)
        status = smb_raw_lock(cli->tree, &io);
        CHECK_STATUS(status, NT_STATUS_OK);
 
-       printf("  try exclusive lock on pid1, testing the unlock.\n");
+       torture_comment(tctx, "  try exclusive lock on pid1, testing the unlock.\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        io.lockx.in.mode = 0;
@@ -1585,7 +1523,7 @@ static bool test_unlock(struct torture_context *tctx, struct smbcli_state *cli)
         * Test unlocking of 0-byte locks.
         */
 
-       printf("  lock shared and exclusive 0-byte locks, testing that Windows "
+       torture_comment(tctx, "  lock shared and exclusive 0-byte locks, testing that Windows "
            "always unlocks the exclusive first.\n");
        lock1.pid = cli->session->pid;
        lock1.offset = 10;
@@ -1680,18 +1618,16 @@ static bool test_multiple_unlock(struct torture_context *tctx, struct smbcli_sta
        struct smb_lock_entry lock2;
        struct smb_lock_entry locks[2];
 
-       printf("Testing LOCKX multiple unlock:\n");
+       torture_comment(tctx, "Testing LOCKX multiple unlock:\n");
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return false;
        }
 
        fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum1 == -1) {
-               printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum1 != -1), talloc_asprintf(tctx,
+                      "Failed to create %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
 
        /* Setup initial parameters */
        io.lockx.level = RAW_LOCK_LOCKX;
@@ -1711,7 +1647,7 @@ static bool test_multiple_unlock(struct torture_context *tctx, struct smbcli_sta
        io.lockx.in.mode = 0; /* exclusive */
 
        /** Test1: Take second lock, but not first. */
-       printf("  unlock 2 locks, first one not locked. Expect no locks "
+       torture_comment(tctx, "  unlock 2 locks, first one not locked. Expect no locks "
            "unlocked. \n");
 
        io.lockx.in.ulock_cnt = 0;
@@ -1743,7 +1679,7 @@ static bool test_multiple_unlock(struct torture_context *tctx, struct smbcli_sta
        CHECK_STATUS(status, NT_STATUS_OK);
 
        /** Test2: Take first lock, but not second. */
-       printf("  unlock 2 locks, second one not locked. Expect first lock "
+       torture_comment(tctx, "  unlock 2 locks, second one not locked. Expect first lock "
            "unlocked.\n");
 
        io.lockx.in.ulock_cnt = 0;
@@ -1796,7 +1732,7 @@ static bool test_stacking(struct torture_context *tctx, struct smbcli_state *cli
        struct smb_lock_entry lock1;
        struct smb_lock_entry lock2;
 
-       printf("Testing stacking:\n");
+       torture_comment(tctx, "Testing stacking:\n");
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return false;
@@ -1805,11 +1741,9 @@ static bool test_stacking(struct torture_context *tctx, struct smbcli_state *cli
        io.generic.level = RAW_LOCK_LOCKX;
 
        fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (fnum1 == -1) {
-               printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
-               ret = false;
-               goto done;
-       }
+       torture_assert(tctx,(fnum1 != -1), talloc_asprintf(tctx,
+                      "Failed to create %s - %s\n",
+                      fname, smbcli_errstr(cli->tree)));
 
        /* Setup initial parameters */
        io.lockx.level = RAW_LOCK_LOCKX;
@@ -1825,7 +1759,7 @@ static bool test_stacking(struct torture_context *tctx, struct smbcli_state *cli
        /**
         * Try to take a shared lock, then stack an exclusive.
         */
-       printf("  stacking an exclusive on top of a shared lock fails.\n");
+       torture_comment(tctx, "  stacking an exclusive on top of a shared lock fails.\n");
        io.lockx.in.file.fnum = fnum1;
        io.lockx.in.locks = &lock1;
 
@@ -1851,7 +1785,7 @@ static bool test_stacking(struct torture_context *tctx, struct smbcli_state *cli
        /**
         * Prove that two exclusive locks do not stack.
         */
-       printf("  two exclusive locks do not stack.\n");
+       torture_comment(tctx, "  two exclusive locks do not stack.\n");
        io.lockx.in.ulock_cnt = 0;
        io.lockx.in.lock_cnt = 1;
        io.lockx.in.mode = 0;