s4:torture:raw:notify: remove superfluous conditional goto
[kai/samba-autobuild/.git] / source4 / torture / raw / notify.c
index effe8ebfde83e34e32611d94d91914adc85c772c..023ce5c8e1b94988bb16eab87d50a8d3e30f9d18 100644 (file)
 
 #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)
 
 /* 
@@ -53,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(mem_ctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /*
          get a handle on the directory
@@ -369,10 +367,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(mem_ctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /*
          get a handle on the directory
@@ -556,9 +553,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(mem_ctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /*
          get a handle on the directory
@@ -679,10 +675,6 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
        CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subname3-r",
                   STR_UNICODE);
 
-       if (!ret) {
-               goto done;
-       }
-
 done:
        smb_raw_exit(cli->session);
        smbcli_deltree(cli->tree, BASEDIR);
@@ -711,9 +703,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);
@@ -955,9 +946,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(mem_ctx, 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;
@@ -1026,13 +1016,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
@@ -1098,13 +1086,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
@@ -1169,13 +1155,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
@@ -1247,13 +1231,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
@@ -1314,10 +1296,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(mem_ctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
+
        /*
          get a handle on the directory
        */
@@ -1424,9 +1406,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(mem_ctx, 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;
@@ -1543,9 +1524,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(mem_ctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /* get a handle on the directory */
        io.generic.level = RAW_OPEN_NTCREATEX;
@@ -1631,9 +1611,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(mem_ctx, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /* get a handle on the directory */
        io.generic.level = RAW_OPEN_NTCREATEX;
@@ -1748,10 +1727,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(torture, torture_setup_dir(cli, BASEDIR),
+                      "Failed to setup up test directory: " BASEDIR);
 
        /*
          get a handle on the directory
@@ -1927,9 +1905,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;
@@ -1947,7 +1924,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 */
@@ -1965,7 +1942,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
@@ -1985,7 +1962,7 @@ 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, "");