s4:torture:raw:notify: make check_rename_reply() properly use torture_result
authorMichael Adam <obnox@samba.org>
Thu, 26 Mar 2015 18:08:26 +0000 (19:08 +0100)
committerGünther Deschner <gd@samba.org>
Mon, 30 Mar 2015 11:41:26 +0000 (13:41 +0200)
Only change currently: the CHECK_WSTR calls report the line
number of this function now instead of the handed in
line of the callers. This could be fixed by turning this
function into a macro...

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source4/torture/raw/notify.c

index a54007a5e3cedfdaacddbac74813b89ae0ce0a5a..effe8ebfde83e34e32611d94d91914adc85c772c 100644 (file)
@@ -333,7 +333,8 @@ done:
  * pair in any of the three following notify_changes.
  */
 
  * 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)
                               int line,
                               struct notify_changes *actions,
                               uint32_t action, const char *name)
@@ -342,19 +343,14 @@ static bool check_rename_reply(struct smbcli_state *cli,
 
        for (i=0; i<3; i++) {
                if (actions[i].action == action) {
 
        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;
                }
        }
 
                        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;
 }
 
        return false;
 }
 
@@ -490,23 +486,23 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
        CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[4].name,
                   "subdir-name\\subname1-r", STR_UNICODE);
 
        CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[4].name,
                   "subdir-name\\subname1-r", STR_UNICODE);
 
-       ret &= check_rename_reply(
+       ret &= check_rename_reply(mem_ctx,
                cli, __LINE__, &notify.nttrans.out.changes[5],
                NOTIFY_ACTION_ADDED, "subname2-r");
                cli, __LINE__, &notify.nttrans.out.changes[5],
                NOTIFY_ACTION_ADDED, "subname2-r");
-       ret &= check_rename_reply(
+       ret &= check_rename_reply(mem_ctx,
                cli, __LINE__, &notify.nttrans.out.changes[5],
                NOTIFY_ACTION_REMOVED, "subdir-name\\subname2");
                cli, __LINE__, &notify.nttrans.out.changes[5],
                NOTIFY_ACTION_REMOVED, "subdir-name\\subname2");
-       ret &= check_rename_reply(
+       ret &= check_rename_reply(mem_ctx,
                cli, __LINE__, &notify.nttrans.out.changes[5],
                NOTIFY_ACTION_MODIFIED, "subname2-r");
                
                cli, __LINE__, &notify.nttrans.out.changes[5],
                NOTIFY_ACTION_MODIFIED, "subname2-r");
                
-       ret &= check_rename_reply(
+       ret &= check_rename_reply(mem_ctx,
                cli, __LINE__, &notify.nttrans.out.changes[8],
                NOTIFY_ACTION_OLD_NAME, "subname2-r");
                cli, __LINE__, &notify.nttrans.out.changes[8],
                NOTIFY_ACTION_OLD_NAME, "subname2-r");
-       ret &= check_rename_reply(
+       ret &= check_rename_reply(mem_ctx,
                cli, __LINE__, &notify.nttrans.out.changes[8],
                NOTIFY_ACTION_NEW_NAME, "subname3-r");
                cli, __LINE__, &notify.nttrans.out.changes[8],
                NOTIFY_ACTION_NEW_NAME, "subname3-r");
-       ret &= check_rename_reply(
+       ret &= check_rename_reply(mem_ctx,
                cli, __LINE__, &notify.nttrans.out.changes[8],
                NOTIFY_ACTION_MODIFIED, "subname3-r");
 
                cli, __LINE__, &notify.nttrans.out.changes[8],
                NOTIFY_ACTION_MODIFIED, "subname3-r");