summaryrefslogtreecommitdiffstats
path: root/source4/torture/basic/delaywrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/basic/delaywrite.c')
-rw-r--r--source4/torture/basic/delaywrite.c84
1 files changed, 28 insertions, 56 deletions
diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c
index 05183d9e6c..8294fea279 100644
--- a/source4/torture/basic/delaywrite.c
+++ b/source4/torture/basic/delaywrite.c
@@ -135,10 +135,8 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum1 == -1) {
- torture_result(tctx, TORTURE_FAIL, "Failed to open %s", fname);
- return false;
- }
+ torture_assert_int_not_equal(tctx, fnum1, -1, talloc_asprintf(tctx,
+ "Failed to open %s", fname));
memset(buf, 'x', 2048);
written = smbcli_write(cli->tree, fnum1, 0, buf, 0, 2048);
@@ -167,32 +165,19 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
/* Do a zero length SMBwrite call to truncate. */
written = smbcli_smbwrite(cli->tree, fnum1, "x", 1024, 0);
-
- if (written != 0) {
- torture_result(tctx, TORTURE_FAIL,
- "write failed - wrote %d bytes (%s)\n",
- (int)written, __location__);
- return false;
- }
+ torture_assert_int_equal(tctx, written, 0,
+ "unexpected number of bytes written");
start = timeval_current();
end = timeval_add(&start, (120 * sec), 0);
while (!timeval_expired(&end)) {
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- ret = false;
- break;
- }
+ torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
- if (finfo2.all_info.out.size != 1024) {
- torture_result(tctx, TORTURE_FAIL,
- "file not truncated, size = %u (should be 1024)",
- (unsigned int)finfo2.all_info.out.size);
- ret = false;
- break;
- }
+ torture_assert_u64_equal(tctx, finfo2.all_info.out.size, 1024,
+ "file not truncated to expected size "
+ "(1024)");
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo2.all_info.out.write_time));
@@ -217,42 +202,29 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
smb_msleep(1 * msec);
}
- if (finfo1.all_info.out.write_time == finfo2.all_info.out.write_time) {
- torture_result(tctx, TORTURE_FAIL,
- "Server did not update write time (wrong!)");
- ret = false;
- }
+ torture_assert_u64_not_equal(tctx,
+ finfo2.all_info.out.write_time,
+ finfo1.all_info.out.write_time,
+ "Server did not update write time");
fflush(stdout);
smb_msleep(2 * msec);
/* Do a non-zero length SMBwrite and make sure it doesn't update the write time. */
written = smbcli_smbwrite(cli->tree, fnum1, "x", 0, 1);
-
- if (written != 1) {
- torture_result(tctx, TORTURE_FAIL,
- "write failed - wrote %d bytes (%s)",
- (int)written, __location__);
- return false;
- }
+ torture_assert_int_equal(tctx, written, 1,
+ "unexpected number of bytes written");
start = timeval_current();
end = timeval_add(&start, (10*sec), 0);
while (!timeval_expired(&end)) {
status = smb_raw_fileinfo(cli->tree, tctx, &finfo3);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
- ret = false;
- break;
- }
+ torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
- if (finfo3.all_info.out.size != 1024) {
- DEBUG(0, ("file not truncated, size = %u (should be 1024)\n",
- (unsigned int)finfo3.all_info.out.size));
- ret = false;
- break;
- }
+ torture_assert_u64_equal(tctx, finfo3.all_info.out.size, 1024,
+ "file not truncated to expected size "
+ "(1024)");
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo3.all_info.out.write_time));
@@ -268,11 +240,10 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
smb_msleep(1 * msec);
}
- if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
- torture_result(tctx, TORTURE_FAIL,
- "Server updated write time (wrong!)");
- ret = false;
- }
+ torture_assert_u64_equal(tctx,
+ finfo3.all_info.out.write_time,
+ finfo2.all_info.out.write_time,
+ "Server updated write time (wrong!)");
fflush(stdout);
smb_msleep(2 * msec);
@@ -284,11 +255,12 @@ static bool test_delayed_write_update1(struct torture_context *tctx, struct smbc
status = smb_raw_pathinfo(cli->tree, tctx, &pinfo4);
torture_assert_ntstatus_ok(tctx, status, "pathinfo failed");
- if (finfo3.all_info.out.write_time == pinfo4.all_info.out.write_time) {
- torture_result(tctx, TORTURE_FAIL,
- "Server did not update write time on close (wrong!)");
- ret = false;
- } else if (finfo3.all_info.out.write_time < pinfo4.all_info.out.write_time) {
+ torture_assert_u64_not_equal(tctx,
+ pinfo4.all_info.out.write_time,
+ finfo3.all_info.out.write_time,
+ "Server did not update write time on "
+ "close (wrong!)");
+ if (finfo3.all_info.out.write_time < pinfo4.all_info.out.write_time) {
torture_comment(tctx, "Server updated write time on close (correct)\n");
}