return ret;
}
+static bool test_delaywrite_delaywrite1_close(void *private_data,
+ union smb_fileinfo *finfo)
+{
+ struct test_delaywrite_delaywrite1_state *state =
+ (struct test_delaywrite_delaywrite1_state *)private_data;
+ struct torture_context *tctx = state->tctx;
+ struct smbcli_state *cli2 = state->cli2;
+ union smb_fileinfo t2finfo;
+ union smb_fileinfo t2pinfo;
+ bool ret = true;
+
+ ZERO_STRUCTP(finfo);
+
+ /*
+ * the close updates the write time to the time of the close
+ * and not to the time of the last write!
+ */
+ torture_comment(tctx, "Close the file handle\n");
+ smbcli_close(state->cli1->tree, state->fnum1);
+ state->fnum1 = -1;
+
+ ZERO_STRUCT(t2finfo);
+ t2finfo.basic_info.level = RAW_FILEINFO_BASIC_INFO;
+ t2finfo.basic_info.in.file.fnum = state->fnum2;
+ ZERO_STRUCT(t2pinfo);
+ t2pinfo.basic_info.level = RAW_FILEINFO_BASIC_INFO;
+ t2pinfo.basic_info.in.file.path = state->fname;
+
+ GET_INFO_FILE2(t2finfo);
+
+ smbcli_close(state->cli2->tree, state->fnum2);
+ state->fnum2 = -1;
+
+ GET_INFO_PATH(t2pinfo);
+ COMPARE_ALL_TIMES_EQUAL(t2pinfo, t2finfo);
+
+ finfo->basic_info.out = t2finfo.basic_info.out;
+
+done:
+ return ret;
+}
+
static bool test_delaywrite_delaywrite1(struct torture_context *tctx,
struct smbcli_state *cli,
struct smbcli_state *cli2)
.tctx = tctx,
.cli1 = cli,
.cli2 = cli2,
+ .fnum1 = -1,
+ .fnum2 = -1,
};
- union smb_fileinfo c1finfo0, c1finfo1, c1finfo2;
- union smb_fileinfo c2pinfo0, c2pinfo1, c2pinfo2, c2pinfo3;
const char *fname = BASEDIR "\\torture_file3.txt";
- int fnum1 = -1;
- int fnum2 = -1;
bool ret = true;
//double used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
//double used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 1000000);
double used_delay = torture_setting_int(tctx, "writetimeupdatedelay", normal_delay);
//double normal_delay = 1000000;
//int normal_delay = 2000000;
- double sec = ((double)used_delay) / ((double)normal_delay);
- int msec = 1000 * sec;
bool ok;
torture_comment(tctx, "\nRunning test_delayed_write_update3\n");
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
torture_comment(tctx, "Open the file handle\n");
- fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum1 == -1) {
+ state.fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ if (state.fnum1 == -1) {
ret = false;
torture_result(tctx, TORTURE_FAIL, __location__": unable to open %s", fname);
goto done;
}
- fnum2 = smbcli_open(cli2->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum2 == -1) {
+ state.fnum2 = smbcli_open(cli2->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ if (state.fnum2 == -1) {
ret = false;
torture_result(tctx, TORTURE_FAIL, __location__": unable to open %s", fname);
goto done;
}
- c1finfo0.basic_info.level = RAW_FILEINFO_BASIC_INFO;
- c1finfo0.basic_info.in.file.fnum = fnum1;
- c1finfo1 = c1finfo0;
- c1finfo2 = c1finfo0;
- c2pinfo0.basic_info.level = RAW_FILEINFO_BASIC_INFO;
- c2pinfo0.basic_info.in.file.path = fname;
- c2pinfo1 = c2pinfo0;
- c2pinfo2 = c2pinfo0;
- c2pinfo3 = c2pinfo0;
-
- /* get the initial times */
- GET_INFO_BOTH(c1finfo0,c2pinfo0);
-
state.fname = fname;
- state.fnum1 = fnum1;
- state.fnum2 = fnum2;
ok = test_delay_writetime1(tctx, used_delay, normal_delay,
- "run1",
+ "run", true, /* smb1 */
test_delaywrite_delaywrite1_get_info,
test_delaywrite_delaywrite1_write_data,
+ test_delaywrite_delaywrite1_close,
&state);
- torture_assert(tctx, ok, "test_delay_writetime1(1)");
- ok = test_delay_writetime1(tctx, used_delay, normal_delay,
- "run2",
- test_delaywrite_delaywrite1_get_info,
- test_delaywrite_delaywrite1_write_data,
- &state);
- torture_assert(tctx, ok, "test_delay_writetime2(2)");
-
- GET_INFO_BOTH(c1finfo1, c2pinfo1);
- COMPARE_TIMES_AFTER_WRITE(c1finfo1, c1finfo0);
-
- /* sleep */
- torture_comment(tctx, "Sleep ...\n");
- smb_msleep(5 * msec);
- torture_comment(tctx, "... continue\n");
-
- GET_INFO_BOTH(c1finfo2, c2pinfo2);
- COMPARE_ALL_TIMES_EQUAL(c1finfo2, c1finfo1);
-
- /*
- * the close updates the write time to the time of the close
- * and not to the time of the last write!
- */
- torture_comment(tctx, "Close the file handle\n");
- smbcli_close(cli->tree, fnum1);
- fnum1 = -1;
-
- GET_INFO_PATH(c2pinfo3);
- COMPARE_WRITE_TIME_GREATER(c2pinfo3, c2pinfo2);
-
- if (c2pinfo3.basic_info.out.write_time > c2pinfo2.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated the write_time on close (correct)\n");
- }
+ torture_assert_goto(tctx, ok, ret, done, "test_delay_writetime2(2)");
done:
- if (fnum1 != -1) {
- smbcli_close(cli->tree, fnum1);
+ if (state.fnum1 != -1) {
+ smbcli_close(cli->tree, state.fnum1);
}
- if (fnum2 != -1) {
- smbcli_close(cli2->tree, fnum2);
+ if (state.fnum2 != -1) {
+ smbcli_close(cli2->tree, state.fnum2);
}
smbcli_unlink(cli->tree, fname);
smbcli_deltree(cli->tree, BASEDIR);
COMPARE_ALL_TIMES_EQUAL(c1finfo0, c1finfoCR);
ok = test_delay_writetime1(tctx, used_delay, normal_delay,
- "run1",
+ "run1", false, /* smb1 */
test_durable_open_delaywrite1_get_info,
test_durable_open_delaywrite1_write_data,
NULL, /* close_cb */
&state);
- torture_assert(tctx, ok, "test_delay_writetime1(1)");
+ torture_assert_goto(tctx, ok, ret, done, "test_delay_writetime1(1)");
ok = test_delay_writetime1(tctx, used_delay, normal_delay,
- "run2",
+ "run2", false, /* smb1 */
test_durable_open_delaywrite1_get_info,
test_durable_open_delaywrite1_write_data,
test_durable_open_delaywrite1_close,
&state);
- torture_assert(tctx, ok, "test_delay_writetime2(2)");
+ torture_assert_goto(tctx, ok, ret, done, "test_delay_writetime2(2)");
done:
if (state.h1 != NULL) {