[PATCHES] let the raw.notify test use torture_asserts.
Michael Adam
obnox at samba.org
Fri Mar 27 03:49:47 MDT 2015
Hi,
the samba3.raw.notify test fails for me sometimes.
But since the code is not using torture_assert/torture_result
macros (using printfs and return instead), one can not
really tell what is going on.
Attached find a patchset that cleans up the notify test to
use torture_assert macros consistently. (the first two
patches also add some macros that I found useful).
Review/push appreciated.
Michael
-------------- next part --------------
From 756553089e3ac7ba1aabe6a54363235c2783adba Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 27 Mar 2015 10:02:28 +0100
Subject: [PATCH 01/16] torture: add torture_assert_int_not_equal_goto
Signed-off-by: Michael Adam <obnox at samba.org>
---
lib/torture/torture.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index d6a9217..efdba18 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -424,6 +424,17 @@ void torture_result(struct torture_context *test,
} \
} while(0)
+#define torture_assert_int_not_equal_goto(torture_ctx,got,not_expected,ret,label,cmt)\
+ do { int __got = (got), __not_expected = (not_expected); \
+ if (__got == __not_expected) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %d (0x%X), expected a different number: %s", \
+ __got, __got, cmt); \
+ ret = false; \
+ goto label; \
+ } \
+ } while(0)
+
#define torture_assert_u64_equal(torture_ctx,got,expected,cmt)\
do { uint64_t __got = (got), __expected = (expected); \
if (__got != __expected) { \
--
2.1.0
From 83ed6c76c9756e88442b53636c5b97ba27747158 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 26 Mar 2015 21:20:23 +0100
Subject: [PATCH 02/16] torture: add torture_assert_not_null[_goto]
Signed-off-by: Michael Adam <obnox at samba.org>
---
lib/torture/torture.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index efdba18..b90af84 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -500,6 +500,27 @@ void torture_result(struct torture_context *test,
}\
} while(0)
+#define torture_assert_not_null(torture_ctx,got,cmt)\
+ do { void *__got = (got); \
+ if (__got == NULL) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was NULL, expected != NULL: %s", \
+ cmt); \
+ return false; \
+ } \
+ } while(0)
+
+#define torture_assert_not_null_goto(torture_ctx,got,ret,label,cmt)\
+ do { void *__got = (got); \
+ if (__got == NULL) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was NULL, expected != NULL: %s", \
+ cmt); \
+ ret = false; \
+ goto label; \
+ } \
+ } while(0)
+
#define torture_skip(torture_ctx,cmt) do {\
torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
return true; \
--
2.1.0
From 79a697e5096b4d1107d5caaa70768f254a740c77 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 26 Mar 2015 12:00:15 +0100
Subject: [PATCH 03/16] s4:torture:raw:notify: remove CHECK_STATUS.
This macro is not setting torture failure, leading to errors instead
of failures. Use torture_assert_ntstatus_(ok|equal)* macros.
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 222 +++++++++++++++++++++++++++++--------------
1 file changed, 149 insertions(+), 73 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index a9baed6..a47dddd 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -27,15 +27,6 @@
#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", \
@@ -99,11 +90,13 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
io.ntcreatex.in.fname = BASEDIR;
status = smb_raw_open(cli->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, 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);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_open");
fnum2 = io.ntcreatex.out.file.fnum;
/* ask for a change notify,
@@ -119,7 +112,9 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
req = smb_raw_changenotify_send(cli->tree, ¬ify);
smb_raw_ntcancel(req);
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_CANCELLED);
+ torture_assert_ntstatus_equal_goto(mem_ctx, status, NT_STATUS_CANCELLED,
+ ret, done,
+ "smb_raw_changenotify_recv");
printf("Testing notify mkdir\n");
@@ -127,7 +122,8 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
smbcli_mkdir(cli2->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, 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_ADDED);
@@ -139,7 +135,8 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
smbcli_rmdir(cli2->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, 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_REMOVED);
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
@@ -153,7 +150,8 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
smb_msleep(200);
req = smb_raw_changenotify_send(cli->tree, ¬ify);
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_changenotify_recv");
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);
@@ -190,18 +188,23 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
req = smb_raw_changenotify_send(cli->tree, ¬ify);
status = smbcli_unlink(cli->tree, BASEDIR "\\nonexistent.txt");
- CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+ torture_assert_ntstatus_equal_goto(mem_ctx, 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(mem_ctx, status, ret, done,
+ "smbcli_unlink");
/* receive the reply from the 2nd notify */
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_changenotify_recv");
CHECK_VAL(notify.nttrans.out.num_changes, count);
for (i=1;i<count;i++) {
@@ -211,7 +214,8 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
printf("and now from the 1st notify\n");
status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, 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_REMOVED);
CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
@@ -220,16 +224,21 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
req = smb_raw_changenotify_send(cli->tree, ¬ify);
status = smbcli_unlink(cli->tree, BASEDIR "\\nonexistent.txt");
- CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+ torture_assert_ntstatus_equal_goto(mem_ctx, 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(mem_ctx, status, ret, done,
+ "smb_raw_changenotify_recv");
/* receive the 3rd notify */
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, 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_REMOVED);
CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
@@ -239,7 +248,8 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
sleep(3);
req = smb_raw_changenotify_send(cli->tree, ¬ify);
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_changenotify_recv");
CHECK_VAL(notify.nttrans.out.num_changes, count-1);
for (i=0;i<notify.nttrans.out.num_changes;i++) {
CHECK_VAL(notify.nttrans.out.changes[i].action, NOTIFY_ACTION_REMOVED);
@@ -247,7 +257,8 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
notify.nttrans.in.file.fnum = fnum2;
req = smb_raw_changenotify_send(cli->tree, ¬ify);
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_changenotify_recv");
CHECK_VAL(notify.nttrans.out.num_changes, count-1);
for (i=0;i<notify.nttrans.out.num_changes;i++) {
CHECK_VAL(notify.nttrans.out.changes[i].action, NOTIFY_ACTION_REMOVED);
@@ -262,10 +273,12 @@ 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(mem_ctx, status, ret, done,
+ "smb_raw_close");
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_changenotify_recv");
CHECK_VAL(notify.nttrans.out.num_changes, 0);
done:
@@ -343,7 +356,8 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
io.ntcreatex.in.fname = BASEDIR;
status = smb_raw_open(cli->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_open");
fnum = io.ntcreatex.out.file.fnum;
/* ask for a change notify, on file or directory name
@@ -362,11 +376,17 @@ 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, ¬ify);
- CHECK_STATUS(status, NT_STATUS_CANCELLED);
+ torture_assert_ntstatus_equal_goto(mem_ctx, status,
+ NT_STATUS_CANCELLED,
+ ret, done,
+ "smb_raw_changenotify_recv");
smb_raw_ntcancel(req2);
status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_CANCELLED);
+ torture_assert_ntstatus_equal_goto(mem_ctx, status,
+ NT_STATUS_CANCELLED,
+ ret, done,
+ "smb_raw_changenotify_recv");
/*
* Make notifies a bit more interesting in a cluster by doing
@@ -395,7 +415,8 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
req2 = smb_raw_changenotify_send(cli->tree, ¬ify);
status = smb_raw_changenotify_recv(req1, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_changenotify_recv");
CHECK_VAL(notify.nttrans.out.num_changes, 11);
CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_ADDED);
@@ -434,7 +455,8 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
}
status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_changenotify_recv");
CHECK_VAL(notify.nttrans.out.num_changes, 3);
CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED);
@@ -486,7 +508,8 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
io.ntcreatex.in.fname = BASEDIR;
status = smb_raw_open(cli->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_open");
fnum = io.ntcreatex.out.file.fnum;
/* ask for a change notify, on file or directory name
@@ -505,11 +528,17 @@ 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, ¬ify);
- CHECK_STATUS(status, NT_STATUS_CANCELLED);
+ torture_assert_ntstatus_equal_goto(mem_ctx, status,
+ NT_STATUS_CANCELLED,
+ ret, done,
+ "smb_raw_changenotify_recv");
smb_raw_ntcancel(req2);
status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_CANCELLED);
+ torture_assert_ntstatus_equal_goto(mem_ctx, status,
+ NT_STATUS_CANCELLED,
+ ret, done,
+ "smb_raw_changenotify_recv");
notify.nttrans.in.recursive = true;
req1 = smb_raw_changenotify_send(cli->tree, ¬ify);
@@ -520,7 +549,8 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
smbcli_unlink(cli->tree, BASEDIR "\\tname1");
status = smb_raw_changenotify_recv(req1, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, 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);
@@ -550,14 +580,16 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
smbcli_unlink(cli->tree, BASEDIR "\\subname3-r");
status = smb_raw_changenotify_recv(req1, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, 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, "subname2-r", STR_UNICODE);
status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, 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);
@@ -630,7 +662,8 @@ static bool test_notify_mask(struct torture_context *tctx,
do { 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,7 +676,8 @@ 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 && \
@@ -854,7 +888,8 @@ static bool test_notify_file(struct torture_context *mem_ctx,
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);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_open");
fnum = io.ntcreatex.out.file.fnum;
/* ask for a change notify,
@@ -869,16 +904,21 @@ static bool test_notify_file(struct torture_context *mem_ctx,
req = smb_raw_changenotify_send(cli->tree, ¬ify);
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+ torture_assert_ntstatus_equal_goto(mem_ctx, 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(mem_ctx, status, ret, done,
+ "smb_raw_close");
status = smbcli_unlink(cli->tree, fname);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smbcli_unlink");
done:
smb_raw_exit(cli->session);
@@ -927,7 +967,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,11 +982,13 @@ static bool test_notify_tdis(struct torture_context *tctx,
req = smb_raw_changenotify_send(cli->tree, ¬ify);
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, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb_raw_changenotify_recv");
CHECK_VAL(notify.nttrans.out.num_changes, 0);
done:
@@ -995,7 +1038,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,10 +1053,12 @@ static bool test_notify_exit(struct torture_context *tctx,
req = smb_raw_changenotify_send(cli->tree, ¬ify);
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, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb_raw_changenotify_recv");
CHECK_VAL(notify.nttrans.out.num_changes, 0);
done:
@@ -1062,7 +1108,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,10 +1123,12 @@ static bool test_notify_ulogoff(struct torture_context *tctx,
req = smb_raw_changenotify_send(cli->tree, ¬ify);
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, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb_raw_changenotify_recv");
CHECK_VAL(notify.nttrans.out.num_changes, 0);
done:
@@ -1136,7 +1185,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 +1202,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, ¬ify);
- 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);
@@ -1195,7 +1248,8 @@ static bool test_notify_double(struct torture_context *mem_ctx,
io.ntcreatex.in.fname = BASEDIR;
status = smb_raw_open(cli->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_open");
fnum = io.ntcreatex.out.file.fnum;
/* ask for a change notify,
@@ -1212,14 +1266,16 @@ 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, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_changenotify_recv");
CHECK_VAL(notify.nttrans.out.num_changes, 1);
CHECK_WSTR(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, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_changenotify_recv");
CHECK_VAL(notify.nttrans.out.num_changes, 1);
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name2", STR_UNICODE);
@@ -1302,7 +1358,8 @@ 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);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_open");
dirs[i].fnum = io.ntcreatex.out.file.fnum;
notify.nttrans.in.completion_filter = dirs[i].filter;
@@ -1311,7 +1368,10 @@ static bool test_notify_tree(struct torture_context *mem_ctx,
req = smb_raw_changenotify_send(cli->tree, ¬ify);
smb_raw_ntcancel(req);
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_CANCELLED);
+ torture_assert_ntstatus_equal_goto(mem_ctx, status,
+ NT_STATUS_CANCELLED,
+ ret, done,
+ "smb_raw_changenotify_recv");
}
/* trigger 2 events in each dir */
@@ -1412,7 +1472,8 @@ static bool test_notify_overflow(struct torture_context *mem_ctx,
io.ntcreatex.in.fname = BASEDIR;
status = smb_raw_open(cli->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_open");
fnum = io.ntcreatex.out.file.fnum;
/* ask for a change notify, on name changes. */
@@ -1427,7 +1488,10 @@ 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, ¬ify);
- CHECK_STATUS(status, NT_STATUS_CANCELLED);
+ torture_assert_ntstatus_equal_goto(mem_ctx, 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",
@@ -1449,7 +1513,8 @@ static bool test_notify_overflow(struct torture_context *mem_ctx,
/* expect that 0 events will be returned with NT_STATUS_OK */
req1 = smb_raw_changenotify_send(cli->tree, ¬ify);
status = smb_raw_changenotify_recv(req1, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_changenotify_recv");
CHECK_VAL(notify.nttrans.out.num_changes, 0);
done:
@@ -1494,7 +1559,8 @@ static bool test_notify_basedir(struct torture_context *mem_ctx,
io.ntcreatex.in.fname = BASEDIR;
status = smb_raw_open(cli->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
+ "smb_raw_open");
fnum = io.ntcreatex.out.file.fnum;
/* create a test file that will also be modified */
@@ -1519,7 +1585,8 @@ static bool test_notify_basedir(struct torture_context *mem_ctx,
/* check how many responses were given, expect only 1 for the file */
status = smb_raw_changenotify_recv(req1, mem_ctx, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(mem_ctx, 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);
@@ -1606,11 +1673,13 @@ static bool test_notify_tcon(struct torture_context *torture,
io.ntcreatex.in.fname = BASEDIR;
status = smb_raw_open(cli->tree, torture, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(torture, 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);
+ torture_assert_ntstatus_ok_goto(torture, status, ret, done,
+ "smb_raw_open");
/* ask for a change notify,
on file or directory name changes */
@@ -1625,7 +1694,8 @@ static bool test_notify_tcon(struct torture_context *torture,
smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, torture, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(torture, 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_ADDED);
@@ -1636,7 +1706,8 @@ static bool test_notify_tcon(struct torture_context *torture,
smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, torture, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(torture, 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_REMOVED);
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
@@ -1651,7 +1722,8 @@ static bool test_notify_tcon(struct torture_context *torture,
smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, torture, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(torture, 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_ADDED);
@@ -1662,7 +1734,8 @@ static bool test_notify_tcon(struct torture_context *torture,
smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, torture, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(torture, 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_REMOVED);
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
@@ -1671,7 +1744,8 @@ static bool test_notify_tcon(struct torture_context *torture,
printf("Disconnecting secondary tree\n");
status = smb_tree_disconnect(tree);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(torture, status, ret, done,
+ "smb_tree_disconnect");
talloc_free(tree);
printf("Testing notify mkdir\n");
@@ -1679,7 +1753,8 @@ static bool test_notify_tcon(struct torture_context *torture,
smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, torture, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(torture, 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_ADDED);
@@ -1690,7 +1765,8 @@ static bool test_notify_tcon(struct torture_context *torture,
smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, torture, ¬ify);
- CHECK_STATUS(status, NT_STATUS_OK);
+ torture_assert_ntstatus_ok_goto(torture, 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_REMOVED);
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
--
2.1.0
From 0aa14664e55e0fbc7638b1d03725a868c92df040 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 26 Mar 2015 18:45:47 +0100
Subject: [PATCH 04/16] s4:torture:raw:notify: remove CHECK_VAL.
This macro is not setting torture failure, leading to errors instead
of failures. Use torture_assert_ntstatus_(ok|equal)* macros.
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 237 +++++++++++++++++++++++++++++++------------
1 file changed, 173 insertions(+), 64 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index a47dddd..3f14ccc 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -27,14 +27,6 @@
#define BASEDIR "\\test_notify"
-#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); \
@@ -125,8 +117,12 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
torture_assert_ntstatus_ok_goto(mem_ctx, 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_ADDED);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 1, ret, done, "more than one change");
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_ADDED, ret, done,
+ "wrong action (exp: ADDED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
printf("Testing notify rmdir\n");
@@ -137,8 +133,12 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, 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_REMOVED);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 1, ret, done, "more than one change");
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_REMOVED, ret, done,
+ "wrong action (exp: REMOVED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
printf("Testing notify mkdir - rmdir - mkdir - rmdir\n");
@@ -152,14 +152,27 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, 4);
- CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_ADDED);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 4, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_ADDED, ret, done,
+ "wrong action (exp: ADDED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
- CHECK_VAL(notify.nttrans.out.changes[1].action, NOTIFY_ACTION_REMOVED);
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[1].action,
+ NOTIFY_ACTION_REMOVED, ret, done,
+ "wrong action (exp: REMOVED)");
CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name", STR_UNICODE);
- CHECK_VAL(notify.nttrans.out.changes[2].action, NOTIFY_ACTION_ADDED);
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[2].action,
+ NOTIFY_ACTION_ADDED, ret, done,
+ "wrong action (exp: ADDED)");
CHECK_WSTR(notify.nttrans.out.changes[2].name, "subdir-name", STR_UNICODE);
- CHECK_VAL(notify.nttrans.out.changes[3].action, NOTIFY_ACTION_REMOVED);
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[3].action,
+ NOTIFY_ACTION_REMOVED, ret, done,
+ "wrong action (exp: REMOVED)");
CHECK_WSTR(notify.nttrans.out.changes[3].name, "subdir-name", STR_UNICODE);
count = torture_numops;
@@ -206,9 +219,14 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, count);
+ torture_assert_int_equal_goto(mem_ctx, 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(mem_ctx,
+ 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);
@@ -216,8 +234,12 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, 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_REMOVED);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_REMOVED, ret, done,
+ "wrong action (exp: REMOVED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
printf("(3rd notify) this notify will only see the 1st unlink\n");
@@ -239,8 +261,12 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, 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_REMOVED);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_REMOVED, ret, done,
+ "wrong action (exp: REMOVED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
/* and we now see the rest of the unlink calls on both directory handles */
@@ -250,18 +276,28 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, count-1);
+ torture_assert_int_equal_goto(mem_ctx, 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(mem_ctx,
+ 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, ¬ify);
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, count-1);
+ torture_assert_int_equal_goto(mem_ctx, 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(mem_ctx,
+ 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");
@@ -279,7 +315,8 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, 0);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 0, ret, done, "no changes expected");
done:
smb_raw_exit(cli->session);
@@ -418,16 +455,32 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, 11);
- CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_ADDED);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 11, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_ADDED, ret, done,
+ "wrong action (exp: ADDED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
- CHECK_VAL(notify.nttrans.out.changes[1].action, NOTIFY_ACTION_ADDED);
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[1].action,
+ NOTIFY_ACTION_ADDED, ret, done,
+ "wrong action (exp: 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);
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[2].action,
+ NOTIFY_ACTION_ADDED, ret, done,
+ "wrong action (exp: 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);
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[3].action,
+ NOTIFY_ACTION_OLD_NAME, ret, done,
+ "wrong action (exp: 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);
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[4].action,
+ NOTIFY_ACTION_NEW_NAME, ret, done,
+ "wrong action (exp: NEW_NAME)");
CHECK_WSTR(notify.nttrans.out.changes[4].name, "subdir-name\\subname1-r", STR_UNICODE);
ret &= check_rename_reply(
@@ -458,12 +511,22 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, 3);
- CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_REMOVED);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 3, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_REMOVED, ret, done,
+ "wrong action (exp: 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);
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[1].action,
+ NOTIFY_ACTION_REMOVED, ret, done,
+ "wrong action (exp: REMOVED)");
CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name", STR_UNICODE);
- CHECK_VAL(notify.nttrans.out.changes[2].action, NOTIFY_ACTION_REMOVED);
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[2].action,
+ NOTIFY_ACTION_REMOVED, ret, done,
+ "wrong action (exp: REMOVED)");
CHECK_WSTR(notify.nttrans.out.changes[2].name, "subname3-r", STR_UNICODE);
done:
@@ -552,8 +615,12 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
torture_assert_ntstatus_ok_goto(mem_ctx, 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);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_MODIFIED, ret, done,
+ "wrong action (exp: MODIFIED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "tname1", STR_UNICODE);
/* Now try and change the mask to include other events.
@@ -583,16 +650,24 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
torture_assert_ntstatus_ok_goto(mem_ctx, 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);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_MODIFIED, ret, done,
+ "wrong action (exp: MODIFIED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subname2-r", STR_UNICODE);
status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, 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);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_MODIFIED, ret, done,
+ "wrong action (exp: MODIFIED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subname3-r", STR_UNICODE);
if (!ret) {
@@ -989,7 +1064,8 @@ static bool test_notify_tdis(struct torture_context *tctx,
status = smb_raw_changenotify_recv(req, tctx, ¬ify);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, 0);
+ torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+ 0, ret, done, "no changes expected");
done:
torture_close_connection(cli);
@@ -1059,7 +1135,8 @@ static bool test_notify_exit(struct torture_context *tctx,
status = smb_raw_changenotify_recv(req, tctx, ¬ify);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, 0);
+ torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+ 0, ret, done, "no changes expected");
done:
torture_close_connection(cli);
@@ -1129,7 +1206,8 @@ static bool test_notify_ulogoff(struct torture_context *tctx,
status = smb_raw_changenotify_recv(req, tctx, ¬ify);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, 0);
+ torture_assert_int_equal_goto(tctx, notify.nttrans.out.num_changes,
+ 0, ret, done, "no changes expected");
done:
torture_close_connection(cli);
@@ -1268,7 +1346,8 @@ static bool test_notify_double(struct torture_context *mem_ctx,
status = smb_raw_changenotify_recv(req1, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, 1);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name2");
@@ -1276,7 +1355,8 @@ static bool test_notify_double(struct torture_context *mem_ctx,
status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, 1);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name2", STR_UNICODE);
done:
@@ -1515,7 +1595,8 @@ static bool test_notify_overflow(struct torture_context *mem_ctx,
status = smb_raw_changenotify_recv(req1, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
"smb_raw_changenotify_recv");
- CHECK_VAL(notify.nttrans.out.num_changes, 0);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 0, ret, done, "no changes expected");
done:
smb_raw_exit(cli->session);
@@ -1587,8 +1668,12 @@ static bool test_notify_basedir(struct torture_context *mem_ctx,
status = smb_raw_changenotify_recv(req1, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, 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);
+ torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(mem_ctx,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_MODIFIED, ret, done,
+ "wrong action (exp: MODIFIED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "tname1", STR_UNICODE);
done:
@@ -1697,8 +1782,12 @@ static bool test_notify_tcon(struct torture_context *torture,
torture_assert_ntstatus_ok_goto(torture, 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_ADDED);
+ torture_assert_int_equal_goto(torture, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(torture,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_ADDED, ret, done,
+ "wrong action (exp: ADDED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
printf("Testing notify rmdir\n");
@@ -1708,8 +1797,12 @@ static bool test_notify_tcon(struct torture_context *torture,
status = smb_raw_changenotify_recv(req, torture, ¬ify);
torture_assert_ntstatus_ok_goto(torture, 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_REMOVED);
+ torture_assert_int_equal_goto(torture, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(torture,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_REMOVED, ret, done,
+ "wrong action (exp: REMOVED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
printf("SIMPLE CHANGE NOTIFY OK\n");
@@ -1725,8 +1818,12 @@ static bool test_notify_tcon(struct torture_context *torture,
torture_assert_ntstatus_ok_goto(torture, 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_ADDED);
+ torture_assert_int_equal_goto(torture, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(torture,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_ADDED, ret, done,
+ "wrong action (exp: ADDED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
printf("Testing notify rmdir\n");
@@ -1736,8 +1833,12 @@ static bool test_notify_tcon(struct torture_context *torture,
status = smb_raw_changenotify_recv(req, torture, ¬ify);
torture_assert_ntstatus_ok_goto(torture, 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_REMOVED);
+ torture_assert_int_equal_goto(torture, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(torture,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_REMOVED, ret, done,
+ "wrong action (exp: REMOVED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
printf("CHANGE NOTIFY WITH TCON OK\n");
@@ -1756,8 +1857,12 @@ static bool test_notify_tcon(struct torture_context *torture,
torture_assert_ntstatus_ok_goto(torture, 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_ADDED);
+ torture_assert_int_equal_goto(torture, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(torture,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_ADDED, ret, done,
+ "wrong action (exp: ADDED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
printf("Testing notify rmdir\n");
@@ -1767,8 +1872,12 @@ static bool test_notify_tcon(struct torture_context *torture,
status = smb_raw_changenotify_recv(req, torture, ¬ify);
torture_assert_ntstatus_ok_goto(torture, 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_REMOVED);
+ torture_assert_int_equal_goto(torture, notify.nttrans.out.num_changes,
+ 1, ret, done, "wrong number of changes");
+ torture_assert_int_equal_goto(torture,
+ notify.nttrans.out.changes[0].action,
+ NOTIFY_ACTION_REMOVED, ret, done,
+ "wrong action (exp: REMOVED)");
CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
printf("CHANGE NOTIFY WITH TDIS OK\n");
--
2.1.0
From 7757f1e0c1d6ae82b9f3f4f4e5018ff7a0bc9d9a Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 26 Mar 2015 18:58:05 +0100
Subject: [PATCH 05/16] s4:torture:raw:notify: remove CHECK_WSTR2.
The original CHECK_WSTR() macro was not setting torture failure,
leading to errors instead of propoer failures.
The original CHECK_WSTR2() macro was exactly like the CHECK_WSTR
macro but using propoer torture_result() calls.
This patch removes the original CHECK_WSTR(), renames CHECK_WSTR2
to CHECK_WSTR and adapts the callers, hence removing the source
of many potential missing torture_assert messages.
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 98 +++++++++++++++++++++++++++-----------------
1 file changed, 60 insertions(+), 38 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index 3f14ccc..a54007a 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -27,14 +27,7 @@
#define BASEDIR "\\test_notify"
-#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)) { \
@@ -123,7 +116,8 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("Testing notify rmdir\n");
@@ -139,7 +133,8 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("Testing notify mkdir - rmdir - mkdir - rmdir\n");
@@ -158,22 +153,26 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[1].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[1].name, "subdir-name",
+ STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[2].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[2].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[2].name, "subdir-name",
+ STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[3].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[3].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[3].name, "subdir-name",
+ STR_UNICODE);
count = torture_numops;
printf("Testing buffered notify on create of %d files\n", count);
@@ -228,7 +227,8 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
}
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, 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, ¬ify);
@@ -240,7 +240,8 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, 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, ¬ify);
@@ -267,7 +268,8 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, 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;
@@ -461,27 +463,32 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[1].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name\\subname1", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[1].name,
+ "subdir-name\\subname1", STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[2].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[2].name, "subdir-name\\subname2", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[2].name,
+ "subdir-name\\subname2", STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[3].action,
NOTIFY_ACTION_OLD_NAME, ret, done,
"wrong action (exp: OLD_NAME)");
- CHECK_WSTR(notify.nttrans.out.changes[3].name, "subdir-name\\subname1", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[3].name,
+ "subdir-name\\subname1", STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[4].action,
NOTIFY_ACTION_NEW_NAME, ret, done,
"wrong action (exp: NEW_NAME)");
- CHECK_WSTR(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(
cli, __LINE__, ¬ify.nttrans.out.changes[5],
@@ -517,17 +524,20 @@ static bool test_notify_recursive(struct torture_context *mem_ctx,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name\\subname1-r", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name,
+ "subdir-name\\subname1-r", STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[1].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[1].name, "subdir-name",
+ STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[2].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[2].name, "subname3-r", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[2].name, "subname3-r",
+ STR_UNICODE);
done:
smb_raw_exit(cli->session);
@@ -621,7 +631,8 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_MODIFIED, ret, done,
"wrong action (exp: MODIFIED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "tname1", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, 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
@@ -656,7 +667,8 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_MODIFIED, ret, done,
"wrong action (exp: MODIFIED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subname2-r", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subname2-r",
+ STR_UNICODE);
status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
@@ -668,7 +680,8 @@ static bool test_notify_mask_change(struct torture_context *mem_ctx,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_MODIFIED, ret, done,
"wrong action (exp: MODIFIED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subname3-r", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subname3-r",
+ STR_UNICODE);
if (!ret) {
goto done;
@@ -1348,7 +1361,8 @@ static bool test_notify_double(struct torture_context *mem_ctx,
"smb_raw_changenotify_recv");
torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
1, ret, done, "wrong number of changes");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name2");
@@ -1357,7 +1371,8 @@ static bool test_notify_double(struct torture_context *mem_ctx,
"smb_raw_changenotify_recv");
torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
1, ret, done, "wrong number of changes");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name2", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subdir-name2",
+ STR_UNICODE);
done:
smb_raw_exit(cli->session);
@@ -1674,7 +1689,8 @@ static bool test_notify_basedir(struct torture_context *mem_ctx,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_MODIFIED, ret, done,
"wrong action (exp: MODIFIED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "tname1", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "tname1",
+ STR_UNICODE);
done:
smb_raw_exit(cli->session);
@@ -1788,7 +1804,8 @@ static bool test_notify_tcon(struct torture_context *torture,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(torture, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("Testing notify rmdir\n");
req = smb_raw_changenotify_send(cli->tree, ¬ify);
@@ -1803,7 +1820,8 @@ static bool test_notify_tcon(struct torture_context *torture,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(torture, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("SIMPLE CHANGE NOTIFY OK\n");
@@ -1824,7 +1842,8 @@ static bool test_notify_tcon(struct torture_context *torture,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(torture, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("Testing notify rmdir\n");
req = smb_raw_changenotify_send(cli->tree, ¬ify);
@@ -1839,7 +1858,8 @@ static bool test_notify_tcon(struct torture_context *torture,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(torture, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("CHANGE NOTIFY WITH TCON OK\n");
@@ -1863,7 +1883,8 @@ static bool test_notify_tcon(struct torture_context *torture,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(torture, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("Testing notify rmdir\n");
req = smb_raw_changenotify_send(cli->tree, ¬ify);
@@ -1878,7 +1899,8 @@ static bool test_notify_tcon(struct torture_context *torture,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(torture, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("CHANGE NOTIFY WITH TDIS OK\n");
done:
@@ -1974,7 +1996,7 @@ static bool test_notify_alignment(struct torture_context *tctx,
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);
}
--
2.1.0
From fc8cedfb8700d16168fb8d61523909801ab2a53c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 26 Mar 2015 19:08:26 +0100
Subject: [PATCH 06/16] s4:torture:raw:notify: make check_rename_reply()
properly use torture_result
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 at samba.org>
---
source4/torture/raw/notify.c | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index a54007a..effe8eb 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -333,7 +333,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)
@@ -342,19 +343,14 @@ 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;
}
@@ -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);
- ret &= check_rename_reply(
+ ret &= check_rename_reply(mem_ctx,
cli, __LINE__, ¬ify.nttrans.out.changes[5],
NOTIFY_ACTION_ADDED, "subname2-r");
- ret &= check_rename_reply(
+ ret &= check_rename_reply(mem_ctx,
cli, __LINE__, ¬ify.nttrans.out.changes[5],
NOTIFY_ACTION_REMOVED, "subdir-name\\subname2");
- ret &= check_rename_reply(
+ ret &= check_rename_reply(mem_ctx,
cli, __LINE__, ¬ify.nttrans.out.changes[5],
NOTIFY_ACTION_MODIFIED, "subname2-r");
- ret &= check_rename_reply(
+ ret &= check_rename_reply(mem_ctx,
cli, __LINE__, ¬ify.nttrans.out.changes[8],
NOTIFY_ACTION_OLD_NAME, "subname2-r");
- ret &= check_rename_reply(
+ ret &= check_rename_reply(mem_ctx,
cli, __LINE__, ¬ify.nttrans.out.changes[8],
NOTIFY_ACTION_NEW_NAME, "subname3-r");
- ret &= check_rename_reply(
+ ret &= check_rename_reply(mem_ctx,
cli, __LINE__, ¬ify.nttrans.out.changes[8],
NOTIFY_ACTION_MODIFIED, "subname3-r");
--
2.1.0
From 5c341f9e5b82a5af2f349ffefcdf086e232505dd Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 26 Mar 2015 19:11:16 +0100
Subject: [PATCH 07/16] s4:torture:raw:notify: improve the CHECK_WSTR() macro
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index effe8eb..8f6675d 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -29,11 +29,10 @@
#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)
/*
--
2.1.0
From cecf4c8cf5c9f521338b447f833f7c2262e44bc9 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 26 Mar 2015 19:13:58 +0100
Subject: [PATCH 08/16] s4:torture:raw:notify: add a few comments to
torture_assert calls
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index 8f6675d..86aebc3 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -1946,7 +1946,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 */
@@ -1964,7 +1964,7 @@ static bool test_notify_alignment(struct torture_context *tctx,
smbcli_close(cli->tree, fnum2);
status = smb_raw_changenotify_recv(req, tctx, ¬ify);
- 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
@@ -1984,7 +1984,7 @@ static bool test_notify_alignment(struct torture_context *tctx,
* the alignment checking for us. */
req = smb_raw_changenotify_send(cli->tree, ¬ify);
status = smb_raw_changenotify_recv(req, tctx, ¬ify);
- 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, "");
--
2.1.0
From 96878d0b1ecccbe9e9db0afe3db3ddff0b4cf5d0 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 26 Mar 2015 19:18:43 +0100
Subject: [PATCH 09/16] s4:torture:raw:notify: use torture_assert with
torture_setup_dir
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 84 ++++++++++++++++++--------------------------
1 file changed, 35 insertions(+), 49 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index 86aebc3..26f7094 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -52,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
@@ -368,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
@@ -555,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
@@ -710,9 +707,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);
@@ -954,9 +950,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;
@@ -1025,9 +1020,8 @@ 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;
@@ -1097,9 +1091,8 @@ 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;
@@ -1168,9 +1161,8 @@ 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;
@@ -1246,9 +1238,8 @@ 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;
@@ -1313,10 +1304,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
*/
@@ -1423,9 +1414,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;
@@ -1542,9 +1532,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;
@@ -1630,9 +1619,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;
@@ -1747,10 +1735,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
@@ -1926,9 +1913,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;
--
2.1.0
From b6a1e89733ec8dfc24f81309be23b6a0c6217a3d Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 26 Mar 2015 19:22:08 +0100
Subject: [PATCH 10/16] s4:torture:raw:notify: treat torture_open_connection
calls with torture_assert
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index 26f7094..80de189 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -1023,9 +1023,8 @@ static bool test_notify_tdis(struct torture_context *tctx,
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
@@ -1094,9 +1093,8 @@ static bool test_notify_exit(struct torture_context *tctx,
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
@@ -1164,9 +1162,8 @@ static bool test_notify_ulogoff(struct torture_context *tctx,
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
@@ -1241,9 +1238,8 @@ static bool test_notify_tcp_dis(struct torture_context *tctx,
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
--
2.1.0
From 85a8cf0dbb1ab168c04508161f77d099a775c77b Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 26 Mar 2015 19:36:52 +0100
Subject: [PATCH 11/16] s4:torture:raw:notify: remove superfluous conditional
goto
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index 80de189..023ce5c 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -675,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);
--
2.1.0
From 643400d81d7452a9a32e126bb3f0d4df36fd4195 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 26 Mar 2015 19:41:06 +0100
Subject: [PATCH 12/16] s4:torture:raw:notify: use torture_assert instead of
printf in failure case
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index 023ce5c..d060538 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -177,12 +177,9 @@ static bool test_notify_dir(struct torture_context *mem_ctx,
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(mem_ctx, fnum3, -1, ret, done,
+ talloc_asprintf(mem_ctx, "Failed to create %s - %s",
+ fname, smbcli_errstr(cli->tree)));
talloc_free(fname);
smbcli_close(cli->tree, fnum3);
}
@@ -1571,12 +1568,9 @@ 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(mem_ctx, fnum2, -1, ret, done,
+ talloc_asprintf(mem_ctx, "Failed to create %s - %s",
+ fname, smbcli_errstr(cli->tree)));
talloc_free(fname);
smbcli_close(cli->tree, fnum2);
}
--
2.1.0
From 9b4fccb6bb713e6158fcd0312f19bc72517deba7 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 27 Mar 2015 00:43:30 +0100
Subject: [PATCH 13/16] s4:torture:raw:notify: remove extra do-loop in
NOTIFY_MASK_TEST macro.
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index d060538..d745b93 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -731,7 +731,7 @@ 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); \
torture_assert_ntstatus_ok_goto(tctx, status, ret, done, \
@@ -790,7 +790,6 @@ static bool test_notify_mask(struct torture_context *tctx,
mask, expected); \
} \
} \
- } while (0); \
} while (0);
printf("Testing mkdir\n");
--
2.1.0
From 07affcdf6673b8581c446c4f58cfa564a923b598 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 27 Mar 2015 10:19:26 +0100
Subject: [PATCH 14/16] s4:torture:raw:notify: let NOTIFY_MASK_TEST use
torture_assert macros
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 64 ++++++++++++++++++++++++--------------------
1 file changed, 35 insertions(+), 29 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index d745b93..07813b4 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -756,39 +756,45 @@ static bool test_notify_mask(struct torture_context *tctx,
((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);
--
2.1.0
From a5dac5865fc414469386c86f13c335c77622f151 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 27 Mar 2015 10:25:17 +0100
Subject: [PATCH 15/16] s4:torture:raw:notify: use torture_assert instead of
printf in test_notify_tree
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index 07813b4..02956ce 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -1487,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(mem_ctx,
+ dirs[i].counted, dirs[i].expected, ret, done,
+ talloc_asprintf(mem_ctx,
+ "unexpected number of events for '%s'",
+ dirs[i].path));
}
/*
--
2.1.0
From ace08e00e41af04a420c40f0439facf91cb2d849 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 27 Mar 2015 10:34:34 +0100
Subject: [PATCH 16/16] s4:torture:raw:notify: torture_assert on creation of
secondary tcon
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/raw/notify.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index 02956ce..1b747da 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -1800,6 +1800,8 @@ static bool test_notify_tcon(struct torture_context *torture,
printf("TESTING WITH SECONDARY TCON\n");
tree = secondary_tcon(cli, torture);
+ torture_assert_not_null_goto(torture, tree, ret, done,
+ "failed to create secondary tcon");
printf("Testing notify mkdir\n");
req = smb_raw_changenotify_send(cli->tree, ¬ify);
--
2.1.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150327/f73f91b8/attachment.pgp>
More information about the samba-technical
mailing list