s4-torture: use tctx variable name in raw notify test consistently.
[kai/samba-autobuild/.git] / source4 / torture / raw / notify.c
index a9baed60be450f155f39957a19c34083830b86e0..7b2eded823c15b2edd34e796d044926a82c1b248 100644 (file)
 
 #define BASEDIR "\\test_notify"
 
-#define CHECK_STATUS(status, correct) do { \
-       if (!NT_STATUS_EQUAL(status, correct)) { \
-               printf("(%d) Incorrect status %s - should be %s\n", \
-                      __LINE__, nt_errstr(status), nt_errstr(correct)); \
-               ret = false; \
-               goto done; \
-       }} while (0)
-
-
-#define CHECK_VAL(v, correct) do { \
-       if ((v) != (correct)) { \
-               printf("(%d) wrong value for %s  0x%x should be 0x%x\n", \
-                      __LINE__, #v, (int)v, (int)correct); \
-               ret = false; \
-               goto done; \
-       }} while (0)
-
-#define CHECK_WSTR(field, value, flags) do { \
-       if (!field.s || strcmp(field.s, value) || wire_bad_flags(&field, flags, cli->transport)) { \
-               printf("(%d) %s [%s] != %s\n",  __LINE__, #field, field.s, value); \
-                       ret = false; \
-               goto done; \
-       }} while (0)
-
-#define CHECK_WSTR2(tctx, field, value, flags) \
+#define CHECK_WSTR(tctx, field, value, flags) \
 do { \
-       if (!field.s || strcmp(field.s, value) || \
-           wire_bad_flags(&field, flags, cli->transport)) { \
-               torture_result(tctx, TORTURE_FAIL, \
-                   "(%d) %s [%s] != %s\n",  __LINE__, #field, field.s, value); \
-       } \
+       torture_assert_str_equal(tctx, field.s, value, "values don't match"); \
+       torture_assert(tctx, \
+                      !wire_bad_flags(&field, STR_UNICODE, cli->transport), \
+                      "wire_bad_flags"); \
 } while (0)
 
 /* 
    basic testing of change notify on directories
 */
-static bool test_notify_dir(struct torture_context *mem_ctx,
+static bool test_notify_dir(struct torture_context *tctx,
                            struct smbcli_state *cli,
                            struct smbcli_state *cli2)
 {
@@ -77,10 +52,9 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
        extern int torture_numops;
 
        printf("TESTING CHANGE NOTIFY ON DIRECTORIES\n");
-               
-       if (!torture_setup_dir(cli, BASEDIR)) {
-               return false;
-       }
+
+       torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /*
          get a handle on the directory
@@ -98,12 +72,14 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
        io.ntcreatex.in.security_flags = 0;
        io.ntcreatex.in.fname = BASEDIR;
 
-       status = smb_raw_open(cli->tree, mem_ctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       status = smb_raw_open(cli->tree, tctx, &io);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
-       status = smb_raw_open(cli->tree, mem_ctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       status = smb_raw_open(cli->tree, tctx, &io);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum2 = io.ntcreatex.out.file.fnum;
 
        /* ask for a change notify,
@@ -118,31 +94,45 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
 
        req = smb_raw_changenotify_send(cli->tree, &notify);
        smb_raw_ntcancel(req);
-       status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_CANCELLED);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_CANCELLED,
+                                          ret, done,
+                                          "smb_raw_changenotify_recv");
 
        printf("Testing notify mkdir\n");
 
        req = smb_raw_changenotify_send(cli->tree, &notify);
        smbcli_mkdir(cli2->tree, BASEDIR "\\subdir-name");
 
-       status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_ADDED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "more than one change");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_ADDED, ret, done,
+                                     "wrong action (exp: ADDED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subdir-name",
+                  STR_UNICODE);
 
        printf("Testing notify rmdir\n");
 
        req = smb_raw_changenotify_send(cli->tree, &notify);
        smbcli_rmdir(cli2->tree, BASEDIR "\\subdir-name");
 
-       status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "more than one change");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_REMOVED, ret, done,
+                                     "wrong action (exp: REMOVED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subdir-name",
+                  STR_UNICODE);
 
        printf("Testing notify mkdir - rmdir - mkdir - rmdir\n");
 
@@ -152,29 +142,44 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
        smbcli_rmdir(cli2->tree, BASEDIR "\\subdir-name");
        smb_msleep(200);
        req = smb_raw_changenotify_send(cli->tree, &notify);
-       status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 4);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_ADDED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
-       CHECK_VAL(notify.nttrans.out.changes[1].action, NOTIFY_ACTION_REMOVED);
-       CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name", STR_UNICODE);
-       CHECK_VAL(notify.nttrans.out.changes[2].action, NOTIFY_ACTION_ADDED);
-       CHECK_WSTR(notify.nttrans.out.changes[2].name, "subdir-name", STR_UNICODE);
-       CHECK_VAL(notify.nttrans.out.changes[3].action, NOTIFY_ACTION_REMOVED);
-       CHECK_WSTR(notify.nttrans.out.changes[3].name, "subdir-name", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     4, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_ADDED, ret, done,
+                                     "wrong action (exp: ADDED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subdir-name",
+                  STR_UNICODE);
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[1].action,
+                                     NOTIFY_ACTION_REMOVED, ret, done,
+                                     "wrong action (exp: REMOVED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[1].name, "subdir-name",
+                  STR_UNICODE);
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[2].action,
+                                     NOTIFY_ACTION_ADDED, ret, done,
+                                     "wrong action (exp: ADDED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[2].name, "subdir-name",
+                  STR_UNICODE);
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[3].action,
+                                     NOTIFY_ACTION_REMOVED, ret, done,
+                                     "wrong action (exp: REMOVED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[3].name, "subdir-name",
+                  STR_UNICODE);
 
        count = torture_numops;
        printf("Testing buffered notify on create of %d files\n", count);
        for (i=0;i<count;i++) {
                char *fname = talloc_asprintf(cli, BASEDIR "\\test%d.txt", i);
                int fnum3 = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
-               if (fnum3 == -1) {
-                       printf("Failed to create %s - %s\n", 
-                              fname, smbcli_errstr(cli->tree));
-                       ret = false;
-                       goto done;
-               }
+               torture_assert_int_not_equal_goto(tctx, fnum3, -1, ret, done,
+                       talloc_asprintf(tctx, "Failed to create %s - %s",
+                                       fname, smbcli_errstr(cli->tree)));
                talloc_free(fname);
                smbcli_close(cli->tree, fnum3);
        }
@@ -190,67 +195,106 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
        req = smb_raw_changenotify_send(cli->tree, &notify);
 
        status = smbcli_unlink(cli->tree, BASEDIR "\\nonexistent.txt");
-       CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_OBJECT_NAME_NOT_FOUND,
+                                          ret, done,
+                                          "smbcli_unlink");
 
        /* (1st unlink) as the 2nd notify directly returns,
           this unlink is only seen by the 1st notify and 
           the 3rd notify (later) */
        printf("Testing notify on unlink for the first file\n");
        status = smbcli_unlink(cli2->tree, BASEDIR "\\test0.txt");
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smbcli_unlink");
 
        /* receive the reply from the 2nd notify */
-       status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
 
-       CHECK_VAL(notify.nttrans.out.num_changes, count);
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     count, ret, done,
+                                     "wrong number of changes");
        for (i=1;i<count;i++) {
-               CHECK_VAL(notify.nttrans.out.changes[i].action, NOTIFY_ACTION_ADDED);
+               torture_assert_int_equal_goto(tctx,
+                                       notify.nttrans.out.changes[i].action,
+                                       NOTIFY_ACTION_ADDED, ret, done,
+                                       "wrong action (exp: ADDED)");
        }
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "test0.txt",
+                  STR_UNICODE);
 
        printf("and now from the 1st notify\n");
-       status = smb_raw_changenotify_recv(req2, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req2, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_REMOVED, ret, done,
+                                     "wrong action (exp: REMOVED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "test0.txt",
+                  STR_UNICODE);
 
        printf("(3rd notify) this notify will only see the 1st unlink\n");
        req = smb_raw_changenotify_send(cli->tree, &notify);
 
        status = smbcli_unlink(cli->tree, BASEDIR "\\nonexistent.txt");
-       CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_OBJECT_NAME_NOT_FOUND,
+                                          ret, done,
+                                          "smbcli_unlink");
 
        printf("Testing notify on wildcard unlink for %d files\n", count-1);
        /* (2nd unlink) do a wildcard unlink */
        status = smbcli_unlink(cli2->tree, BASEDIR "\\test*.txt");
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
 
        /* receive the 3rd notify */
-       status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_REMOVED, ret, done,
+                                     "wrong action (exp: REMOVED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "test0.txt",
+                  STR_UNICODE);
 
        /* and we now see the rest of the unlink calls on both directory handles */
        notify.nttrans.in.file.fnum = fnum;
        sleep(3);
        req = smb_raw_changenotify_send(cli->tree, &notify);
-       status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, count-1);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     count - 1, ret, done,
+                                     "wrong number of changes");
        for (i=0;i<notify.nttrans.out.num_changes;i++) {
-               CHECK_VAL(notify.nttrans.out.changes[i].action, NOTIFY_ACTION_REMOVED);
+               torture_assert_int_equal_goto(tctx,
+                                       notify.nttrans.out.changes[i].action,
+                                       NOTIFY_ACTION_REMOVED, ret, done,
+                                       "wrong action (exp: REMOVED)");
        }
        notify.nttrans.in.file.fnum = fnum2;
        req = smb_raw_changenotify_send(cli->tree, &notify);
-       status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, count-1);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     count - 1, ret, done,
+                                     "wrong number of changes");
        for (i=0;i<notify.nttrans.out.num_changes;i++) {
-               CHECK_VAL(notify.nttrans.out.changes[i].action, NOTIFY_ACTION_REMOVED);
+               torture_assert_int_equal_goto(tctx,
+                                       notify.nttrans.out.changes[i].action,
+                                       NOTIFY_ACTION_REMOVED, ret, done,
+                                       "wrong action (exp: REMOVED)");
        }
 
        printf("Testing if a close() on the dir handle triggers the notify reply\n");
@@ -262,11 +306,14 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
        cl.close.in.file.fnum = fnum;
        cl.close.in.write_time = 0;
        status = smb_raw_close(cli->tree, &cl);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_close");
 
-       status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 0);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     0, ret, done, "no changes expected");
 
 done:
        smb_raw_exit(cli->session);
@@ -281,7 +328,8 @@ done:
  * pair in any of the three following notify_changes.
  */
 
-static bool check_rename_reply(struct smbcli_state *cli,
+static bool check_rename_reply(struct torture_context *tctx,
+                              struct smbcli_state *cli,
                               int line,
                               struct notify_changes *actions,
                               uint32_t action, const char *name)
@@ -290,26 +338,21 @@ static bool check_rename_reply(struct smbcli_state *cli,
 
        for (i=0; i<3; i++) {
                if (actions[i].action == action) {
-                       if ((actions[i].name.s == NULL)
-                           || (strcmp(actions[i].name.s, name) != 0)
-                           || (wire_bad_flags(&actions[i].name, STR_UNICODE,
-                                              cli->transport))) {
-                               printf("(%d) name [%s] != %s\n", line,
-                                      actions[i].name.s, name);
-                               return false;
-                       }
+                       CHECK_WSTR(tctx, actions[i].name, name, STR_UNICODE);
                        return true;
                }
        }
 
-       printf("(%d) expected action %d, not found\n", line, action);
+       torture_result(tctx, TORTURE_FAIL,
+                      __location__": (%d) expected action %d, not found\n",
+                      line, action);
        return false;
 }
 
 /* 
    testing of recursive change notify
 */
-static bool test_notify_recursive(struct torture_context *mem_ctx,
+static bool test_notify_recursive(struct torture_context *tctx,
                                  struct smbcli_state *cli,
                                  struct smbcli_state *cli2)
 {
@@ -321,10 +364,9 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
        struct smbcli_request *req1, *req2;
 
        printf("TESTING CHANGE NOTIFY WITH RECURSION\n");
-               
-       if (!torture_setup_dir(cli, BASEDIR)) {
-               return false;
-       }
+
+       torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /*
          get a handle on the directory
@@ -342,8 +384,9 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
        io.ntcreatex.in.security_flags = 0;
        io.ntcreatex.in.fname = BASEDIR;
 
-       status = smb_raw_open(cli->tree, mem_ctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       status = smb_raw_open(cli->tree, tctx, &io);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
        /* ask for a change notify, on file or directory name
@@ -361,12 +404,18 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
 
        /* cancel initial requests so the buffer is setup */
        smb_raw_ntcancel(req1);
-       status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_CANCELLED);
+       status = smb_raw_changenotify_recv(req1, tctx, &notify);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_CANCELLED,
+                                          ret, done,
+                                          "smb_raw_changenotify_recv");
 
        smb_raw_ntcancel(req2);
-       status = smb_raw_changenotify_recv(req2, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_CANCELLED);
+       status = smb_raw_changenotify_recv(req2, tctx, &notify);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_CANCELLED,
+                                          ret, done,
+                                          "smb_raw_changenotify_recv");
 
        /*
         * Make notifies a bit more interesting in a cluster by doing
@@ -394,38 +443,60 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
        notify.nttrans.in.recursive = false;
        req2 = smb_raw_changenotify_send(cli->tree, &notify);
 
-       status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-
-       CHECK_VAL(notify.nttrans.out.num_changes, 11);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_ADDED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
-       CHECK_VAL(notify.nttrans.out.changes[1].action, NOTIFY_ACTION_ADDED);
-       CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name\\subname1", STR_UNICODE);
-       CHECK_VAL(notify.nttrans.out.changes[2].action, NOTIFY_ACTION_ADDED);
-       CHECK_WSTR(notify.nttrans.out.changes[2].name, "subdir-name\\subname2", STR_UNICODE);
-       CHECK_VAL(notify.nttrans.out.changes[3].action, NOTIFY_ACTION_OLD_NAME);
-       CHECK_WSTR(notify.nttrans.out.changes[3].name, "subdir-name\\subname1", STR_UNICODE);
-       CHECK_VAL(notify.nttrans.out.changes[4].action, NOTIFY_ACTION_NEW_NAME);
-       CHECK_WSTR(notify.nttrans.out.changes[4].name, "subdir-name\\subname1-r", STR_UNICODE);
-
-       ret &= check_rename_reply(
+       status = smb_raw_changenotify_recv(req1, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     11, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_ADDED, ret, done,
+                                     "wrong action (exp: ADDED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subdir-name",
+                  STR_UNICODE);
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[1].action,
+                                     NOTIFY_ACTION_ADDED, ret, done,
+                                     "wrong action (exp: ADDED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[1].name,
+                  "subdir-name\\subname1", STR_UNICODE);
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[2].action,
+                                     NOTIFY_ACTION_ADDED, ret, done,
+                                     "wrong action (exp: ADDED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[2].name,
+                  "subdir-name\\subname2", STR_UNICODE);
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[3].action,
+                                     NOTIFY_ACTION_OLD_NAME, ret, done,
+                                     "wrong action (exp: OLD_NAME)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[3].name,
+                  "subdir-name\\subname1", STR_UNICODE);
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[4].action,
+                                     NOTIFY_ACTION_NEW_NAME, ret, done,
+                                     "wrong action (exp: NEW_NAME)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[4].name,
+                  "subdir-name\\subname1-r", STR_UNICODE);
+
+       ret &= check_rename_reply(tctx,
                cli, __LINE__, &notify.nttrans.out.changes[5],
                NOTIFY_ACTION_ADDED, "subname2-r");
-       ret &= check_rename_reply(
+       ret &= check_rename_reply(tctx,
                cli, __LINE__, &notify.nttrans.out.changes[5],
                NOTIFY_ACTION_REMOVED, "subdir-name\\subname2");
-       ret &= check_rename_reply(
+       ret &= check_rename_reply(tctx,
                cli, __LINE__, &notify.nttrans.out.changes[5],
                NOTIFY_ACTION_MODIFIED, "subname2-r");
                
-       ret &= check_rename_reply(
+       ret &= check_rename_reply(tctx,
                cli, __LINE__, &notify.nttrans.out.changes[8],
                NOTIFY_ACTION_OLD_NAME, "subname2-r");
-       ret &= check_rename_reply(
+       ret &= check_rename_reply(tctx,
                cli, __LINE__, &notify.nttrans.out.changes[8],
                NOTIFY_ACTION_NEW_NAME, "subname3-r");
-       ret &= check_rename_reply(
+       ret &= check_rename_reply(tctx,
                cli, __LINE__, &notify.nttrans.out.changes[8],
                NOTIFY_ACTION_MODIFIED, "subname3-r");
 
@@ -433,16 +504,30 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
                goto done;
        }
 
-       status = smb_raw_changenotify_recv(req2, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-
-       CHECK_VAL(notify.nttrans.out.num_changes, 3);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name\\subname1-r", STR_UNICODE);
-       CHECK_VAL(notify.nttrans.out.changes[1].action, NOTIFY_ACTION_REMOVED);
-       CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name", STR_UNICODE);
-       CHECK_VAL(notify.nttrans.out.changes[2].action, NOTIFY_ACTION_REMOVED);
-       CHECK_WSTR(notify.nttrans.out.changes[2].name, "subname3-r", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req2, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     3, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_REMOVED, ret, done,
+                                     "wrong action (exp: REMOVED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name,
+                  "subdir-name\\subname1-r", STR_UNICODE);
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[1].action,
+                                     NOTIFY_ACTION_REMOVED, ret, done,
+                                     "wrong action (exp: REMOVED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[1].name, "subdir-name",
+                  STR_UNICODE);
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[2].action,
+                                     NOTIFY_ACTION_REMOVED, ret, done,
+                                     "wrong action (exp: REMOVED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[2].name, "subname3-r",
+                  STR_UNICODE);
 
 done:
        smb_raw_exit(cli->session);
@@ -453,7 +538,7 @@ done:
 /* 
    testing of change notify mask change
 */
-static bool test_notify_mask_change(struct torture_context *mem_ctx,
+static bool test_notify_mask_change(struct torture_context *tctx,
                                    struct smbcli_state *cli)
 {
        bool ret = true;
@@ -465,9 +550,8 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
 
        printf("TESTING CHANGE NOTIFY WITH MASK CHANGE\n");
 
-       if (!torture_setup_dir(cli, BASEDIR)) {
-               return false;
-       }
+       torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /*
          get a handle on the directory
@@ -485,8 +569,9 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
        io.ntcreatex.in.security_flags = 0;
        io.ntcreatex.in.fname = BASEDIR;
 
-       status = smb_raw_open(cli->tree, mem_ctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       status = smb_raw_open(cli->tree, tctx, &io);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
        /* ask for a change notify, on file or directory name
@@ -504,12 +589,18 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
 
        /* cancel initial requests so the buffer is setup */
        smb_raw_ntcancel(req1);
-       status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_CANCELLED);
+       status = smb_raw_changenotify_recv(req1, tctx, &notify);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_CANCELLED,
+                                          ret, done,
+                                          "smb_raw_changenotify_recv");
 
        smb_raw_ntcancel(req2);
-       status = smb_raw_changenotify_recv(req2, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_CANCELLED);
+       status = smb_raw_changenotify_recv(req2, tctx, &notify);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_CANCELLED,
+                                          ret, done,
+                                          "smb_raw_changenotify_recv");
 
        notify.nttrans.in.recursive = true;
        req1 = smb_raw_changenotify_send(cli->tree, &notify);
@@ -519,12 +610,18 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
        smbcli_setatr(cli->tree, BASEDIR "\\tname1", FILE_ATTRIBUTE_HIDDEN, 0);
        smbcli_unlink(cli->tree, BASEDIR "\\tname1");
 
-       status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       status = smb_raw_changenotify_recv(req1, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
 
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_MODIFIED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "tname1", STR_UNICODE);
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_MODIFIED, ret, done,
+                                     "wrong action (exp: MODIFIED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "tname1",
+                  STR_UNICODE);
 
        /* Now try and change the mask to include other events.
         * This should not work - once the mask is set on a directory
@@ -549,23 +646,31 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
        smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name");
        smbcli_unlink(cli->tree, BASEDIR "\\subname3-r");
 
-       status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_MODIFIED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subname2-r", STR_UNICODE);
-
-       status = smb_raw_changenotify_recv(req2, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_MODIFIED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subname3-r", STR_UNICODE);
-
-       if (!ret) {
-               goto done;
-       }
+       status = smb_raw_changenotify_recv(req1, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_MODIFIED, ret, done,
+                                     "wrong action (exp: MODIFIED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subname2-r",
+                  STR_UNICODE);
+
+       status = smb_raw_changenotify_recv(req2, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_MODIFIED, ret, done,
+                                     "wrong action (exp: MODIFIED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subname3-r",
+                  STR_UNICODE);
 
 done:
        smb_raw_exit(cli->session);
@@ -595,9 +700,8 @@ static bool test_notify_mask(struct torture_context *tctx,
 
        printf("TESTING CHANGE NOTIFY COMPLETION FILTERS\n");
 
-       if (!torture_setup_dir(cli, BASEDIR)) {
-               return false;
-       }
+       torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        tv = timeval_current_ofs(1000, 0);
        t = timeval_to_nttime(&tv);
@@ -627,10 +731,11 @@ static bool test_notify_mask(struct torture_context *tctx,
 #define NOTIFY_MASK_TEST(test_name, setup, op, cleanup, Action, expected, nchanges) \
        do { \
        smbcli_getatr(cli->tree, test_name, NULL, NULL, NULL); \
-       do { for (mask=i=0;i<32;i++) { \
+       for (mask=i=0;i<32;i++) { \
                struct smbcli_request *req; \
                status = smb_raw_open(cli->tree, tctx, &io); \
-               CHECK_STATUS(status, NT_STATUS_OK); \
+               torture_assert_ntstatus_ok_goto(tctx, status, ret, done, \
+                                               "smb_raw_open"); \
                fnum = io.ntcreatex.out.file.fnum; \
                setup \
                notify.nttrans.in.file.fnum = fnum;     \
@@ -643,48 +748,54 @@ static bool test_notify_mask(struct torture_context *tctx,
                cleanup \
                smbcli_close(cli->tree, fnum); \
                if (NT_STATUS_EQUAL(status, NT_STATUS_CANCELLED)) continue; \
-               CHECK_STATUS(status, NT_STATUS_OK); \
+               torture_assert_ntstatus_ok_goto(tctx, status, ret, done, \
+                                               "smbcli_close"); \
                /* special case to cope with file rename behaviour */ \
                if (nchanges == 2 && notify.nttrans.out.num_changes == 1 && \
                    notify.nttrans.out.changes[0].action == NOTIFY_ACTION_MODIFIED && \
                    ((expected) & FILE_NOTIFY_CHANGE_ATTRIBUTES) && \
                    Action == NOTIFY_ACTION_OLD_NAME) { \
                        printf("(rename file special handling OK)\n"); \
-               } else if (nchanges != notify.nttrans.out.num_changes) { \
-                       printf("ERROR: nchanges=%d expected=%d action=%d filter=0x%08x\n", \
-                              notify.nttrans.out.num_changes, \
-                              nchanges, \
-                              notify.nttrans.out.changes[0].action, \
-                              notify.nttrans.in.completion_filter); \
-                       ret = false; \
-               } else if (notify.nttrans.out.changes[0].action != Action) { \
-                       printf("ERROR: nchanges=%d action=%d expectedAction=%d filter=0x%08x\n", \
-                              notify.nttrans.out.num_changes, \
-                              notify.nttrans.out.changes[0].action, \
-                              Action, \
-                              notify.nttrans.in.completion_filter); \
-                       ret = false; \
-               } else if (strcmp(notify.nttrans.out.changes[0].name.s, "tname1") != 0) { \
-                       printf("ERROR: nchanges=%d action=%d filter=0x%08x name=%s\n", \
-                              notify.nttrans.out.num_changes, \
-                              notify.nttrans.out.changes[0].action, \
-                              notify.nttrans.in.completion_filter, \
-                              notify.nttrans.out.changes[0].name.s);   \
-                       ret = false; \
+               } else { \
+                       torture_assert_int_equal_goto(tctx, \
+                               notify.nttrans.out.num_changes,\
+                               nchanges, ret, done, \
+                               talloc_asprintf(tctx, \
+                                       "nchanges=%d expected=%d action=%d " \
+                                       "filter=0x%08x\n", \
+                                       notify.nttrans.out.num_changes, \
+                                       nchanges, \
+                                       notify.nttrans.out.changes[0].action, \
+                                       notify.nttrans.in.completion_filter)); \
+                       torture_assert_int_equal_goto(tctx, \
+                               notify.nttrans.out.changes[0].action, \
+                               Action, ret, done, \
+                               talloc_asprintf(tctx, \
+                                       "nchanges=%d action=%d " \
+                                       "expectedAction=%d filter=0x%08x\n", \
+                                       notify.nttrans.out.num_changes, \
+                                       notify.nttrans.out.changes[0].action, \
+                                       Action, \
+                                       notify.nttrans.in.completion_filter)); \
+                       torture_assert_str_equal_goto(tctx, \
+                               notify.nttrans.out.changes[0].name.s, \
+                               "tname1", ret, done, \
+                               talloc_asprintf(tctx, \
+                                       "nchanges=%d action=%d filter=0x%08x " \
+                                       "name=%s expected_name=tname1\n", \
+                                       notify.nttrans.out.num_changes, \
+                                       notify.nttrans.out.changes[0].action, \
+                                       notify.nttrans.in.completion_filter, \
+                                       notify.nttrans.out.changes[0].name.s));\
                } \
                mask |= (1<<i); \
        } \
        if ((expected) != mask) { \
-               if (((expected) & ~mask) != 0) { \
-                       printf("ERROR: trigger on too few bits. mask=0x%08x expected=0x%08x\n", \
-                              mask, expected); \
-                       ret = false; \
-               } else { \
-                       printf("WARNING: trigger on too many bits. mask=0x%08x expected=0x%08x\n", \
-                              mask, expected); \
-               } \
+               torture_assert_int_not_equal_goto(tctx, ((expected) & ~mask), \
+                               0, ret, done, "Too few bits"); \
+               printf("WARNING: trigger on too many bits. mask=0x%08x expected=0x%08x\n", \
+                      mask, expected); \
        } \
-       } while (0); \
        } while (0);
 
        printf("Testing mkdir\n");
@@ -823,7 +934,7 @@ done:
 /*
   basic testing of change notify on files
 */
-static bool test_notify_file(struct torture_context *mem_ctx,
+static bool test_notify_file(struct torture_context *tctx,
                             struct smbcli_state *cli)
 {
        NTSTATUS status;
@@ -837,9 +948,8 @@ static bool test_notify_file(struct torture_context *mem_ctx,
 
        printf("TESTING CHANGE NOTIFY ON FILES\n");
 
-       if (!torture_setup_dir(cli, BASEDIR)) {
-               return false;
-       }
+       torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        io.generic.level = RAW_OPEN_NTCREATEX;
        io.ntcreatex.in.root_fid.fnum = 0;
@@ -853,8 +963,9 @@ static bool test_notify_file(struct torture_context *mem_ctx,
        io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
        io.ntcreatex.in.security_flags = 0;
        io.ntcreatex.in.fname = fname;
-       status = smb_raw_open(cli->tree, mem_ctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       status = smb_raw_open(cli->tree, tctx, &io);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
        /* ask for a change notify,
@@ -868,17 +979,22 @@ static bool test_notify_file(struct torture_context *mem_ctx,
        printf("Testing if notifies on file handles are invalid (should be)\n");
 
        req = smb_raw_changenotify_send(cli->tree, &notify);
-       status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_INVALID_PARAMETER,
+                                          ret, done,
+                                          "smb_raw_changenotify_recv");
 
        cl.close.level = RAW_CLOSE_CLOSE;
        cl.close.in.file.fnum = fnum;
        cl.close.in.write_time = 0;
        status = smb_raw_close(cli->tree, &cl);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_close");
 
        status = smbcli_unlink(cli->tree, fname);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smbcli_unlink");
 
 done:
        smb_raw_exit(cli->session);
@@ -902,13 +1018,11 @@ static bool test_notify_tdis(struct torture_context *tctx,
 
        printf("TESTING CHANGE NOTIFY FOLLOWED BY TDIS\n");
 
-       if (!torture_setup_dir(cli1, BASEDIR)) {
-               return false;
-       }
+       torture_assert(tctx, torture_setup_dir(cli1, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
-       if (!torture_open_connection(&cli, tctx, 0)) {
-               return false;
-       }
+       torture_assert(tctx, torture_open_connection(&cli, tctx, 0),
+                      "Failed to open connection.");
 
        /*
          get a handle on the directory
@@ -927,7 +1041,8 @@ static bool test_notify_tdis(struct torture_context *tctx,
        io.ntcreatex.in.fname = BASEDIR;
 
        status = smb_raw_open(cli->tree, tctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
        /* ask for a change notify,
@@ -941,12 +1056,15 @@ static bool test_notify_tdis(struct torture_context *tctx,
        req = smb_raw_changenotify_send(cli->tree, &notify);
 
        status = smbcli_tdis(cli);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smbcli_tdis");
        cli->tree = NULL;
 
        status = smb_raw_changenotify_recv(req, tctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 0);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     0, ret, done, "no changes expected");
 
 done:
        torture_close_connection(cli);
@@ -970,13 +1088,11 @@ static bool test_notify_exit(struct torture_context *tctx,
 
        printf("TESTING CHANGE NOTIFY FOLLOWED BY EXIT\n");
 
-       if (!torture_setup_dir(cli1, BASEDIR)) {
-               return false;
-       }
+       torture_assert(tctx, torture_setup_dir(cli1, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
-       if (!torture_open_connection(&cli, tctx, 0)) {
-               return false;
-       }
+       torture_assert(tctx, torture_open_connection(&cli, tctx, 0),
+                      "Failed to open connection.");
 
        /*
          get a handle on the directory
@@ -995,7 +1111,8 @@ static bool test_notify_exit(struct torture_context *tctx,
        io.ntcreatex.in.fname = BASEDIR;
 
        status = smb_raw_open(cli->tree, tctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
        /* ask for a change notify,
@@ -1009,11 +1126,14 @@ static bool test_notify_exit(struct torture_context *tctx,
        req = smb_raw_changenotify_send(cli->tree, &notify);
 
        status = smb_raw_exit(cli->session);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_exit");
 
        status = smb_raw_changenotify_recv(req, tctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 0);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     0, ret, done, "no changes expected");
 
 done:
        torture_close_connection(cli);
@@ -1037,13 +1157,11 @@ static bool test_notify_ulogoff(struct torture_context *tctx,
 
        printf("TESTING CHANGE NOTIFY FOLLOWED BY ULOGOFF\n");
 
-       if (!torture_setup_dir(cli1, BASEDIR)) {
-               return false;
-       }
+       torture_assert(tctx, torture_setup_dir(cli1, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
-       if (!torture_open_connection(&cli, tctx, 0)) {
-               return false;
-       }
+       torture_assert(tctx, torture_open_connection(&cli, tctx, 0),
+                      "Failed to open connection.");
 
        /*
          get a handle on the directory
@@ -1062,7 +1180,8 @@ static bool test_notify_ulogoff(struct torture_context *tctx,
        io.ntcreatex.in.fname = BASEDIR;
 
        status = smb_raw_open(cli->tree, tctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
        /* ask for a change notify,
@@ -1076,11 +1195,14 @@ static bool test_notify_ulogoff(struct torture_context *tctx,
        req = smb_raw_changenotify_send(cli->tree, &notify);
 
        status = smb_raw_ulogoff(cli->session);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_ulogoff");
 
        status = smb_raw_changenotify_recv(req, tctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 0);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     0, ret, done, "no changes expected");
 
 done:
        torture_close_connection(cli);
@@ -1111,13 +1233,11 @@ static bool test_notify_tcp_dis(struct torture_context *tctx,
 
        printf("TESTING CHANGE NOTIFY FOLLOWED BY TCP DISCONNECT\n");
 
-       if (!torture_setup_dir(cli1, BASEDIR)) {
-               return false;
-       }
+       torture_assert(tctx, torture_setup_dir(cli1, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
-       if (!torture_open_connection(&cli, tctx, 0)) {
-               return false;
-       }
+       torture_assert(tctx, torture_open_connection(&cli, tctx, 0),
+                      "Failed to open connection.");
 
        /*
          get a handle on the directory
@@ -1136,7 +1256,8 @@ static bool test_notify_tcp_dis(struct torture_context *tctx,
        io.ntcreatex.in.fname = BASEDIR;
 
        status = smb_raw_open(cli->tree, tctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
        /* ask for a change notify,
@@ -1152,7 +1273,10 @@ static bool test_notify_tcp_dis(struct torture_context *tctx,
        smbcli_transport_idle_handler(cli->transport, tcp_dis_handler, 250, cli);
 
        status = smb_raw_changenotify_recv(req, tctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_LOCAL_DISCONNECT);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_LOCAL_DISCONNECT,
+                                          ret, done,
+                                          "smb_raw_changenotify_recv");
 
 done:
        torture_close_connection(cli);
@@ -1163,7 +1287,7 @@ done:
 /* 
    test setting up two change notify requests on one handle
 */
-static bool test_notify_double(struct torture_context *mem_ctx,
+static bool test_notify_double(struct torture_context *tctx,
                               struct smbcli_state *cli)
 {
        bool ret = true;
@@ -1174,10 +1298,10 @@ static bool test_notify_double(struct torture_context *mem_ctx,
        struct smbcli_request *req1, *req2;
 
        printf("TESTING CHANGE NOTIFY TWICE ON ONE DIRECTORY\n");
-               
-       if (!torture_setup_dir(cli, BASEDIR)) {
-               return false;
-       }
+
+       torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
+
        /*
          get a handle on the directory
        */
@@ -1194,8 +1318,9 @@ static bool test_notify_double(struct torture_context *mem_ctx,
        io.ntcreatex.in.security_flags = 0;
        io.ntcreatex.in.fname = BASEDIR;
 
-       status = smb_raw_open(cli->tree, mem_ctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       status = smb_raw_open(cli->tree, tctx, &io);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
        /* ask for a change notify,
@@ -1211,17 +1336,23 @@ static bool test_notify_double(struct torture_context *mem_ctx,
 
        smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name");
 
-       status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req1, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subdir-name",
+                  STR_UNICODE);
 
        smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name2");
 
-       status = smb_raw_changenotify_recv(req2, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name2", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req2, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subdir-name2",
+                  STR_UNICODE);
 
 done:
        smb_raw_exit(cli->session);
@@ -1233,7 +1364,7 @@ done:
 /* 
    test multiple change notifies at different depths and with/without recursion
 */
-static bool test_notify_tree(struct torture_context *mem_ctx,
+static bool test_notify_tree(struct torture_context *tctx,
                             struct smbcli_state *cli,
                             struct smbcli_state *cli2)
 {
@@ -1277,9 +1408,8 @@ static bool test_notify_tree(struct torture_context *mem_ctx,
 
        printf("TESTING CHANGE NOTIFY FOR DIFFERENT DEPTHS\n");
 
-       if (!torture_setup_dir(cli, BASEDIR)) {
-               return false;
-       }
+       torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        io.generic.level = RAW_OPEN_NTCREATEX;
        io.ntcreatex.in.root_fid.fnum = 0;
@@ -1301,8 +1431,9 @@ static bool test_notify_tree(struct torture_context *mem_ctx,
        */
        for (i=0;i<ARRAY_SIZE(dirs);i++) {
                io.ntcreatex.in.fname = dirs[i].path;
-               status = smb_raw_open(cli->tree, mem_ctx, &io);
-               CHECK_STATUS(status, NT_STATUS_OK);
+               status = smb_raw_open(cli->tree, tctx, &io);
+               torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                               "smb_raw_open");
                dirs[i].fnum = io.ntcreatex.out.file.fnum;
 
                notify.nttrans.in.completion_filter = dirs[i].filter;
@@ -1310,13 +1441,16 @@ static bool test_notify_tree(struct torture_context *mem_ctx,
                notify.nttrans.in.recursive = dirs[i].recursive;
                req = smb_raw_changenotify_send(cli->tree, &notify);
                smb_raw_ntcancel(req);
-               status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
-               CHECK_STATUS(status, NT_STATUS_CANCELLED);
+               status = smb_raw_changenotify_recv(req, tctx, &notify);
+               torture_assert_ntstatus_equal_goto(tctx, status,
+                                                  NT_STATUS_CANCELLED,
+                                                  ret, done,
+                                                  "smb_raw_changenotify_recv");
        }
 
        /* trigger 2 events in each dir */
        for (i=0;i<ARRAY_SIZE(dirs);i++) {
-               char *path = talloc_asprintf(mem_ctx, "%s\\test.dir", dirs[i].path);
+               char *path = talloc_asprintf(tctx, "%s\\test.dir", dirs[i].path);
                /*
                 * Make notifies a bit more interesting in a cluster
                 * by doing the changes against different nodes with
@@ -1337,7 +1471,7 @@ static bool test_notify_tree(struct torture_context *mem_ctx,
                        req = smb_raw_changenotify_send(cli->tree, &notify);
                        smb_raw_ntcancel(req);
                        notify.nttrans.out.num_changes = 0;
-                       status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
+                       status = smb_raw_changenotify_recv(req, tctx, &notify);
                        dirs[i].counted += notify.nttrans.out.num_changes;
                }
                
@@ -1353,11 +1487,11 @@ static bool test_notify_tree(struct torture_context *mem_ctx,
        printf("took %.4f seconds to propogate all events\n", timeval_elapsed(&tv));
 
        for (i=0;i<ARRAY_SIZE(dirs);i++) {
-               if (dirs[i].counted != dirs[i].expected) {
-                       printf("ERROR: i=%d expected %d got %d for '%s'\n",
-                              i, dirs[i].expected, dirs[i].counted, dirs[i].path);
-                       ret = false;
-               }
+               torture_assert_int_equal_goto(tctx,
+                       dirs[i].counted, dirs[i].expected, ret, done,
+                       talloc_asprintf(tctx,
+                                       "unexpected number of events for '%s'",
+                                       dirs[i].path));
        }
 
        /*
@@ -1378,7 +1512,7 @@ done:
    Test response when cached server events exceed single NT NOTFIY response
    packet size.
 */
-static bool test_notify_overflow(struct torture_context *mem_ctx,
+static bool test_notify_overflow(struct torture_context *tctx,
                                 struct smbcli_state *cli)
 {
        bool ret = true;
@@ -1392,9 +1526,8 @@ static bool test_notify_overflow(struct torture_context *mem_ctx,
 
        printf("TESTING CHANGE NOTIFY EVENT OVERFLOW\n");
 
-       if (!torture_setup_dir(cli, BASEDIR)) {
-               return false;
-       }
+       torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /* get a handle on the directory */
        io.generic.level = RAW_OPEN_NTCREATEX;
@@ -1411,8 +1544,9 @@ static bool test_notify_overflow(struct torture_context *mem_ctx,
        io.ntcreatex.in.security_flags = 0;
        io.ntcreatex.in.fname = BASEDIR;
 
-       status = smb_raw_open(cli->tree, mem_ctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       status = smb_raw_open(cli->tree, tctx, &io);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
        /* ask for a change notify, on name changes. */
@@ -1426,8 +1560,11 @@ static bool test_notify_overflow(struct torture_context *mem_ctx,
 
        /* cancel initial requests so the buffer is setup */
        smb_raw_ntcancel(req1);
-       status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_CANCELLED);
+       status = smb_raw_changenotify_recv(req1, tctx, &notify);
+       torture_assert_ntstatus_equal_goto(tctx, status,
+                                          NT_STATUS_CANCELLED,
+                                          ret, done,
+                                          "smb_raw_changenotify_recv");
 
        /* open a lot of files, filling up the server side notify buffer */
        printf("Testing overflowed buffer notify on create of %d files\n",
@@ -1436,21 +1573,20 @@ static bool test_notify_overflow(struct torture_context *mem_ctx,
                char *fname = talloc_asprintf(cli, BASEDIR "\\test%d.txt", i);
                int fnum2 = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR,
                                        DENY_NONE);
-               if (fnum2 == -1) {
-                       printf("Failed to create %s - %s\n",
-                              fname, smbcli_errstr(cli->tree));
-                       ret = false;
-                       goto done;
-               }
+               torture_assert_int_not_equal_goto(tctx, fnum2, -1, ret, done,
+                       talloc_asprintf(tctx, "Failed to create %s - %s",
+                                       fname, smbcli_errstr(cli->tree)));
                talloc_free(fname);
                smbcli_close(cli->tree, fnum2);
        }
 
        /* expect that 0 events will be returned with NT_STATUS_OK */
        req1 = smb_raw_changenotify_send(cli->tree, &notify);
-       status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 0);
+       status = smb_raw_changenotify_recv(req1, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     0, ret, done, "no changes expected");
 
 done:
        smb_raw_exit(cli->session);
@@ -1462,7 +1598,7 @@ done:
    Test if notifications are returned for changes to the base directory.
    They shouldn't be.
 */
-static bool test_notify_basedir(struct torture_context *mem_ctx,
+static bool test_notify_basedir(struct torture_context *tctx,
                                struct smbcli_state *cli)
 {
        bool ret = true;
@@ -1474,9 +1610,8 @@ static bool test_notify_basedir(struct torture_context *mem_ctx,
 
        printf("TESTING CHANGE NOTIFY BASEDIR EVENTS\n");
 
-       if (!torture_setup_dir(cli, BASEDIR)) {
-               return false;
-       }
+       torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /* get a handle on the directory */
        io.generic.level = RAW_OPEN_NTCREATEX;
@@ -1493,8 +1628,9 @@ static bool test_notify_basedir(struct torture_context *mem_ctx,
        io.ntcreatex.in.security_flags = 0;
        io.ntcreatex.in.fname = BASEDIR;
 
-       status = smb_raw_open(cli->tree, mem_ctx, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       status = smb_raw_open(cli->tree, tctx, &io);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
        /* create a test file that will also be modified */
@@ -1518,11 +1654,17 @@ static bool test_notify_basedir(struct torture_context *mem_ctx,
        smb_msleep(200);
 
        /* check how many responses were given, expect only 1 for the file */
-       status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_MODIFIED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "tname1", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req1, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of  changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_MODIFIED, ret, done,
+                                     "wrong action (exp: MODIFIED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "tname1",
+                  STR_UNICODE);
 
 done:
        smb_raw_exit(cli->session);
@@ -1571,7 +1713,7 @@ static struct smbcli_tree *secondary_tcon(struct smbcli_state *cli,
 /* 
    very simple change notify test
 */
-static bool test_notify_tcon(struct torture_context *torture,
+static bool test_notify_tcon(struct torture_context *tctx,
                             struct smbcli_state *cli)
 {
        bool ret = true;
@@ -1584,10 +1726,9 @@ static bool test_notify_tcon(struct torture_context *torture,
        struct smbcli_tree *tree = NULL;
                
        printf("TESTING SIMPLE CHANGE NOTIFY\n");
-               
-       if (!torture_setup_dir(cli, BASEDIR)) {
-               return false;
-       }
+
+       torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /*
          get a handle on the directory
@@ -1605,12 +1746,14 @@ static bool test_notify_tcon(struct torture_context *torture,
        io.ntcreatex.in.security_flags = 0;
        io.ntcreatex.in.fname = BASEDIR;
 
-       status = smb_raw_open(cli->tree, torture, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       status = smb_raw_open(cli->tree, tctx, &io);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
-       status = smb_raw_open(cli->tree, torture, &io);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       status = smb_raw_open(cli->tree, tctx, &io);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_open");
 
        /* ask for a change notify,
           on file or directory name changes */
@@ -1624,76 +1767,115 @@ static bool test_notify_tcon(struct torture_context *torture,
        req = smb_raw_changenotify_send(cli->tree, &notify);
        smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name");
 
-       status = smb_raw_changenotify_recv(req, torture, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_ADDED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_ADDED, ret, done,
+                                     "wrong action (exp: ADDED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subdir-name",
+                  STR_UNICODE);
 
        printf("Testing notify rmdir\n");
        req = smb_raw_changenotify_send(cli->tree, &notify);
        smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name");
 
-       status = smb_raw_changenotify_recv(req, torture, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_REMOVED, ret, done,
+                                     "wrong action (exp: REMOVED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subdir-name",
+                  STR_UNICODE);
 
        printf("SIMPLE CHANGE NOTIFY OK\n");
 
        printf("TESTING WITH SECONDARY TCON\n");
-       tree = secondary_tcon(cli, torture);
+       tree = secondary_tcon(cli, tctx);
+       torture_assert_not_null_goto(tctx, tree, ret, done,
+                                    "failed to create secondary tcon");
 
        printf("Testing notify mkdir\n");
        req = smb_raw_changenotify_send(cli->tree, &notify);
        smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name");
 
-       status = smb_raw_changenotify_recv(req, torture, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_ADDED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_ADDED, ret, done,
+                                     "wrong action (exp: ADDED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subdir-name",
+                  STR_UNICODE);
 
        printf("Testing notify rmdir\n");
        req = smb_raw_changenotify_send(cli->tree, &notify);
        smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name");
 
-       status = smb_raw_changenotify_recv(req, torture, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_REMOVED, ret, done,
+                                     "wrong action (exp: REMOVED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subdir-name",
+                  STR_UNICODE);
 
        printf("CHANGE NOTIFY WITH TCON OK\n");
 
        printf("Disconnecting secondary tree\n");
        status = smb_tree_disconnect(tree);
-       CHECK_STATUS(status, NT_STATUS_OK);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_tree_disconnect");
        talloc_free(tree);
 
        printf("Testing notify mkdir\n");
        req = smb_raw_changenotify_send(cli->tree, &notify);
        smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name");
 
-       status = smb_raw_changenotify_recv(req, torture, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_ADDED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_ADDED, ret, done,
+                                     "wrong action (exp: ADDED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subdir-name",
+                  STR_UNICODE);
 
        printf("Testing notify rmdir\n");
        req = smb_raw_changenotify_send(cli->tree, &notify);
        smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name");
 
-       status = smb_raw_changenotify_recv(req, torture, &notify);
-       CHECK_STATUS(status, NT_STATUS_OK);
-       CHECK_VAL(notify.nttrans.out.num_changes, 1);
-       CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED);
-       CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+       status = smb_raw_changenotify_recv(req, tctx, &notify);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb_raw_changenotify_recv");
+       torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+                                     1, ret, done, "wrong number of changes");
+       torture_assert_int_equal_goto(tctx,
+                                     notify.nttrans.out.changes[0].action,
+                                     NOTIFY_ACTION_REMOVED, ret, done,
+                                     "wrong action (exp: REMOVED)");
+       CHECK_WSTR(tctx, notify.nttrans.out.changes[0].name, "subdir-name",
+                  STR_UNICODE);
 
        printf("CHANGE NOTIFY WITH TDIS OK\n");
 done:
@@ -1724,9 +1906,8 @@ static bool test_notify_alignment(struct torture_context *tctx,
 
        torture_comment(tctx, "TESTING CHANGE NOTIFY REPLY ALIGNMENT\n");
 
-       if (!torture_setup_dir(cli, BASEDIR)) {
-               return false;
-       }
+       torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /* get a handle on the directory */
        io.generic.level = RAW_OPEN_NTCREATEX;
@@ -1744,7 +1925,7 @@ static bool test_notify_alignment(struct torture_context *tctx,
        io.ntcreatex.in.fname = BASEDIR;
 
        status = smb_raw_open(cli->tree, tctx, &io);
-       torture_assert_ntstatus_ok(tctx, status, "");
+       torture_assert_ntstatus_ok(tctx, status, "smb_raw_open");
        fnum = io.ntcreatex.out.file.fnum;
 
        /* ask for a change notify, on file creation */
@@ -1762,7 +1943,7 @@ static bool test_notify_alignment(struct torture_context *tctx,
        smbcli_close(cli->tree, fnum2);
 
        status = smb_raw_changenotify_recv(req, tctx, &notify);
-       torture_assert_ntstatus_ok(tctx, status, "");
+       torture_assert_ntstatus_ok(tctx, status, "smb_raw_changenotify_recv");
 
        /* create 4 files that will cause CHANGE_NOTIFY_INFO structures
         * to be returned in the same packet with all possible 4-byte padding
@@ -1782,14 +1963,14 @@ static bool test_notify_alignment(struct torture_context *tctx,
         * the alignment checking for us. */
        req = smb_raw_changenotify_send(cli->tree, &notify);
        status = smb_raw_changenotify_recv(req, tctx, &notify);
-       torture_assert_ntstatus_ok(tctx, status, "");
+       torture_assert_ntstatus_ok(tctx, status, "smb_raw_changenotify_recv");
 
        /* Do basic checking for correctness. */
        torture_assert(tctx, notify.nttrans.out.num_changes == num_names, "");
        for (i = 0; i < num_names; i++) {
                torture_assert(tctx, notify.nttrans.out.changes[i].action ==
                    NOTIFY_ACTION_ADDED, "");
-               CHECK_WSTR2(tctx, notify.nttrans.out.changes[i].name, fnames[i],
+               CHECK_WSTR(tctx, notify.nttrans.out.changes[i].name, fnames[i],
                    STR_UNICODE);
        }