#define CHECK_STATUS(status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \
- printf("(%s) Incorrect status %s - should be %s\n", \
- __location__, nt_errstr(status), nt_errstr(correct)); \
+ torture_result(tctx, TORTURE_FAIL, \
+ "(%s) Incorrect status %s - should be %s\n", \
+ __location__, nt_errstr(status), nt_errstr(correct)); \
ret = false; \
goto done; \
}} while (0)
#define CHECK_STATUS_CONT(status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \
- printf("(%s) Incorrect status %s - should be %s\n", \
- __location__, nt_errstr(status), nt_errstr(correct)); \
+ torture_result(tctx, TORTURE_FAIL, \
+ "(%s) Incorrect status %s - should be %s\n", \
+ __location__, nt_errstr(status), nt_errstr(correct)); \
ret = false; \
}} while (0)
#define CHECK_STATUS_OR(status, correct1, correct2) do { \
if ((!NT_STATUS_EQUAL(status, correct1)) && \
(!NT_STATUS_EQUAL(status, correct2))) { \
- printf("(%s) Incorrect status %s - should be %s or %s\n", \
- __location__, nt_errstr(status), nt_errstr(correct1), \
- nt_errstr(correct2)); \
+ torture_result(tctx, TORTURE_FAIL, \
+ "(%s) Incorrect status %s - should be %s or %s\n", \
+ __location__, nt_errstr(status), nt_errstr(correct1), \
+ nt_errstr(correct2)); \
ret = false; \
goto done; \
}} while (0)
#define CHECK_STATUS_OR_CONT(status, correct1, correct2) do { \
if ((!NT_STATUS_EQUAL(status, correct1)) && \
(!NT_STATUS_EQUAL(status, correct2))) { \
- printf("(%s) Incorrect status %s - should be %s or %s\n", \
- __location__, nt_errstr(status), nt_errstr(correct1), \
- nt_errstr(correct2)); \
+ torture_result(tctx, TORTURE_FAIL, \
+ "(%s) Incorrect status %s - should be %s or %s\n", \
+ __location__, nt_errstr(status), nt_errstr(correct1), \
+ nt_errstr(correct2)); \
ret = false; \
}} while (0)
#define BASEDIR "\\testlock"
return false;
}
- printf("Testing RAW_LOCK_LOCK\n");
+ torture_comment(tctx, "Testing RAW_LOCK_LOCK\n");
io.generic.level = RAW_LOCK_LOCK;
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+ "Failed to create %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
- printf("Trying 0/0 lock\n");
+ torture_comment(tctx, "Trying 0/0 lock\n");
io.lock.level = RAW_LOCK_LOCK;
io.lock.in.file.fnum = fnum;
io.lock.in.count = 0;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- printf("Trying 0/1 lock\n");
+ torture_comment(tctx, "Trying 0/1 lock\n");
io.lock.level = RAW_LOCK_LOCK;
io.lock.in.file.fnum = fnum;
io.lock.in.count = 1;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- printf("Trying 0xEEFFFFFF lock\n");
+ torture_comment(tctx, "Trying 0xEEFFFFFF lock\n");
io.lock.level = RAW_LOCK_LOCK;
io.lock.in.file.fnum = fnum;
io.lock.in.count = 4000;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- printf("Trying 0xEF000000 lock\n");
+ torture_comment(tctx, "Trying 0xEF000000 lock\n");
io.lock.level = RAW_LOCK_LOCK;
io.lock.in.file.fnum = fnum;
io.lock.in.count = 4000;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- printf("Trying max lock\n");
+ torture_comment(tctx, "Trying max lock\n");
io.lock.level = RAW_LOCK_LOCK;
io.lock.in.file.fnum = fnum;
io.lock.in.count = 4000;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- printf("Trying wrong pid unlock\n");
+ torture_comment(tctx, "Trying wrong pid unlock\n");
io.lock.level = RAW_LOCK_LOCK;
io.lock.in.file.fnum = fnum;
io.lock.in.count = 4002;
return false;
}
- printf("Testing RAW_LOCK_LOCKX\n");
+ torture_comment(tctx, "Testing RAW_LOCK_LOCKX\n");
io.generic.level = RAW_LOCK_LOCKX;
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+ "Failed to create %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
io.lockx.level = RAW_LOCK_LOCKX;
io.lockx.in.file.fnum = fnum;
CHECK_STATUS(status, NT_STATUS_OK);
- printf("Trying 0xEEFFFFFF lock\n");
+ torture_comment(tctx, "Trying 0xEEFFFFFF lock\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
lock[0].count = 4000;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- printf("Trying 0xEF000000 lock\n");
+ torture_comment(tctx, "Trying 0xEF000000 lock\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
lock[0].count = 4000;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- printf("Trying zero lock\n");
+ torture_comment(tctx, "Trying zero lock\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
lock[0].count = 0;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- printf("Trying max lock\n");
+ torture_comment(tctx, "Trying max lock\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
lock[0].count = 0;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- printf("Trying 2^63\n");
+ torture_comment(tctx, "Trying 2^63\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
lock[0].count = 1;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- printf("Trying 2^63 - 1\n");
+ torture_comment(tctx, "Trying 2^63 - 1\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
lock[0].count = 1;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- printf("Trying max lock 2\n");
+ torture_comment(tctx, "Trying max lock 2\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
lock[0].count = 1;
return false;
}
- printf("Testing high pid\n");
+ torture_comment(tctx, "Testing high pid\n");
io.generic.level = RAW_LOCK_LOCKX;
cli->session->pid = 1;
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+ "Failed to create %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
if (smbcli_write(cli->tree, fnum, 0, &c, 0, 1) != 1) {
- printf("Failed to write 1 byte - %s\n", smbcli_errstr(cli->tree));
+ torture_result(tctx, TORTURE_FAIL,
+ "Failed to write 1 byte - %s\n",
+ smbcli_errstr(cli->tree));
ret = false;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
if (smbcli_read(cli->tree, fnum, &c, 0, 1) != 1) {
- printf("Failed to read 1 byte - %s\n", smbcli_errstr(cli->tree));
+ torture_result(tctx, TORTURE_FAIL,
+ "Failed to read 1 byte - %s\n",
+ smbcli_errstr(cli->tree));
ret = false;
goto done;
}
cli->session->pid = 2;
if (smbcli_read(cli->tree, fnum, &c, 0, 1) == 1) {
- printf("pid is incorrect handled for read with lock!\n");
+ torture_result(tctx, TORTURE_FAIL,
+ "pid is incorrect handled for read with lock!\n");
ret = false;
goto done;
}
cli->session->pid = 0x10001;
if (smbcli_read(cli->tree, fnum, &c, 0, 1) != 1) {
- printf("High pid is used on this server!\n");
+ torture_result(tctx, TORTURE_FAIL,
+ "High pid is used on this server!\n");
ret = false;
} else {
- printf("High pid is not used on this server (correct)\n");
+ torture_warning(tctx, "High pid is not used on this server (correct)\n");
}
done:
lp_smbcli_session_options(tctx->lp_ctx, &options);
- printf("Testing LOCKING_ANDX_CANCEL_LOCK\n");
+ torture_comment(tctx, "Testing LOCKING_ANDX_CANCEL_LOCK\n");
io.generic.level = RAW_LOCK_LOCKX;
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+ "Failed to create %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
io.lockx.level = RAW_LOCK_LOCKX;
io.lockx.in.file.fnum = fnum;
t = time(NULL);
- printf("testing cancel by CANCEL_LOCK\n");
+ torture_comment(tctx, "testing cancel by CANCEL_LOCK\n");
/* setup a timed lock */
io.lockx.in.timeout = 10000;
req = smb_raw_lock_send(cli->tree, &io);
- if (req == NULL) {
- printf("Failed to setup timed lock (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+ "Failed to setup timed lock (%s)\n", __location__));
/* cancel the wrong range */
lock[0].offset = 0;
status = smbcli_request_simple_recv(req);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
- if (time(NULL) > t+2) {
- printf("lock cancel was not immediate (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx,
+ "lock cancel was not immediate (%s)\n", __location__));
- printf("testing cancel by unlock\n");
+ torture_comment(tctx, "testing cancel by unlock\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
io.lockx.in.timeout = 5000;
req = smb_raw_lock_send(cli->tree, &io);
- if (req == NULL) {
- printf("Failed to setup timed lock (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+ "Failed to setup timed lock (%s)\n", __location__));
io.lockx.in.ulock_cnt = 1;
io.lockx.in.lock_cnt = 0;
status = smbcli_request_simple_recv(req);
CHECK_STATUS(status, NT_STATUS_OK);
- if (time(NULL) > t+2) {
- printf("lock cancel by unlock was not immediate (%s) - took %d secs\n",
- __location__, (int)(time(NULL)-t));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx,
+ "lock cancel by unlock was not immediate (%s) - took %d secs\n",
+ __location__, (int)(time(NULL)-t)));
- printf("testing cancel by close\n");
+ torture_comment(tctx, "testing cancel by close\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
t = time(NULL);
io.lockx.in.timeout = 10000;
req = smb_raw_lock_send(cli->tree, &io);
- if (req == NULL) {
- printf("Failed to setup timed lock (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+ "Failed to setup timed lock (%s)\n", __location__));
status = smbcli_close(cli->tree, fnum);
CHECK_STATUS(status, NT_STATUS_OK);
status = smbcli_request_simple_recv(req);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- if (time(NULL) > t+2) {
- printf("lock cancel by close was not immediate (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx,
+ "lock cancel by close was not immediate (%s)\n", __location__));
- printf("create a new sessions\n");
+ torture_comment(tctx, "create a new sessions\n");
session = smbcli_session_init(cli->transport, tctx, false, options);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
CHECK_STATUS(status, NT_STATUS_OK);
session->vuid = setup.out.vuid;
- printf("create new tree context\n");
+ torture_comment(tctx, "create new tree context\n");
share = torture_setting_string(tctx, "share", NULL);
host = torture_setting_string(tctx, "host", NULL);
tree = smbcli_tree_init(session, tctx, false);
CHECK_STATUS(status, NT_STATUS_OK);
tree->tid = tcon.tconx.out.tid;
- printf("testing cancel by exit\n");
+ torture_comment(tctx, "testing cancel by exit\n");
fname = BASEDIR "\\test_exit.txt";
fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+ "Failed to reopen %s - %s\n",
+ fname, smbcli_errstr(tree)));
+
io.lockx.level = RAW_LOCK_LOCKX;
io.lockx.in.file.fnum = fnum;
io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
io.lockx.in.timeout = 10000;
t = time(NULL);
req = smb_raw_lock_send(tree, &io);
- if (req == NULL) {
- printf("Failed to setup timed lock (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+ "Failed to setup timed lock (%s)\n", __location__));
status = smb_raw_exit(session);
CHECK_STATUS(status, NT_STATUS_OK);
status = smbcli_request_simple_recv(req);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- if (time(NULL) > t+2) {
- printf("lock cancel by exit was not immediate (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx,
+ "lock cancel by exit was not immediate (%s)\n", __location__));
- printf("testing cancel by ulogoff\n");
+ torture_comment(tctx, "testing cancel by ulogoff\n");
fname = BASEDIR "\\test_ulogoff.txt";
fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+ "Failed to reopen %s - %s\n",
+ fname, smbcli_errstr(tree)));
+
io.lockx.level = RAW_LOCK_LOCKX;
io.lockx.in.file.fnum = fnum;
io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
io.lockx.in.timeout = 10000;
t = time(NULL);
req = smb_raw_lock_send(tree, &io);
- if (req == NULL) {
- printf("Failed to setup timed lock (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+ "Failed to setup timed lock (%s)\n", __location__));
status = smb_raw_ulogoff(session);
CHECK_STATUS(status, NT_STATUS_OK);
status = smbcli_request_simple_recv(req);
if (NT_STATUS_EQUAL(NT_STATUS_FILE_LOCK_CONFLICT, status)) {
- printf("lock not canceled by ulogoff - %s (ignored because of vfs_vifs fails it)\n",
+ torture_result(tctx, TORTURE_FAIL,
+ "lock not canceled by ulogoff - %s (ignored because of vfs_vifs fails it)\n",
nt_errstr(status));
smb_tree_disconnect(tree);
smb_raw_exit(session);
}
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- if (time(NULL) > t+2) {
- printf("lock cancel by ulogoff was not immediate (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx,
+ "lock cancel by ulogoff was not immediate (%s)\n", __location__));
- printf("testing cancel by tdis\n");
+ torture_comment(tctx, "testing cancel by tdis\n");
tree->session = cli->session;
fname = BASEDIR "\\test_tdis.txt";
fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+ "Failed to reopen %s - %s\n",
+ fname, smbcli_errstr(tree)));
+
io.lockx.level = RAW_LOCK_LOCKX;
io.lockx.in.file.fnum = fnum;
io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
io.lockx.in.timeout = 10000;
t = time(NULL);
req = smb_raw_lock_send(tree, &io);
- if (req == NULL) {
- printf("Failed to setup timed lock (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+ "Failed to setup timed lock (%s)\n", __location__));
status = smb_tree_disconnect(tree);
CHECK_STATUS(status, NT_STATUS_OK);
status = smbcli_request_simple_recv(req);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- if (time(NULL) > t+2) {
- printf("lock cancel by tdis was not immediate (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,!(time(NULL) > t+2), talloc_asprintf(tctx,
+ "lock cancel by tdis was not immediate (%s)\n", __location__));
done:
smb_raw_exit(cli->session);
return false;
}
- printf("Testing LOCK_NOT_GRANTED vs. FILE_LOCK_CONFLICT\n");
+ torture_comment(tctx, "Testing LOCK_NOT_GRANTED vs. FILE_LOCK_CONFLICT\n");
- printf("testing with timeout = 0\n");
+ torture_comment(tctx, "testing with timeout = 0\n");
fname = BASEDIR "\\test0.txt";
t = 0;
/* end of the loop */
if (t == 0) {
smb_raw_exit(cli->session);
- printf("testing with timeout > 0 (=1)\n");
+ torture_comment(tctx, "testing with timeout > 0 (=1)\n");
fname = BASEDIR "\\test1.txt";
t = 1;
goto next_run;
* to the client (after the timeout went by)
*/
smb_raw_exit(cli->session);
- printf("testing a conflict while a lock is pending\n");
+ torture_comment(tctx, "testing a conflict while a lock is pending\n");
fname = BASEDIR "\\test2.txt";
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+ "Failed to reopen %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
+
io.lockx.level = RAW_LOCK_LOCKX;
io.lockx.in.file.fnum = fnum;
io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
start = time(NULL);
io.lockx.in.timeout = 1000;
req = smb_raw_lock_send(cli->tree, &io);
- if (req == NULL) {
- printf("Failed to setup timed lock (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+ "Failed to setup timed lock (%s)\n", __location__));
io.lockx.in.timeout = 0;
lock[0].offset = 105;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
- if (time(NULL) < start+1) {
- printf("lock comes back to early (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,!(time(NULL) < start+1), talloc_asprintf(tctx,
+ "lock comes back to early (%s)\n", __location__));
smbcli_close(cli->tree, fnum);
fname = BASEDIR "\\test3.txt";
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+ "Failed to reopen %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
+
io.lockx.level = RAW_LOCK_LOCKX;
io.lockx.in.file.fnum = fnum;
io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
start = time(NULL);
io.lockx.in.timeout = 1000;
req = smb_raw_lock_send(cli->tree, &io);
- if (req == NULL) {
- printf("Failed to setup timed lock (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+ "Failed to setup timed lock (%s)\n", __location__));
io.lockx.in.timeout = 0;
lock[0].offset = 105;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
- if (time(NULL) < start+1) {
- printf("lock comes back to early (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,!(time(NULL) < start+1), talloc_asprintf(tctx,
+ "lock comes back to early (%s)\n", __location__));
smbcli_close(cli->tree, fnum);
fname = BASEDIR "\\test4.txt";
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+ "Failed to reopen %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
+
io.lockx.level = RAW_LOCK_LOCKX;
io.lockx.in.file.fnum = fnum;
io.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
start = time(NULL);
io.lockx.in.timeout = 1000;
req = smb_raw_lock_send(cli->tree, &io);
- if (req == NULL) {
- printf("Failed to setup timed lock (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(req != NULL), talloc_asprintf(tctx,
+ "Failed to setup timed lock (%s)\n", __location__));
io.lockx.in.timeout = 0;
status = smb_raw_lock(cli->tree, &io);
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
- if (time(NULL) < start+1) {
- printf("lock comes back to early (%s)\n", __location__);
- ret = false;
- goto done;
- }
+ torture_assert(tctx,!(time(NULL) < start+1), talloc_asprintf(tctx,
+ "lock comes back to early (%s)\n", __location__));
done:
smb_raw_exit(cli->session);
return false;
}
- printf("Testing LOCKING_ANDX_CHANGE_LOCKTYPE\n");
+ torture_comment(tctx, "Testing LOCKING_ANDX_CHANGE_LOCKTYPE\n");
io.generic.level = RAW_LOCK_LOCKX;
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+ "Failed to create %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
io.lockx.level = RAW_LOCK_LOCKX;
io.lockx.in.file.fnum = fnum;
CHECK_STATUS(status, NT_STATUS_OK);
if (smbcli_write(cli->tree, fnum, 0, &c, 100, 1) == 1) {
- printf("allowed write on read locked region (%s)\n", __location__);
+ torture_result(tctx, TORTURE_FAIL,
+ "allowed write on read locked region (%s)\n", __location__);
ret = false;
goto done;
}
CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRnoatomiclocks));
if (smbcli_write(cli->tree, fnum, 0, &c, 100, 1) == 1) {
- printf("allowed write after lock change (%s)\n", __location__);
+ torture_result(tctx, TORTURE_FAIL,
+ "allowed write after lock change (%s)\n", __location__);
ret = false;
goto done;
}
int fnum, i;
const char *fname = BASEDIR "\\zero.txt";
- printf("Testing zero length byte range locks:\n");
+ torture_comment(tctx, "Testing zero length byte range locks:\n");
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
io.generic.level = RAW_LOCK_LOCKX;
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
+ "Failed to create %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
/* Setup initial parameters */
io.lockx.level = RAW_LOCK_LOCKX;
for (i = 0;
i < sizeof(zero_byte_tests) / sizeof(struct double_lock_test);
i++) {
- printf(" ... {%d, %llu, %llu} + {%d, %llu, %llu} = %s\n",
+ torture_comment(tctx, " ... {%d, %llu, %llu} + {%d, %llu, %llu} = %s\n",
zero_byte_tests[i].lock1.pid,
zero_byte_tests[i].lock1.offset,
zero_byte_tests[i].lock1.count,
struct smb_lock_entry lock1;
struct smb_lock_entry lock2;
- printf("Testing LOCKX unlock:\n");
+ torture_comment(tctx, "Testing LOCKX unlock:\n");
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
}
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum1 == -1) {
- printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum1 != -1), talloc_asprintf(tctx,
+ "Failed to create %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
+
fnum2 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum2 == -1) {
- printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum2 != -1), talloc_asprintf(tctx,
+ "Failed to create %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
/* Setup initial parameters */
io.lockx.level = RAW_LOCK_LOCKX;
/**
* Take exclusive lock, then unlock it with a shared-unlock call.
*/
- printf(" taking exclusive lock.\n");
+ torture_comment(tctx, " taking exclusive lock.\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
io.lockx.in.mode = 0;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- printf(" unlock the exclusive with a shared unlock call.\n");
+ torture_comment(tctx, " unlock the exclusive with a shared unlock call.\n");
io.lockx.in.ulock_cnt = 1;
io.lockx.in.lock_cnt = 0;
io.lockx.in.mode = LOCKING_ANDX_SHARED_LOCK;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- printf(" try shared lock on pid2/fnum2, testing the unlock.\n");
+ torture_comment(tctx, " try shared lock on pid2/fnum2, testing the unlock.\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
io.lockx.in.mode = LOCKING_ANDX_SHARED_LOCK;
/**
* Unlock a shared lock with an exclusive-unlock call.
*/
- printf(" unlock new shared lock with exclusive unlock call.\n");
+ torture_comment(tctx, " unlock new shared lock with exclusive unlock call.\n");
io.lockx.in.ulock_cnt = 1;
io.lockx.in.lock_cnt = 0;
io.lockx.in.mode = 0;
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- printf(" try exclusive lock on pid1, testing the unlock.\n");
+ torture_comment(tctx, " try exclusive lock on pid1, testing the unlock.\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
io.lockx.in.mode = 0;
* Test unlocking of 0-byte locks.
*/
- printf(" lock shared and exclusive 0-byte locks, testing that Windows "
+ torture_comment(tctx, " lock shared and exclusive 0-byte locks, testing that Windows "
"always unlocks the exclusive first.\n");
lock1.pid = cli->session->pid;
lock1.offset = 10;
struct smb_lock_entry lock2;
struct smb_lock_entry locks[2];
- printf("Testing LOCKX multiple unlock:\n");
+ torture_comment(tctx, "Testing LOCKX multiple unlock:\n");
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
}
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum1 == -1) {
- printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum1 != -1), talloc_asprintf(tctx,
+ "Failed to create %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
/* Setup initial parameters */
io.lockx.level = RAW_LOCK_LOCKX;
io.lockx.in.mode = 0; /* exclusive */
/** Test1: Take second lock, but not first. */
- printf(" unlock 2 locks, first one not locked. Expect no locks "
+ torture_comment(tctx, " unlock 2 locks, first one not locked. Expect no locks "
"unlocked. \n");
io.lockx.in.ulock_cnt = 0;
CHECK_STATUS(status, NT_STATUS_OK);
/** Test2: Take first lock, but not second. */
- printf(" unlock 2 locks, second one not locked. Expect first lock "
+ torture_comment(tctx, " unlock 2 locks, second one not locked. Expect first lock "
"unlocked.\n");
io.lockx.in.ulock_cnt = 0;
struct smb_lock_entry lock1;
struct smb_lock_entry lock2;
- printf("Testing stacking:\n");
+ torture_comment(tctx, "Testing stacking:\n");
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
io.generic.level = RAW_LOCK_LOCKX;
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum1 == -1) {
- printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = false;
- goto done;
- }
+ torture_assert(tctx,(fnum1 != -1), talloc_asprintf(tctx,
+ "Failed to create %s - %s\n",
+ fname, smbcli_errstr(cli->tree)));
/* Setup initial parameters */
io.lockx.level = RAW_LOCK_LOCKX;
/**
* Try to take a shared lock, then stack an exclusive.
*/
- printf(" stacking an exclusive on top of a shared lock fails.\n");
+ torture_comment(tctx, " stacking an exclusive on top of a shared lock fails.\n");
io.lockx.in.file.fnum = fnum1;
io.lockx.in.locks = &lock1;
/**
* Prove that two exclusive locks do not stack.
*/
- printf(" two exclusive locks do not stack.\n");
+ torture_comment(tctx, " two exclusive locks do not stack.\n");
io.lockx.in.ulock_cnt = 0;
io.lockx.in.lock_cnt = 1;
io.lockx.in.mode = 0;