diff options
author | Michael Adam <obnox@samba.org> | 2014-10-02 17:08:12 +0200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2014-10-03 08:34:06 +0200 |
commit | 884f7476785a519772c5f871704159207c19847b (patch) | |
tree | 6db6774234f0e7289228f4f7731595bfe3a3e8bd /source4 | |
parent | 641a8a25752d6c0faead3939784a3f665de03645 (diff) | |
download | samba-884f7476785a519772c5f871704159207c19847b.tar.gz |
s4:torture:basic: make use of torture_assert macros in delayed_write_update1c
This does not change the logic except for adding early
returns in failure cases.
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4')
-rw-r--r-- | source4/torture/basic/delaywrite.c | 65 |
1 files changed, 23 insertions, 42 deletions
diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c index 72102c1ddb0..df90e400073 100644 --- a/source4/torture/basic/delaywrite.c +++ b/source4/torture/basic/delaywrite.c @@ -622,10 +622,8 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb 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); @@ -663,20 +661,11 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb while (!timeval_expired(&end)) { status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); - if (!NT_STATUS_IS_OK(status)) { - torture_result(tctx, TORTURE_FAIL, "fileinfo failed: %s", - nt_errstr(status)); - ret = false; - break; - } + torture_assert_ntstatus_ok(tctx, status, "fileinfo failed"); - if (finfo2.all_info.out.size != 0) { - torture_result(tctx, TORTURE_FAIL, - "file not truncated (size = %u, should be 10240)", - (unsigned int)finfo2.all_info.out.size); - ret = false; - break; - } + torture_assert_u64_equal(tctx, finfo2.all_info.out.size, 0, + "file not truncated to expected size " + "(0)"); torture_comment(tctx, "write time %s\n", nt_time_string(tctx, finfo2.all_info.out.write_time)); @@ -701,11 +690,10 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb 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); @@ -720,18 +708,10 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb while (!timeval_expired(&end)) { status = smb_raw_fileinfo(cli->tree, tctx, &finfo3); - if (!NT_STATUS_IS_OK(status)) { - torture_result(tctx, TORTURE_FAIL, "fileinfo failed: %s", - nt_errstr(status)); - ret = false; - break; - } + torture_assert_ntstatus_ok(tctx, status, "fileinfo failed"); - if (finfo3.all_info.out.size != 1) { - torture_result(tctx, TORTURE_FAIL, "file not expanded"); - ret = false; - break; - } + torture_assert_u64_equal(tctx, finfo3.all_info.out.size, 1, + "file not expaneded"); torture_comment(tctx, "write time %s\n", nt_time_string(tctx, finfo3.all_info.out.write_time)); @@ -747,11 +727,10 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb 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!)"); /* the close should trigger an write time update */ smbcli_close(cli->tree, fnum1); @@ -760,10 +739,12 @@ static bool test_delayed_write_update1c(struct torture_context *tctx, struct smb 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!)\n"); - 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"); } |