summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/basic/delaywrite.c30
-rw-r--r--source4/torture/raw/oplock.c159
-rw-r--r--source4/torture/smbtorture.c15
-rw-r--r--source4/torture/torture.c3
-rw-r--r--source4/torture/ui.c16
-rw-r--r--source4/torture/ui.h7
6 files changed, 135 insertions, 95 deletions
diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c
index 4c2a511721..072f15c623 100644
--- a/source4/torture/basic/delaywrite.c
+++ b/source4/torture/basic/delaywrite.c
@@ -487,6 +487,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
ret = False;
+ torture_result(tctx, TORTURE_FAIL, __location__": unable to open %s", fname);
goto done;
}
@@ -496,8 +497,8 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
status = smb_raw_fileinfo(cli->tree, tctx, &finfo1);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
ret = False;
+ torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s", nt_errstr(status));
goto done;
}
@@ -506,16 +507,15 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
if (written != 1) {
- torture_comment(tctx, "(%s) written gave %d - should have been 1\n",
- __location__, (int)written);
+ torture_result(tctx, TORTURE_FAIL, __location__": written gave %d - should have been 1", (int)written);
ret = False;
goto done;
}
fnum2 = smbcli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- torture_comment(tctx, "(%s) failed to open 2nd time - %s\n",
- __location__, smbcli_errstr(cli2->tree));
+ torture_result(tctx, TORTURE_FAIL, __location__": failed to open 2nd time - %s",
+ smbcli_errstr(cli2->tree));
ret = False;
goto done;
}
@@ -523,8 +523,8 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
written = smbcli_write(cli2->tree, fnum2, 0, "x", 0, 1);
if (written != 1) {
- torture_comment(tctx, "(%s) written gave %d - should have been 1\n",
- __location__, (int)written);
+ torture_result(tctx, TORTURE_FAIL, __location__": written gave %d - should have been 1",
+ (int)written);
ret = False;
goto done;
}
@@ -535,30 +535,30 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
status = smb_raw_pathinfo(cli2->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("(%s) fileinfo failed: %s\n",
- __location__, nt_errstr(status)));
+ torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s",
+ nt_errstr(status));
ret = False;
goto done;
}
if (finfo1.basic_info.out.create_time !=
finfo2.basic_info.out.create_time) {
- torture_comment(tctx, "(%s) create_time changed\n", __location__);
+ torture_result(tctx, TORTURE_FAIL, __location__": create_time changed");
ret = False;
goto done;
}
if (finfo1.basic_info.out.access_time !=
finfo2.basic_info.out.access_time) {
- torture_comment(tctx, "(%s) access_time changed\n", __location__);
+ torture_result(tctx, TORTURE_FAIL, __location__": access_time changed");
ret = False;
goto done;
}
if (finfo1.basic_info.out.write_time !=
finfo2.basic_info.out.write_time) {
- torture_comment(tctx, "(%s) write_time changed\n", __location__);
- torture_comment(tctx, "write time conn 1 = %s, conn 2 = %s\n",
+ torture_result(tctx, TORTURE_FAIL, __location__": write_time changed:\n"
+ "write time conn 1 = %s, conn 2 = %s",
nt_time_string(tctx, finfo1.basic_info.out.write_time),
nt_time_string(tctx, finfo2.basic_info.out.write_time));
ret = False;
@@ -567,7 +567,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
if (finfo1.basic_info.out.change_time !=
finfo2.basic_info.out.change_time) {
- torture_comment(tctx, "(%s) change_time changed\n", __location__);
+ torture_result(tctx, TORTURE_FAIL, __location__": change_time changed");
ret = False;
goto done;
}
@@ -587,7 +587,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
status = smb_raw_pathinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+ torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s", nt_errstr(status));
ret = False;
goto done;
}
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index f2e894a6eb..1e677fad45 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -28,15 +28,15 @@
#define CHECK_VAL(v, correct) do { \
if ((v) != (correct)) { \
- printf("(%d) wrong value for %s got 0x%x - should be 0x%x\n", \
- __LINE__, #v, (int)v, (int)correct); \
+ torture_result(tctx, TORTURE_FAIL, __location__": wrong value for %s got 0x%x - should be 0x%x", \
+ #v, (int)v, (int)correct); \
ret = False; \
}} while (0)
-#define CHECK_STATUS(status, correct) do { \
+#define CHECK_STATUS(tctx, 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)); \
+ torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
+ nt_errstr(status), nt_errstr(correct)); \
ret = False; \
goto done; \
}} while (0)
@@ -126,7 +126,8 @@ static BOOL oplock_handler_close(struct smbcli_transport *transport, uint16_t ti
/*
test oplock ops
*/
-static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TALLOC_CTX *mem_ctx)
+static BOOL test_oplock(struct torture_context *tctx,
+ struct smbcli_state *cli1, struct smbcli_state *cli2, TALLOC_CTX *mem_ctx)
{
const char *fname = BASEDIR "\\test_oplock.dat";
NTSTATUS status;
@@ -158,26 +159,26 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = fname;
- printf("open a file with a normal oplock\n");
+ torture_comment(tctx, "open a file with a normal oplock\n");
ZERO_STRUCT(break_info);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN);
- printf("a 2nd open should not cause a break\n");
+ torture_comment(tctx, "a 2nd open should not cause a break\n");
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
- printf("unlink it - should also be no break\n");
+ torture_comment(tctx, "unlink it - should also be no break\n");
unl.unlink.in.pattern = fname;
unl.unlink.in.attrib = 0;
status = smb_raw_unlink(cli2->tree, &unl);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
@@ -186,35 +187,35 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
/*
with a batch oplock we get a break
*/
- printf("open with batch oplock\n");
+ torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
- printf("unlink should generate a break\n");
+ torture_comment(tctx, "unlink should generate a break\n");
unl.unlink.in.pattern = fname;
unl.unlink.in.attrib = 0;
status = smb_raw_unlink(cli2->tree, &unl);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.fnum, fnum);
CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
CHECK_VAL(break_info.failures, 0);
- printf("2nd unlink should not generate a break\n");
+ torture_comment(tctx, "2nd unlink should not generate a break\n");
ZERO_STRUCT(break_info);
status = smb_raw_unlink(cli2->tree, &unl);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 0);
- printf("writing should generate a self break to none\n");
+ torture_comment(tctx, "writing should generate a self break to none\n");
smbcli_write(cli1->tree, fnum, 0, &c, 0, 1);
msleep(100);
smbcli_write(cli1->tree, fnum, 0, &c, 1, 1);
@@ -227,36 +228,36 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli1->tree, fnum);
- printf("open with batch oplock\n");
+ torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
- printf("unlink should generate a break, which we ack as break to none\n");
+ torture_comment(tctx, "unlink should generate a break, which we ack as break to none\n");
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_none, cli1->tree);
unl.unlink.in.pattern = fname;
unl.unlink.in.attrib = 0;
status = smb_raw_unlink(cli2->tree, &unl);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.fnum, fnum);
CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
CHECK_VAL(break_info.failures, 0);
- printf("2nd unlink should not generate a break\n");
+ torture_comment(tctx, "2nd unlink should not generate a break\n");
ZERO_STRUCT(break_info);
status = smb_raw_unlink(cli2->tree, &unl);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 0);
- printf("writing should not generate a break\n");
+ torture_comment(tctx, "writing should not generate a break\n");
smbcli_write(cli1->tree, fnum, 0, &c, 0, 1);
msleep(100);
smbcli_write(cli1->tree, fnum, 0, &c, 1, 1);
@@ -265,14 +266,14 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli1->tree, fnum);
- printf("if we close on break then the unlink can succeed\n");
+ torture_comment(tctx, "if we close on break then the unlink can succeed\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
@@ -280,14 +281,14 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
unl.unlink.in.attrib = 0;
ZERO_STRUCT(break_info);
status = smb_raw_unlink(cli2->tree, &unl);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.fnum, fnum);
CHECK_VAL(break_info.level, 1);
CHECK_VAL(break_info.failures, 0);
- printf("a self read should not cause a break\n");
+ torture_comment(tctx, "a self read should not cause a break\n");
ZERO_STRUCT(break_info);
smbcli_close(cli1->tree, fnum);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -296,7 +297,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
@@ -306,11 +307,11 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
rd.read.in.offset = 0;
rd.read.in.remaining = 0;
status = smb_raw_read(cli1->tree, &rd);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
- printf("a 2nd open should give a break\n");
+ torture_comment(tctx, "a 2nd open should give a break\n");
ZERO_STRUCT(break_info);
smbcli_close(cli1->tree, fnum);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -319,7 +320,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
@@ -327,7 +328,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.fnum, fnum);
@@ -335,7 +336,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
CHECK_VAL(break_info.failures, 0);
- printf("a 2nd open should give a break to level II if the first open allowed shared read\n");
+ torture_comment(tctx, "a 2nd open should give a break to level II if the first open allowed shared read\n");
ZERO_STRUCT(break_info);
smbcli_close(cli1->tree, fnum);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -347,14 +348,14 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
ZERO_STRUCT(break_info);
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
@@ -364,7 +365,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
CHECK_VAL(break_info.failures, 0);
ZERO_STRUCT(break_info);
- printf("write should trigger a break to none on both\n");
+ torture_comment(tctx, "write should trigger a break to none on both\n");
smbcli_write(cli1->tree, fnum, 0, &c, 0, 1);
msleep(100);
smbcli_write(cli1->tree, fnum, 0, &c, 1, 1);
@@ -376,7 +377,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli1->tree, fnum);
smbcli_close(cli2->tree, fnum2);
- printf("a 2nd open should get an oplock when we close instead of ack\n");
+ torture_comment(tctx, "a 2nd open should get an oplock when we close instead of ack\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree);
@@ -386,7 +387,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
@@ -396,7 +397,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
@@ -407,7 +408,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli2->tree, fnum);
- printf("open with batch oplock\n");
+ torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -415,19 +416,19 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
ZERO_STRUCT(break_info);
- printf("second open with attributes only shouldn't cause oplock break\n");
+ torture_comment(tctx, "second open with attributes only shouldn't cause oplock break\n");
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN);
CHECK_VAL(break_info.count, 0);
@@ -437,7 +438,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli2->tree, fnum2);
smbcli_unlink(cli1->tree, fname);
- printf("open with attributes only can create file\n");
+ torture_comment(tctx, "open with attributes only can create file\n");
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
@@ -445,11 +446,11 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
- printf("Subsequent normal open should break oplock on attribute only open to level II\n");
+ torture_comment(tctx, "Subsequent normal open should break oplock on attribute only open to level II\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -460,7 +461,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.fnum, fnum);
@@ -469,7 +470,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
smbcli_close(cli2->tree, fnum2);
- printf("third oplocked open should grant level2 without break\n");
+ torture_comment(tctx, "third oplocked open should grant level2 without break\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli2->tree);
@@ -479,7 +480,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
@@ -487,7 +488,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
ZERO_STRUCT(break_info);
- printf("write should trigger a break to none on both\n");
+ torture_comment(tctx, "write should trigger a break to none on both\n");
smbcli_write(cli2->tree, fnum2, 0, &c, 0, 1);
/* Now the oplock break request comes in. But right now we can't
@@ -506,7 +507,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
- printf("Open with oplock after a on-oplock open should grant level2\n");
+ torture_comment(tctx, "Open with oplock after a on-oplock open should grant level2\n");
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
@@ -514,7 +515,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_SHARE_ACCESS_DELETE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
@@ -529,13 +530,13 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_SHARE_ACCESS_DELETE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
- printf("write should trigger a break to none\n");
+ torture_comment(tctx, "write should trigger a break to none\n");
{
union smb_write wr;
wr.write.level = RAW_WRITE_WRITE;
@@ -545,7 +546,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
wr.write.in.remaining = 0;
wr.write.in.data = (const uint8_t *)"x";
status = smb_raw_write(cli1->tree, &wr);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
}
/* Now the oplock break request comes in. But right now we can't
@@ -562,7 +563,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
wr.write.in.remaining = 0;
wr.write.in.data = (const uint8_t *)"x";
status = smb_raw_write(cli1->tree, &wr);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
}
CHECK_VAL(break_info.count, 1);
@@ -575,7 +576,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_unlink(cli1->tree, fname);
/* Test if a set-eof on pathname breaks an exclusive oplock. */
- printf("Test if setpathinfo set EOF breaks oplocks.\n");
+ torture_comment(tctx, "Test if setpathinfo set EOF breaks oplocks.\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -589,7 +590,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_SHARE_ACCESS_DELETE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
@@ -602,7 +603,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
status = smb_raw_setpathinfo(cli2->tree, &sfi);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.failures, 0);
CHECK_VAL(break_info.level, 0);
@@ -611,7 +612,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_unlink(cli1->tree, fname);
/* Test if a set-allocation size on pathname breaks an exclusive oplock. */
- printf("Test if setpathinfo allocation size breaks oplocks.\n");
+ torture_comment(tctx, "Test if setpathinfo allocation size breaks oplocks.\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -625,7 +626,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_SHARE_ACCESS_DELETE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
@@ -638,7 +639,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
status = smb_raw_setpathinfo(cli2->tree, &sfi);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.failures, 0);
CHECK_VAL(break_info.level, 0);
@@ -647,7 +648,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli2->tree, fnum2);
smbcli_unlink(cli1->tree, fname);
- printf("open with batch oplock\n");
+ torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -656,13 +657,13 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
ZERO_STRUCT(break_info);
- printf("second open with attributes only and NTCREATEX_DISP_OVERWRITE dispostion causes oplock break\n");
+ torture_comment(tctx, "second open with attributes only and NTCREATEX_DISP_OVERWRITE dispostion causes oplock break\n");
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
@@ -670,7 +671,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
CHECK_VAL(break_info.count, 1);
@@ -680,7 +681,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli2->tree, fnum2);
smbcli_unlink(cli1->tree, fname);
- printf("open with batch oplock\n");
+ torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -689,13 +690,13 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
ZERO_STRUCT(break_info);
- printf("second open with attributes only and NTCREATEX_DISP_SUPERSEDE dispostion causes oplock break\n");
+ torture_comment(tctx, "second open with attributes only and NTCREATEX_DISP_SUPERSEDE dispostion causes oplock break\n");
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
@@ -703,7 +704,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
CHECK_VAL(break_info.count, 1);
@@ -746,7 +747,7 @@ BOOL torture_raw_oplock(struct torture_context *torture)
mem_ctx = talloc_init("torture_raw_oplock");
- if (!test_oplock(cli1, cli2, mem_ctx)) {
+ if (!test_oplock(torture, cli1, cli2, mem_ctx)) {
ret = False;
}
@@ -776,7 +777,7 @@ BOOL torture_bench_oplock(struct torture_context *torture)
cli = talloc_array(mem_ctx, struct smbcli_state *, torture_nprocs);
- printf("Opening %d connections\n", torture_nprocs);
+ torture_comment(torture, "Opening %d connections\n", torture_nprocs);
for (i=0;i<torture_nprocs;i++) {
if (!torture_open_connection_ev(&cli[i], i, ev)) {
return False;
@@ -817,19 +818,19 @@ BOOL torture_bench_oplock(struct torture_context *torture)
This measures how fast we can pass on oplocks, and stresses
the oplock handling code
*/
- printf("Running for %d seconds\n", timelimit);
+ torture_comment(torture, "Running for %d seconds\n", timelimit);
while (timeval_elapsed(&tv) < timelimit) {
for (i=0;i<torture_nprocs;i++) {
NTSTATUS status;
status = smb_raw_open(cli[i]->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(torture, status, NT_STATUS_OK);
count++;
}
- printf("%.2f ops/second\r", count/timeval_elapsed(&tv));
+ torture_comment(torture, "%.2f ops/second\r", count/timeval_elapsed(&tv));
}
- printf("%.2f ops/second\n", count/timeval_elapsed(&tv));
+ torture_comment(torture, "%.2f ops/second\n", count/timeval_elapsed(&tv));
smb_raw_exit(cli[torture_nprocs-1]->session);
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index cc4c3e6b5b..5247abc14b 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -316,13 +316,25 @@ static void simple_comment (struct torture_context *test,
printf("%s", comment);
}
+static void simple_warning(struct torture_context *test,
+ const char *comment)
+{
+ fprintf(stderr, "WARNING: %s\n", comment);
+}
+
const static struct torture_ui_ops std_ui_ops = {
.comment = simple_comment,
+ .warning = simple_warning,
.suite_start = simple_suite_start,
.suite_finish = simple_suite_finish,
.test_result = simple_test_result
};
+static void subunit_init(struct torture_context *ctx)
+{
+ /* FIXME: register segv and bus handler */
+}
+
static void subunit_suite_start(struct torture_context *ctx,
struct torture_suite *suite)
{
@@ -354,7 +366,7 @@ static void subunit_test_result (struct torture_context *context,
break;
}
if (reason)
- printf(" [ %s ]", reason);
+ printf(" [\n%s\n]", reason);
printf("\n");
}
@@ -365,6 +377,7 @@ static void subunit_comment (struct torture_context *test,
}
const static struct torture_ui_ops subunit_ui_ops = {
+ .init = subunit_init,
.comment = subunit_comment,
.test_start = subunit_test_start,
.test_result = subunit_test_result,
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index e54efd72d0..4699df7d89 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -49,6 +49,9 @@ struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx,
torture->ui_ops = ui_ops;
torture->returncode = true;
+ if (ui_ops->init)
+ ui_ops->init(torture);
+
return torture;
}
diff --git a/source4/torture/ui.c b/source4/torture/ui.c
index 6368d47991..d28c0e5bc2 100644
--- a/source4/torture/ui.c
+++ b/source4/torture/ui.c
@@ -40,6 +40,22 @@ void torture_comment(struct torture_context *context, const char *comment, ...)
talloc_free(tmp);
}
+void torture_warning(struct torture_context *context, const char *comment, ...)
+{
+ va_list ap;
+ char *tmp;
+
+ if (!context->ui_ops->warning)
+ return;
+
+ va_start(ap, comment);
+ tmp = talloc_vasprintf(context, comment, ap);
+
+ context->ui_ops->warning(context, tmp);
+
+ talloc_free(tmp);
+}
+
void torture_result(struct torture_context *context,
enum torture_result result, const char *fmt, ...)
{
diff --git a/source4/torture/ui.h b/source4/torture/ui.h
index 8c4d3b6729..329462ba28 100644
--- a/source4/torture/ui.h
+++ b/source4/torture/ui.h
@@ -40,7 +40,9 @@ enum torture_result {
*/
struct torture_ui_ops
{
+ void (*init) (struct torture_context *);
void (*comment) (struct torture_context *, const char *);
+ void (*warning) (struct torture_context *, const char *);
void (*suite_start) (struct torture_context *, struct torture_suite *);
void (*suite_finish) (struct torture_context *, struct torture_suite *);
void (*tcase_start) (struct torture_context *, struct torture_tcase *);
@@ -188,6 +190,7 @@ bool torture_run_test(struct torture_context *context,
struct torture_test *test);
void torture_comment(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3);
+void torture_warning(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3);
void torture_result(struct torture_context *test,
enum torture_result, const char *reason, ...) PRINTF_ATTRIBUTE(3,4);
@@ -263,6 +266,10 @@ void torture_result(struct torture_context *test,
torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
return false; \
} while (0)
+#define torture_fail_goto(torture_ctx,label,cmt) do {\
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
+ goto label; \
+ } while (0)
#define torture_out stderr