#define CHECK_CREATED(__io, __created, __attribute) \
do { \
CHECK_VAL((__io)->out.create_action, NTCREATEX_ACTION_ ## __created); \
- CHECK_VAL((__io)->out.alloc_size, 0); \
- CHECK_VAL((__io)->out.size, 0); \
CHECK_VAL((__io)->out.file_attr, (__attribute)); \
CHECK_VAL((__io)->out.reserved2, 0); \
} while(0)
COMPARE_CREATE_TIME_EQUAL(given,correct); \
} while (0)
+#define DEBUG_BASIC_INFO(finfo, comment) do { \
+ struct timeval atv; \
+ struct timeval wtv; \
+ struct timeval_buf atvb; \
+ struct timeval_buf wtvb; \
+ nttime_to_timeval(&atv, finfo.basic_info.out.access_time); \
+ nttime_to_timeval(&wtv, finfo.basic_info.out.write_time); \
+ torture_comment(tctx, "%s: Access(%s) Write(%s)\n", \
+ comment, \
+ timeval_str_buf(&atv, false, true, &atvb), \
+ timeval_str_buf(&wtv, false, true, &wtvb)); \
+} while (0)
#define GET_INFO_FILE(tree, finfo) do { \
- struct timeval _atv; \
- struct timeval _wtv; \
- struct timeval_buf _atvb; \
- struct timeval_buf _wtvb; \
NTSTATUS _status; \
_status = smb2_getinfo_file(tree, tctx, &finfo); \
if (!NT_STATUS_IS_OK(_status)) { \
nt_errstr(_status)); \
goto done; \
} \
- nttime_to_timeval(&_atv, finfo.basic_info.out.access_time); \
- nttime_to_timeval(&_wtv, finfo.basic_info.out.write_time); \
- torture_comment(tctx, "fileinfo(%s,%s): Access(%s) Write(%s)\n", \
- #tree, #finfo, \
- timeval_str_buf(&_atv, false, true, &_atvb), \
- timeval_str_buf(&_wtv, false, true, &_wtvb)); \
+ DEBUG_BASIC_INFO(finfo, "fileinfo(" #tree ")"); \
} while (0)
#define GET_INFO_BOTH(finfo1, finfo2) do { \
COMPARE_ALL_TIMES_EQUAL(finfo1, finfo2); \
} while (0)
-#define SET_INFO_FILE_EX(finfo, wrtime, tree, tfnum) do { \
- NTSTATUS _status; \
- union smb_setfileinfo sfinfo; \
- sfinfo.basic_info.level = RAW_SFILEINFO_BASIC_INFO; \
- sfinfo.basic_info.in.file.fnum = tfnum; \
- sfinfo.basic_info.in.create_time = 0; \
- sfinfo.basic_info.in.access_time = 0; \
- unix_to_nt_time(&sfinfo.basic_info.in.write_time, (wrtime)); \
- sfinfo.basic_info.in.change_time = 0; \
- sfinfo.basic_info.in.attrib = finfo1.basic_info.out.attrib; \
- _status = smb_raw_setfileinfo(tree, &sfinfo); \
- if (!NT_STATUS_IS_OK(_status)) { \
- torture_result(tctx, TORTURE_FAIL, __location__": setfileinfo failed: %s", \
- nt_errstr(_status)); \
- ret = false; \
- goto done; \
- } \
-} while (0)
-#define SET_INFO_FILE(finfo, wrtime) \
- SET_INFO_FILE_EX(finfo, wrtime, cli->tree, fnum1)
-
-#define SET_INFO_FILE_NS(finfo, wrtime, ns, tree, tfnum) do { \
- NTSTATUS _status; \
- union smb_setfileinfo sfinfo; \
- sfinfo.basic_info.level = RAW_SFILEINFO_BASIC_INFO; \
- sfinfo.basic_info.in.file.fnum = tfnum; \
- sfinfo.basic_info.in.create_time = 0; \
- sfinfo.basic_info.in.access_time = 0; \
- unix_to_nt_time(&sfinfo.basic_info.in.write_time, (wrtime)); \
- sfinfo.basic_info.in.write_time += (ns); \
- sfinfo.basic_info.in.change_time = 0; \
- sfinfo.basic_info.in.attrib = finfo1.basic_info.out.attrib; \
- _status = smb_raw_setfileinfo(tree, &sfinfo); \
- if (!NT_STATUS_IS_OK(_status)) { \
- torture_result(tctx, TORTURE_FAIL, __location__": setfileinfo failed: %s", \
- nt_errstr(_status)); \
- ret = false; \
- goto done; \
- } \
-} while (0)
-
-struct test_durable_open_delaywrite1_state {
+struct test_timestamp_delaywrite1_state {
struct torture_context *tctx;
struct smb2_tree *tree1;
struct smb2_tree *tree2;
struct smb2_handle *h2;
};
-static bool test_durable_open_delaywrite1_get_info(void *private_data,
+static bool test_timestamp_delaywrite1_get_info(void *private_data,
union smb_fileinfo *finfo)
{
- struct test_durable_open_delaywrite1_state *state =
- (struct test_durable_open_delaywrite1_state *)private_data;
+ struct test_timestamp_delaywrite1_state *state =
+ (struct test_timestamp_delaywrite1_state *)private_data;
struct torture_context *tctx = state->tctx;
union smb_fileinfo t1finfo;
union smb_fileinfo t2finfo;
return ret;
}
-static bool test_durable_open_delaywrite1_write_data(void *private_data)
+static bool test_timestamp_delaywrite1_write_data(void *private_data)
{
- struct test_durable_open_delaywrite1_state *state =
- (struct test_durable_open_delaywrite1_state *)private_data;
+ struct test_timestamp_delaywrite1_state *state =
+ (struct test_timestamp_delaywrite1_state *)private_data;
struct torture_context *tctx = state->tctx;
struct smb2_write wr;
NTSTATUS status;
return ret;
}
-static bool test_durable_open_delaywrite1_close(void *private_data,
+static bool test_timestamp_delaywrite1_close(void *private_data,
union smb_fileinfo *finfo)
{
- struct test_durable_open_delaywrite1_state *state =
- (struct test_durable_open_delaywrite1_state *)private_data;
+ struct test_timestamp_delaywrite1_state *state =
+ (struct test_timestamp_delaywrite1_state *)private_data;
struct torture_context *tctx = state->tctx;
union smb_fileinfo t1finfoCL;
union smb_fileinfo t2finfoCL;
return ret;
}
-static bool test_durable_open_delaywrite1(struct torture_context *tctx,
- struct smb2_tree *tree1,
- struct smb2_tree *tree2)
+static bool test_timestamp_delaywrite1x(struct torture_context *tctx,
+ struct smb2_tree *tree1,
+ struct smb2_tree *tree2,
+ const char *description,
+ bool reconnect)
{
- struct test_durable_open_delaywrite1_state state = {
+ struct test_timestamp_delaywrite1_state state = {
.tctx = tctx,
.tree1 = tree1,
.tree2 = tree2,
normal_delay);
/* Choose a random name in case the state is left a little funky. */
- snprintf(fname, 256, "durable_open_delaywrite1_%s.dat",
+ snprintf(fname, 256, "%s_%s.dat", description,
generate_random_str(tctx, 8));
smb2_util_unlink(tree1, fname);
cr2.in.durable_open = false;
cr2.in.oplock_level = 0;
cr2.in.create_disposition = NTCREATEX_DISP_OPEN;
- status = smb2_create(tree2, mem_ctx, &cr2);
+ status = smb2_create(state.tree2, mem_ctx, &cr2);
CHECK_STATUS(status, NT_STATUS_OK);
_h2 = cr2.out.file.handle;
state.h2 = &_h2;
ok = test_smb_timestamp_writetime1(tctx, used_delay, normal_delay,
"run1",
- test_durable_open_delaywrite1_get_info,
- test_durable_open_delaywrite1_write_data,
+ test_timestamp_delaywrite1_get_info,
+ test_timestamp_delaywrite1_write_data,
NULL, /* close_cb */
&state);
torture_assert_goto(tctx, ok, ret, done,
"test_smb_timestamp_writetime1(1)");
ok = test_smb_timestamp_writetime1(tctx, used_delay, normal_delay,
"run2",
- test_durable_open_delaywrite1_get_info,
- test_durable_open_delaywrite1_write_data,
- test_durable_open_delaywrite1_close,
+ test_timestamp_delaywrite1_get_info,
+ test_timestamp_delaywrite1_write_data,
+ test_timestamp_delaywrite1_close,
&state);
torture_assert_goto(tctx, ok, ret, done,
"test_smb_timestamp_writetime1(2)");
smb2_util_close(tree2, *state.h2);
}
- smb2_util_unlink(tree1, fname);
+ smb2_util_unlink(tree2, fname);
- talloc_free(tree1);
- talloc_free(tree2);
+ TALLOC_FREE(tree1);
+ TALLOC_FREE(tree2);
talloc_free(mem_ctx);
torture_suite_create(ctx, "timestamps");
torture_suite_add_2smb2_test(suite, "delaywrite1",
- test_durable_open_delaywrite1);
+ test_timestamp_delaywrite1);
suite->description = talloc_strdup(suite, "SMB2-TIMESTAMPS tests");