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));
finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO;
finfo1.basic_info.in.file.fnum = fnum1;
finfo2 = finfo1;
status = smb_raw_fileinfo(cli->tree, tctx, &finfo1);
-
torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
-
- torture_comment(tctx, "Initial write time %s\n",
- nt_time_string(tctx, finfo1.basic_info.out.write_time));
- written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
+ torture_comment(tctx, "Initial write time %s\n",
+ nt_time_string(tctx, finfo1.basic_info.out.write_time));
- if (written != 1) {
- torture_result(tctx, TORTURE_FAIL,
- "write failed - wrote %d bytes (%s)\n",
- (int)written, __location__);
- return false;
- }
+ written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
+ torture_assert_int_equal(tctx, written, 1,
+ "unexpected number of bytes written");
start = timeval_current();
- end = timeval_add(&start, (120*sec), 0);
+ 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_comment(tctx, "write time %s\n",
- nt_time_string(tctx, finfo2.basic_info.out.write_time));
- if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
+ torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
+
+ torture_comment(tctx, "write time %s\n",
+ nt_time_string(tctx, finfo2.basic_info.out.write_time));
+
+ if (finfo1.basic_info.out.write_time !=
+ finfo2.basic_info.out.write_time)
+ {
double diff = timeval_elapsed(&start);
- if (diff < (used_delay / (double)1000000)) {
- torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds"
- "(expected > %.2f) (wrong!)\n",
- diff, used_delay / (double)1000000);
- ret = false;
- break;
- }
+
+ torture_assert(tctx,
+ diff >= (used_delay / (double)1000000),
+ talloc_asprintf(tctx,
+ "Server updated write_time after %.2f "
+ "seconds (expected >= %.2f)\n",
+ diff, used_delay/(double)1000000));
torture_comment(tctx, "Server updated write_time after %.2f seconds (correct)\n",
diff);
fflush(stdout);
smb_msleep(1 * msec);
}
-
- if (finfo1.basic_info.out.write_time == finfo2.basic_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.basic_info.out.write_time,
+ finfo1.basic_info.out.write_time,
+ "Server did not update write time within "
+ "120 seconds");
if (fnum1 != -1)
smbcli_close(cli->tree, fnum1);
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);
torture_assert_ntstatus_ok(tctx, status, "fileinfo failed");
- torture_comment(tctx, "Initial write time %s\n",
- nt_time_string(tctx, finfo1.all_info.out.write_time));
+ torture_assert_u64_equal(tctx, finfo1.all_info.out.size, 2048,
+ "file size not as expected after write(2048)");
+
+ torture_comment(tctx, "Initial write time %s\n",
+ nt_time_string(tctx, finfo1.all_info.out.write_time));
/* 3 second delay to ensure we get past any 2 second time
granularity (older systems may have that) */
/* 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);
+ 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));
+ nt_time_string(tctx, finfo2.all_info.out.write_time));
if (finfo1.all_info.out.write_time != finfo2.all_info.out.write_time) {
double diff = timeval_elapsed(&start);
if (diff > (0.25 * (used_delay / (double)1000000))) {
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));
- if (finfo2.all_info.out.write_time != finfo3.all_info.out.write_time) {
- double diff = timeval_elapsed(&start);
+ nt_time_string(tctx, finfo3.all_info.out.write_time));
+
+ torture_assert_u64_equal(tctx,
+ finfo3.all_info.out.write_time,
+ finfo2.all_info.out.write_time,
+ talloc_asprintf(tctx,
+ "Server updated write time "
+ "after %.2f seconds (wrong!)",
+ timeval_elapsed(&start)));
- torture_comment(tctx, "server updated write_time after %.2f seconds"
- "(1 sec == %.2f)(wrong)\n",
- diff, sec);
- break;
- }
fflush(stdout);
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_comment(tctx, "Server did not update write time within 10 "
+ "seconds. Good!\n");
fflush(stdout);
smb_msleep(2 * msec);
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_comment(tctx, "Server updated write time on close (correct)\n");
- }
+ 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!)");
+ torture_assert(tctx,
+ pinfo4.all_info.out.write_time > finfo3.all_info.out.write_time,
+ "Server updated write time on close, but to an earlier point "
+ "in time");
+
+ torture_comment(tctx, "Server updated write time on close (correct)\n");
if (fnum1 != -1)
smbcli_close(cli->tree, fnum1);
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "server updated write_time after %.2f seconds"
- "(1 sec == %.2f)(correct)\n",
- diff, sec);
+ "(write time update delay == %.2f)(correct)\n",
+ diff, used_delay / (double)1000000);
break;
}
fflush(stdout);
double diff = timeval_elapsed(&start);
torture_comment(tctx, "server updated write_time after %.2f seconds"
- "(1 sec == %.2f)(correct)\n",
- diff, sec);
+ "(write time update delay == %.2f)(correct)\n",
+ diff, used_delay / (double)1000000);
break;
}
fflush(stdout);
double diff = timeval_elapsed(&start);
torture_comment(tctx, "server updated write_time after %.2f seconds"
- "(1 sec == %.2f)(correct)\n",
- diff, sec);
+ "(write time update delay == %.2f)(wrong)\n",
+ diff, used_delay / (double)1000000);
break;
}
fflush(stdout);
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds"
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
}
torture_comment(tctx, "Server updated write_time after %.2f seconds"
- "(1sec == %.2f) (correct)\n",
- diff, sec);
+ "(correct)\n",
+ diff);
break;
}
fflush(stdout);
}
torture_comment(tctx, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (correct)\n",
- diff, sec);
+ "(correct)\n",
+ diff);
break;
}
smb_msleep(0.5 * msec);
if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
}
torture_comment(tctx, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (correct)\n",
- diff, sec);
+ "(correct)\n",
+ diff);
break;
}
smb_msleep(0.5 * msec);
if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
struct smbcli_state *cli,
struct smbcli_state *cli2)
{
- union smb_fileinfo finfo0, finfo1, finfo2, finfo3, finfo4;
- union smb_fileinfo pinfo0, pinfo1, pinfo2, pinfo3, pinfo4, pinfo5;
+ union smb_fileinfo finfo0, finfo1, finfo2, finfo3;
+ union smb_fileinfo pinfo0, pinfo1, pinfo2, pinfo3, pinfo4;
const char *fname = BASEDIR "\\torture_file3c.txt";
int fnum1 = -1;
bool ret = true;
finfo1 = finfo0;
finfo2 = finfo0;
finfo3 = finfo0;
- finfo4 = finfo0;
pinfo0.basic_info.level = RAW_FILEINFO_BASIC_INFO;
pinfo0.basic_info.in.file.path = fname;
pinfo1 = pinfo0;
pinfo2 = pinfo0;
pinfo3 = pinfo0;
pinfo4 = pinfo0;
- pinfo5 = pinfo0;
/* get the initial times */
GET_INFO_BOTH(finfo0,pinfo0);
if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
if (finfo3.basic_info.out.write_time > finfo2.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
if (finfo4.basic_info.out.write_time > finfo3.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
if (finfo3.basic_info.out.write_time > finfo2.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
if (finfo4.basic_info.out.write_time > finfo3.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
if (finfo3.basic_info.out.write_time > finfo2.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
if (finfo4.basic_info.out.write_time > finfo3.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
if (finfo5.basic_info.out.write_time > pinfo6.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}
if (finfo5.basic_info.out.write_time > pinfo6.basic_info.out.write_time) {
double diff = timeval_elapsed(&start);
torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
- "(1sec == %.2f) (wrong!)\n",
- diff, sec);
+ "(wrong!)\n",
+ diff);
ret = false;
break;
}