#define BASEDIR "\\test_notify"
-#define CHECK_WSTR(field, value, flags) do { \
- if (!field.s || strcmp(field.s, value) || wire_bad_flags(&field, flags, cli->transport)) { \
- printf("(%d) %s [%s] != %s\n", __LINE__, #field, field.s, value); \
- ret = false; \
- goto done; \
- }} while (0)
-
-#define CHECK_WSTR2(tctx, field, value, flags) \
+#define CHECK_WSTR(tctx, field, value, flags) \
do { \
- if (!field.s || strcmp(field.s, value) || \
- wire_bad_flags(&field, flags, cli->transport)) { \
- torture_result(tctx, TORTURE_FAIL, \
- "(%d) %s [%s] != %s\n", __LINE__, #field, field.s, value); \
- } \
+ torture_assert_str_equal(tctx, field.s, value, "values don't match"); \
+ torture_assert(tctx, \
+ !wire_bad_flags(&field, STR_UNICODE, cli->transport), \
+ "wire_bad_flags"); \
} while (0)
/*
extern int torture_numops;
printf("TESTING CHANGE NOTIFY ON DIRECTORIES\n");
-
- if (!torture_setup_dir(cli, BASEDIR)) {
- return false;
- }
+
+ torture_assert(mem_ctx, torture_setup_dir(cli, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
/*
get a handle on the directory
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("Testing notify rmdir\n");
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("Testing notify mkdir - rmdir - mkdir - rmdir\n");
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[1].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[1].name, "subdir-name",
+ STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[2].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[2].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[2].name, "subdir-name",
+ STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[3].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[3].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[3].name, "subdir-name",
+ STR_UNICODE);
count = torture_numops;
printf("Testing buffered notify on create of %d files\n", count);
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
}
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "test0.txt",
+ STR_UNICODE);
printf("and now from the 1st notify\n");
status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify);
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "test0.txt",
+ STR_UNICODE);
printf("(3rd notify) this notify will only see the 1st unlink\n");
req = smb_raw_changenotify_send(cli->tree, ¬ify);
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "test0.txt", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "test0.txt",
+ STR_UNICODE);
/* and we now see the rest of the unlink calls on both directory handles */
notify.nttrans.in.file.fnum = fnum;
* pair in any of the three following notify_changes.
*/
-static bool check_rename_reply(struct smbcli_state *cli,
+static bool check_rename_reply(struct torture_context *tctx,
+ struct smbcli_state *cli,
int line,
struct notify_changes *actions,
uint32_t action, const char *name)
for (i=0; i<3; i++) {
if (actions[i].action == action) {
- if ((actions[i].name.s == NULL)
- || (strcmp(actions[i].name.s, name) != 0)
- || (wire_bad_flags(&actions[i].name, STR_UNICODE,
- cli->transport))) {
- printf("(%d) name [%s] != %s\n", line,
- actions[i].name.s, name);
- return false;
- }
+ CHECK_WSTR(tctx, actions[i].name, name, STR_UNICODE);
return true;
}
}
- printf("(%d) expected action %d, not found\n", line, action);
+ torture_result(tctx, TORTURE_FAIL,
+ __location__": (%d) expected action %d, not found\n",
+ line, action);
return false;
}
struct smbcli_request *req1, *req2;
printf("TESTING CHANGE NOTIFY WITH RECURSION\n");
-
- if (!torture_setup_dir(cli, BASEDIR)) {
- return false;
- }
+
+ torture_assert(mem_ctx, torture_setup_dir(cli, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
/*
get a handle on the directory
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[1].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name\\subname1", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[1].name,
+ "subdir-name\\subname1", STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[2].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[2].name, "subdir-name\\subname2", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[2].name,
+ "subdir-name\\subname2", STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[3].action,
NOTIFY_ACTION_OLD_NAME, ret, done,
"wrong action (exp: OLD_NAME)");
- CHECK_WSTR(notify.nttrans.out.changes[3].name, "subdir-name\\subname1", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[3].name,
+ "subdir-name\\subname1", STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[4].action,
NOTIFY_ACTION_NEW_NAME, ret, done,
"wrong action (exp: NEW_NAME)");
- CHECK_WSTR(notify.nttrans.out.changes[4].name, "subdir-name\\subname1-r", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[4].name,
+ "subdir-name\\subname1-r", STR_UNICODE);
- ret &= check_rename_reply(
+ ret &= check_rename_reply(mem_ctx,
cli, __LINE__, ¬ify.nttrans.out.changes[5],
NOTIFY_ACTION_ADDED, "subname2-r");
- ret &= check_rename_reply(
+ ret &= check_rename_reply(mem_ctx,
cli, __LINE__, ¬ify.nttrans.out.changes[5],
NOTIFY_ACTION_REMOVED, "subdir-name\\subname2");
- ret &= check_rename_reply(
+ ret &= check_rename_reply(mem_ctx,
cli, __LINE__, ¬ify.nttrans.out.changes[5],
NOTIFY_ACTION_MODIFIED, "subname2-r");
- ret &= check_rename_reply(
+ ret &= check_rename_reply(mem_ctx,
cli, __LINE__, ¬ify.nttrans.out.changes[8],
NOTIFY_ACTION_OLD_NAME, "subname2-r");
- ret &= check_rename_reply(
+ ret &= check_rename_reply(mem_ctx,
cli, __LINE__, ¬ify.nttrans.out.changes[8],
NOTIFY_ACTION_NEW_NAME, "subname3-r");
- ret &= check_rename_reply(
+ ret &= check_rename_reply(mem_ctx,
cli, __LINE__, ¬ify.nttrans.out.changes[8],
NOTIFY_ACTION_MODIFIED, "subname3-r");
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name\\subname1-r", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name,
+ "subdir-name\\subname1-r", STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[1].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[1].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[1].name, "subdir-name",
+ STR_UNICODE);
torture_assert_int_equal_goto(mem_ctx,
notify.nttrans.out.changes[2].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[2].name, "subname3-r", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[2].name, "subname3-r",
+ STR_UNICODE);
done:
smb_raw_exit(cli->session);
printf("TESTING CHANGE NOTIFY WITH MASK CHANGE\n");
- if (!torture_setup_dir(cli, BASEDIR)) {
- return false;
- }
+ torture_assert(mem_ctx, torture_setup_dir(cli, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
/*
get a handle on the directory
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_MODIFIED, ret, done,
"wrong action (exp: MODIFIED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "tname1", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "tname1",
+ STR_UNICODE);
/* Now try and change the mask to include other events.
* This should not work - once the mask is set on a directory
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_MODIFIED, ret, done,
"wrong action (exp: MODIFIED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subname2-r", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subname2-r",
+ STR_UNICODE);
status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify);
torture_assert_ntstatus_ok_goto(mem_ctx, status, ret, done,
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_MODIFIED, ret, done,
"wrong action (exp: MODIFIED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subname3-r", STR_UNICODE);
-
- if (!ret) {
- goto done;
- }
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subname3-r",
+ STR_UNICODE);
done:
smb_raw_exit(cli->session);
printf("TESTING CHANGE NOTIFY COMPLETION FILTERS\n");
- if (!torture_setup_dir(cli, BASEDIR)) {
- return false;
- }
+ torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
tv = timeval_current_ofs(1000, 0);
t = timeval_to_nttime(&tv);
printf("TESTING CHANGE NOTIFY ON FILES\n");
- if (!torture_setup_dir(cli, BASEDIR)) {
- return false;
- }
+ torture_assert(mem_ctx, torture_setup_dir(cli, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.root_fid.fnum = 0;
printf("TESTING CHANGE NOTIFY FOLLOWED BY TDIS\n");
- if (!torture_setup_dir(cli1, BASEDIR)) {
- return false;
- }
+ torture_assert(tctx, torture_setup_dir(cli1, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
- if (!torture_open_connection(&cli, tctx, 0)) {
- return false;
- }
+ torture_assert(tctx, torture_open_connection(&cli, tctx, 0),
+ "Failed to open connection.");
/*
get a handle on the directory
printf("TESTING CHANGE NOTIFY FOLLOWED BY EXIT\n");
- if (!torture_setup_dir(cli1, BASEDIR)) {
- return false;
- }
+ torture_assert(tctx, torture_setup_dir(cli1, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
- if (!torture_open_connection(&cli, tctx, 0)) {
- return false;
- }
+ torture_assert(tctx, torture_open_connection(&cli, tctx, 0),
+ "Failed to open connection.");
/*
get a handle on the directory
printf("TESTING CHANGE NOTIFY FOLLOWED BY ULOGOFF\n");
- if (!torture_setup_dir(cli1, BASEDIR)) {
- return false;
- }
+ torture_assert(tctx, torture_setup_dir(cli1, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
- if (!torture_open_connection(&cli, tctx, 0)) {
- return false;
- }
+ torture_assert(tctx, torture_open_connection(&cli, tctx, 0),
+ "Failed to open connection.");
/*
get a handle on the directory
printf("TESTING CHANGE NOTIFY FOLLOWED BY TCP DISCONNECT\n");
- if (!torture_setup_dir(cli1, BASEDIR)) {
- return false;
- }
+ torture_assert(tctx, torture_setup_dir(cli1, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
- if (!torture_open_connection(&cli, tctx, 0)) {
- return false;
- }
+ torture_assert(tctx, torture_open_connection(&cli, tctx, 0),
+ "Failed to open connection.");
/*
get a handle on the directory
struct smbcli_request *req1, *req2;
printf("TESTING CHANGE NOTIFY TWICE ON ONE DIRECTORY\n");
-
- if (!torture_setup_dir(cli, BASEDIR)) {
- return false;
- }
+
+ torture_assert(mem_ctx, torture_setup_dir(cli, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
+
/*
get a handle on the directory
*/
"smb_raw_changenotify_recv");
torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
1, ret, done, "wrong number of changes");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name2");
"smb_raw_changenotify_recv");
torture_assert_int_equal_goto(mem_ctx, notify.nttrans.out.num_changes,
1, ret, done, "wrong number of changes");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name2", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "subdir-name2",
+ STR_UNICODE);
done:
smb_raw_exit(cli->session);
printf("TESTING CHANGE NOTIFY FOR DIFFERENT DEPTHS\n");
- if (!torture_setup_dir(cli, BASEDIR)) {
- return false;
- }
+ torture_assert(mem_ctx, torture_setup_dir(cli, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.root_fid.fnum = 0;
printf("TESTING CHANGE NOTIFY EVENT OVERFLOW\n");
- if (!torture_setup_dir(cli, BASEDIR)) {
- return false;
- }
+ torture_assert(mem_ctx, torture_setup_dir(cli, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
/* get a handle on the directory */
io.generic.level = RAW_OPEN_NTCREATEX;
printf("TESTING CHANGE NOTIFY BASEDIR EVENTS\n");
- if (!torture_setup_dir(cli, BASEDIR)) {
- return false;
- }
+ torture_assert(mem_ctx, torture_setup_dir(cli, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
/* get a handle on the directory */
io.generic.level = RAW_OPEN_NTCREATEX;
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_MODIFIED, ret, done,
"wrong action (exp: MODIFIED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "tname1", STR_UNICODE);
+ CHECK_WSTR(mem_ctx, notify.nttrans.out.changes[0].name, "tname1",
+ STR_UNICODE);
done:
smb_raw_exit(cli->session);
struct smbcli_tree *tree = NULL;
printf("TESTING SIMPLE CHANGE NOTIFY\n");
-
- if (!torture_setup_dir(cli, BASEDIR)) {
- return false;
- }
+
+ torture_assert(torture, torture_setup_dir(cli, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
/*
get a handle on the directory
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(torture, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("Testing notify rmdir\n");
req = smb_raw_changenotify_send(cli->tree, ¬ify);
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(torture, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("SIMPLE CHANGE NOTIFY OK\n");
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(torture, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("Testing notify rmdir\n");
req = smb_raw_changenotify_send(cli->tree, ¬ify);
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(torture, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("CHANGE NOTIFY WITH TCON OK\n");
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_ADDED, ret, done,
"wrong action (exp: ADDED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(torture, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("Testing notify rmdir\n");
req = smb_raw_changenotify_send(cli->tree, ¬ify);
notify.nttrans.out.changes[0].action,
NOTIFY_ACTION_REMOVED, ret, done,
"wrong action (exp: REMOVED)");
- CHECK_WSTR(notify.nttrans.out.changes[0].name, "subdir-name", STR_UNICODE);
+ CHECK_WSTR(torture, notify.nttrans.out.changes[0].name, "subdir-name",
+ STR_UNICODE);
printf("CHANGE NOTIFY WITH TDIS OK\n");
done:
torture_comment(tctx, "TESTING CHANGE NOTIFY REPLY ALIGNMENT\n");
- if (!torture_setup_dir(cli, BASEDIR)) {
- return false;
- }
+ torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+ "Failed to setup up test directory: " BASEDIR);
/* get a handle on the directory */
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.fname = BASEDIR;
status = smb_raw_open(cli->tree, tctx, &io);
- torture_assert_ntstatus_ok(tctx, status, "");
+ torture_assert_ntstatus_ok(tctx, status, "smb_raw_open");
fnum = io.ntcreatex.out.file.fnum;
/* ask for a change notify, on file creation */
smbcli_close(cli->tree, fnum2);
status = smb_raw_changenotify_recv(req, tctx, ¬ify);
- torture_assert_ntstatus_ok(tctx, status, "");
+ torture_assert_ntstatus_ok(tctx, status, "smb_raw_changenotify_recv");
/* create 4 files that will cause CHANGE_NOTIFY_INFO structures
* to be returned in the same packet with all possible 4-byte padding
* the alignment checking for us. */
req = smb_raw_changenotify_send(cli->tree, ¬ify);
status = smb_raw_changenotify_recv(req, tctx, ¬ify);
- torture_assert_ntstatus_ok(tctx, status, "");
+ torture_assert_ntstatus_ok(tctx, status, "smb_raw_changenotify_recv");
/* Do basic checking for correctness. */
torture_assert(tctx, notify.nttrans.out.num_changes == num_names, "");
for (i = 0; i < num_names; i++) {
torture_assert(tctx, notify.nttrans.out.changes[i].action ==
NOTIFY_ACTION_ADDED, "");
- CHECK_WSTR2(tctx, notify.nttrans.out.changes[i].name, fnames[i],
+ CHECK_WSTR(tctx, notify.nttrans.out.changes[i].name, fnames[i],
STR_UNICODE);
}