[PATCHES] wider use of torture_comment in some torture tests
Günther Deschner
gd at samba.org
Tue Sep 6 15:27:54 UTC 2016
Hi,
please review and push.
Guenther
--
Günther Deschner GPG-ID: 8EE11688
Red Hat gdeschner at redhat.com
Samba Team gd at samba.org
-------------- next part --------------
From 17fb565b5e68fcfa0ed674cc0c8a4468f05baaa8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd at samba.org>
Date: Mon, 22 Feb 2016 15:30:26 +0100
Subject: [PATCH 01/10] s4:torture:smb2:connect: prefer torture_comment() to
printf().
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Guenther
Signed-off-by: Günther Deschner <gd at samba.org>
---
source4/torture/smb2/connect.c | 101 +++++++++++++++++++++--------------------
1 file changed, 53 insertions(+), 48 deletions(-)
diff --git a/source4/torture/smb2/connect.c b/source4/torture/smb2/connect.c
index 6340430..cbfad24 100644
--- a/source4/torture/smb2/connect.c
+++ b/source4/torture/smb2/connect.c
@@ -28,7 +28,9 @@
/*
send a close
*/
-static NTSTATUS torture_smb2_close(struct smb2_tree *tree, struct smb2_handle handle)
+static NTSTATUS torture_smb2_close(struct torture_context *tctx,
+ struct smb2_tree *tree,
+ struct smb2_handle handle)
{
struct smb2_close io;
NTSTATUS status;
@@ -39,19 +41,19 @@ static NTSTATUS torture_smb2_close(struct smb2_tree *tree, struct smb2_handle ha
io.in.flags = SMB2_CLOSE_FLAGS_FULL_INFORMATION;
status = smb2_close(tree, &io);
if (!NT_STATUS_IS_OK(status)) {
- printf("close failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "close failed - %s\n", nt_errstr(status));
return status;
}
if (DEBUGLVL(1)) {
- printf("Close gave:\n");
- printf("create_time = %s\n", nt_time_string(tmp_ctx, io.out.create_time));
- printf("access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
- printf("write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
- printf("change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
- printf("alloc_size = %lld\n", (long long)io.out.alloc_size);
- printf("size = %lld\n", (long long)io.out.size);
- printf("file_attr = 0x%x\n", io.out.file_attr);
+ torture_comment(tctx, "Close gave:\n");
+ torture_comment(tctx, "create_time = %s\n", nt_time_string(tmp_ctx, io.out.create_time));
+ torture_comment(tctx, "access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
+ torture_comment(tctx, "write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
+ torture_comment(tctx, "change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
+ torture_comment(tctx, "alloc_size = %lld\n", (long long)io.out.alloc_size);
+ torture_comment(tctx, "size = %lld\n", (long long)io.out.size);
+ torture_comment(tctx, "file_attr = 0x%x\n", io.out.file_attr);
}
talloc_free(tmp_ctx);
@@ -75,7 +77,7 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tre
data = data_blob_talloc(tree, NULL, size);
if (size != data.length) {
- printf("data_blob_talloc(%u) failed\n", (unsigned int)size);
+ torture_comment(tctx, "data_blob_talloc(%u) failed\n", (unsigned int)size);
return NT_STATUS_NO_MEMORY;
}
@@ -90,7 +92,7 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tre
status = smb2_write(tree, &w);
if (!NT_STATUS_IS_OK(status)) {
- printf("write 1 failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "write 1 failed - %s\n", nt_errstr(status));
return status;
}
@@ -98,7 +100,7 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tre
status = smb2_write(tree, &w);
if (!NT_STATUS_IS_OK(status)) {
- printf("write 2 failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "write 2 failed - %s\n", nt_errstr(status));
return status;
}
@@ -109,7 +111,7 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tre
status = smb2_flush(tree, &f);
if (!NT_STATUS_IS_OK(status)) {
- printf("flush failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "flush failed - %s\n", nt_errstr(status));
return status;
}
@@ -120,13 +122,13 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tre
status = smb2_read(tree, tree, &r);
if (!NT_STATUS_IS_OK(status)) {
- printf("read failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "read failed - %s\n", nt_errstr(status));
return status;
}
if (data.length != r.out.data.length ||
memcmp(data.data, r.out.data.data, data.length) != 0) {
- printf("read data mismatch\n");
+ torture_comment(tctx, "read data mismatch\n");
return NT_STATUS_NET_WRITE_FAULT;
}
@@ -137,7 +139,8 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tre
/*
send a create
*/
-static NTSTATUS torture_smb2_createfile(struct smb2_tree *tree,
+static NTSTATUS torture_smb2_createfile(struct torture_context *tctx,
+ struct smb2_tree *tree,
const char *fname,
struct smb2_handle *handle)
{
@@ -160,21 +163,22 @@ static NTSTATUS torture_smb2_createfile(struct smb2_tree *tree,
status = smb2_create(tree, tmp_ctx, &io);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(tmp_ctx);
+ torture_comment(tctx, "create1 failed - %s\n", nt_errstr(status));
return status;
}
if (DEBUGLVL(1)) {
- printf("Open gave:\n");
- printf("oplock_flags = 0x%x\n", io.out.oplock_level);
- printf("create_action = 0x%x\n", io.out.create_action);
- printf("create_time = %s\n", nt_time_string(tmp_ctx, io.out.create_time));
- printf("access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
- printf("write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
- printf("change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
- printf("alloc_size = %lld\n", (long long)io.out.alloc_size);
- printf("size = %lld\n", (long long)io.out.size);
- printf("file_attr = 0x%x\n", io.out.file_attr);
- printf("handle = %016llx%016llx\n",
+ torture_comment(tctx, "Open gave:\n");
+ torture_comment(tctx, "oplock_flags = 0x%x\n", io.out.oplock_level);
+ torture_comment(tctx, "create_action = 0x%x\n", io.out.create_action);
+ torture_comment(tctx, "create_time = %s\n", nt_time_string(tmp_ctx, io.out.create_time));
+ torture_comment(tctx, "access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
+ torture_comment(tctx, "write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
+ torture_comment(tctx, "change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
+ torture_comment(tctx, "alloc_size = %lld\n", (long long)io.out.alloc_size);
+ torture_comment(tctx, "size = %lld\n", (long long)io.out.size);
+ torture_comment(tctx, "file_attr = 0x%x\n", io.out.file_attr);
+ torture_comment(tctx, "handle = %016llx%016llx\n",
(long long)io.out.file.handle.data[0],
(long long)io.out.file.handle.data[1]);
}
@@ -190,7 +194,7 @@ static NTSTATUS torture_smb2_createfile(struct smb2_tree *tree,
/*
basic testing of SMB2 connection calls
*/
-bool torture_smb2_connect(struct torture_context *torture)
+bool torture_smb2_connect(struct torture_context *tctx)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
@@ -199,52 +203,53 @@ bool torture_smb2_connect(struct torture_context *torture)
NTSTATUS status;
bool ok;
- ok = torture_smb2_connection(torture, &tree);
- torture_assert(torture, ok, "torture_smb2_connection failed");
+ ok = torture_smb2_connection(tctx, &tree);
+ torture_assert(tctx, ok, "torture_smb2_connection failed");
smb2_util_unlink(tree, "test9.dat");
- status = torture_smb2_createfile(tree, "test9.dat", &h1);
- torture_assert_ntstatus_ok(torture, status, "create failed");
+ status = torture_smb2_createfile(tctx, tree, "test9.dat", &h1);
+ torture_assert_ntstatus_ok(tctx, status, "create failed");
- status = torture_smb2_createfile(tree, "test9.dat", &h2);
- torture_assert_ntstatus_ok(torture, status, "create failed");
+ status = torture_smb2_createfile(tctx, tree, "test9.dat", &h2);
+ torture_assert_ntstatus_ok(tctx, status, "create failed");
- status = torture_smb2_write(torture, tree, h1);
- torture_assert_ntstatus_ok(torture, status, "write failed");
+ status = torture_smb2_write(tctx, tree, h1);
+ torture_assert_ntstatus_ok(tctx, status, "write failed");
- status = torture_smb2_close(tree, h1);
- torture_assert_ntstatus_ok(torture, status, "close failed");
+ status = torture_smb2_close(tctx, tree, h1);
+ torture_assert_ntstatus_ok(tctx, status, "close failed");
- status = torture_smb2_close(tree, h2);
- torture_assert_ntstatus_ok(torture, status, "close failed");
+ status = torture_smb2_close(tctx, tree, h2);
+ torture_assert_ntstatus_ok(tctx, status, "close failed");
status = smb2_util_close(tree, h1);
- torture_assert_ntstatus_equal(torture, status, NT_STATUS_FILE_CLOSED,
+ torture_assert_ntstatus_equal(tctx, status, NT_STATUS_FILE_CLOSED,
"close should have closed the handle");
status = smb2_tdis(tree);
- torture_assert_ntstatus_ok(torture, status, "tdis failed");
+ torture_assert_ntstatus_ok(tctx, status, "tdis failed");
status = smb2_tdis(tree);
- torture_assert_ntstatus_equal(torture, status,
+ torture_assert_ntstatus_equal(tctx, status,
NT_STATUS_NETWORK_NAME_DELETED,
"tdis should have closed the tcon");
status = smb2_logoff(tree->session);
- torture_assert_ntstatus_ok(torture, status, "logoff failed");
+ torture_assert_ntstatus_ok(tctx, status, "logoff failed");
req = smb2_logoff_send(tree->session);
- torture_assert_not_null(torture, req, "smb2_logoff_send failed");
+ torture_assert_not_null(tctx, req, "smb2_logoff_send failed");
req->session = NULL;
status = smb2_logoff_recv(req);
- torture_assert_ntstatus_equal(torture, status, NT_STATUS_USER_SESSION_DELETED,
+
+ torture_assert_ntstatus_equal(tctx, status, NT_STATUS_USER_SESSION_DELETED,
"logoff should have disabled session");
status = smb2_keepalive(tree->session->transport);
- torture_assert_ntstatus_ok(torture, status, "keepalive failed");
+ torture_assert_ntstatus_ok(tctx, status, "keepalive failed");
talloc_free(mem_ctx);
--
2.7.4
From b50d6f027b814f1ed05a97550881a3541e0e570f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd at samba.org>
Date: Mon, 22 Feb 2016 17:39:19 +0100
Subject: [PATCH 02/10] source4/torture/rpc/testjoin.c: prefer
torture_comment() over printf().
Guenther
Signed-off-by: Guenther Deschner <gd at samba.org>
---
source4/torture/rpc/testjoin.c | 90 +++++++++++++++++++++---------------------
1 file changed, 46 insertions(+), 44 deletions(-)
diff --git a/source4/torture/rpc/testjoin.c b/source4/torture/rpc/testjoin.c
index 7fbf301..2252dce 100644
--- a/source4/torture/rpc/testjoin.c
+++ b/source4/torture/rpc/testjoin.c
@@ -51,7 +51,8 @@ struct test_join {
};
-static NTSTATUS DeleteUser_byname(struct dcerpc_binding_handle *b,
+static NTSTATUS DeleteUser_byname(struct torture_context *tctx,
+ struct dcerpc_binding_handle *b,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle, const char *name)
{
@@ -89,11 +90,11 @@ static NTSTATUS DeleteUser_byname(struct dcerpc_binding_handle *b,
status = dcerpc_samr_OpenUser_r(b, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- printf("OpenUser(%s) failed - %s\n", name, nt_errstr(status));
+ torture_comment(tctx, "OpenUser(%s) failed - %s\n", name, nt_errstr(status));
return status;
}
if (!NT_STATUS_IS_OK(r.out.result)) {
- printf("OpenUser(%s) failed - %s\n", name, nt_errstr(r.out.result));
+ torture_comment(tctx, "OpenUser(%s) failed - %s\n", name, nt_errstr(r.out.result));
return r.out.result;
}
@@ -116,7 +117,7 @@ static NTSTATUS DeleteUser_byname(struct dcerpc_binding_handle *b,
when finished
*/
-struct test_join *torture_create_testuser_max_pwlen(struct torture_context *torture,
+struct test_join *torture_create_testuser_max_pwlen(struct torture_context *tctx,
const char *username,
const char *domain,
uint16_t acct_type,
@@ -142,7 +143,7 @@ struct test_join *torture_create_testuser_max_pwlen(struct torture_context *tort
int policy_min_pw_len = 0;
struct test_join *join;
char *random_pw;
- const char *dc_binding = torture_setting_string(torture, "dc_binding", NULL);
+ const char *dc_binding = torture_setting_string(tctx, "dc_binding", NULL);
struct dcerpc_binding_handle *b = NULL;
join = talloc(NULL, struct test_join);
@@ -152,17 +153,17 @@ struct test_join *torture_create_testuser_max_pwlen(struct torture_context *tort
ZERO_STRUCTP(join);
- printf("Connecting to SAMR\n");
+ torture_comment(tctx, "Connecting to SAMR\n");
if (dc_binding) {
status = dcerpc_pipe_connect(join,
&join->p,
dc_binding,
&ndr_table_samr,
- cmdline_credentials, NULL, torture->lp_ctx);
+ cmdline_credentials, NULL, tctx->lp_ctx);
} else {
- status = torture_rpc_connection(torture,
+ status = torture_rpc_connection(tctx,
&join->p,
&ndr_table_samr);
}
@@ -178,17 +179,17 @@ struct test_join *torture_create_testuser_max_pwlen(struct torture_context *tort
status = dcerpc_samr_Connect_r(b, join, &c);
if (!NT_STATUS_IS_OK(status)) {
const char *errstr = nt_errstr(status);
- printf("samr_Connect failed - %s\n", errstr);
+ torture_comment(tctx, "samr_Connect failed - %s\n", errstr);
return NULL;
}
if (!NT_STATUS_IS_OK(c.out.result)) {
const char *errstr = nt_errstr(c.out.result);
- printf("samr_Connect failed - %s\n", errstr);
+ torture_comment(tctx, "samr_Connect failed - %s\n", errstr);
return NULL;
}
if (domain) {
- printf("Opening domain %s\n", domain);
+ torture_comment(tctx, "Opening domain %s\n", domain);
name.string = domain;
l.in.connect_handle = &handle;
@@ -197,11 +198,11 @@ struct test_join *torture_create_testuser_max_pwlen(struct torture_context *tort
status = dcerpc_samr_LookupDomain_r(b, join, &l);
if (!NT_STATUS_IS_OK(status)) {
- printf("LookupDomain failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "LookupDomain failed - %s\n", nt_errstr(status));
goto failed;
}
if (!NT_STATUS_IS_OK(l.out.result)) {
- printf("LookupDomain failed - %s\n", nt_errstr(l.out.result));
+ torture_comment(tctx, "LookupDomain failed - %s\n", nt_errstr(l.out.result));
goto failed;
}
} else {
@@ -219,15 +220,15 @@ struct test_join *torture_create_testuser_max_pwlen(struct torture_context *tort
status = dcerpc_samr_EnumDomains_r(b, join, &e);
if (!NT_STATUS_IS_OK(status)) {
- printf("EnumDomains failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "EnumDomains failed - %s\n", nt_errstr(status));
goto failed;
}
if (!NT_STATUS_IS_OK(e.out.result)) {
- printf("EnumDomains failed - %s\n", nt_errstr(e.out.result));
+ torture_comment(tctx, "EnumDomains failed - %s\n", nt_errstr(e.out.result));
goto failed;
}
if ((num_entries != 2) || (sam && sam->count != 2)) {
- printf("unexpected number of domains\n");
+ torture_comment(tctx, "unexpected number of domains\n");
goto failed;
}
for (i=0; i < 2; i++) {
@@ -237,7 +238,7 @@ struct test_join *torture_create_testuser_max_pwlen(struct torture_context *tort
}
}
if (domain) {
- printf("Opening domain %s\n", domain);
+ torture_comment(tctx, "Opening domain %s\n", domain);
name.string = domain;
l.in.connect_handle = &handle;
@@ -246,15 +247,15 @@ struct test_join *torture_create_testuser_max_pwlen(struct torture_context *tort
status = dcerpc_samr_LookupDomain_r(b, join, &l);
if (!NT_STATUS_IS_OK(status)) {
- printf("LookupDomain failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "LookupDomain failed - %s\n", nt_errstr(status));
goto failed;
}
if (!NT_STATUS_IS_OK(l.out.result)) {
- printf("LookupDomain failed - %s\n", nt_errstr(l.out.result));
+ torture_comment(tctx, "LookupDomain failed - %s\n", nt_errstr(l.out.result));
goto failed;
}
} else {
- printf("cannot proceed without domain name\n");
+ torture_comment(tctx, "cannot proceed without domain name\n");
goto failed;
}
}
@@ -271,15 +272,15 @@ struct test_join *torture_create_testuser_max_pwlen(struct torture_context *tort
status = dcerpc_samr_OpenDomain_r(b, join, &o);
if (!NT_STATUS_IS_OK(status)) {
- printf("OpenDomain failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "OpenDomain failed - %s\n", nt_errstr(status));
goto failed;
}
if (!NT_STATUS_IS_OK(o.out.result)) {
- printf("OpenDomain failed - %s\n", nt_errstr(o.out.result));
+ torture_comment(tctx, "OpenDomain failed - %s\n", nt_errstr(o.out.result));
goto failed;
}
- printf("Creating account %s\n", username);
+ torture_comment(tctx, "Creating account %s\n", username);
again:
name.string = username;
@@ -293,19 +294,19 @@ again:
status = dcerpc_samr_CreateUser2_r(b, join, &r);
if (!NT_STATUS_IS_OK(status)) {
- printf("CreateUser2 failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "CreateUser2 failed - %s\n", nt_errstr(status));
goto failed;
}
if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_USER_EXISTS)) {
- status = DeleteUser_byname(b, join, &join->domain_handle, name.string);
+ status = DeleteUser_byname(tctx, b, join, &join->domain_handle, name.string);
if (NT_STATUS_IS_OK(status)) {
goto again;
}
}
if (!NT_STATUS_IS_OK(r.out.result)) {
- printf("CreateUser2 failed - %s\n", nt_errstr(r.out.result));
+ torture_comment(tctx, "CreateUser2 failed - %s\n", nt_errstr(r.out.result));
goto failed;
}
@@ -321,7 +322,7 @@ again:
random_pw = generate_random_password(join, MAX(8, policy_min_pw_len), max_pw_len);
- printf("Setting account password '%s'\n", random_pw);
+ torture_comment(tctx, "Setting account password '%s'\n", random_pw);
ZERO_STRUCT(u);
s.in.user_handle = &join->user_handle;
@@ -333,9 +334,9 @@ again:
status = dcerpc_fetch_session_key(join->p, &session_key);
if (!NT_STATUS_IS_OK(status)) {
- printf("SetUserInfo level %u - no session key - %s\n",
+ torture_comment(tctx, "SetUserInfo level %u - no session key - %s\n",
s.in.level, nt_errstr(status));
- torture_leave_domain(torture, join);
+ torture_leave_domain(tctx, join);
goto failed;
}
@@ -343,11 +344,11 @@ again:
status = dcerpc_samr_SetUserInfo_r(b, join, &s);
if (!NT_STATUS_IS_OK(status)) {
- printf("SetUserInfo failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "SetUserInfo failed - %s\n", nt_errstr(status));
goto failed;
}
if (!NT_STATUS_IS_OK(s.out.result)) {
- printf("SetUserInfo failed - %s\n", nt_errstr(s.out.result));
+ torture_comment(tctx, "SetUserInfo failed - %s\n", nt_errstr(s.out.result));
goto failed;
}
@@ -369,18 +370,18 @@ again:
u.info21.description.string = talloc_asprintf(join,
"Samba4 torture account created by host %s: %s",
- lpcfg_netbios_name(torture->lp_ctx),
+ lpcfg_netbios_name(tctx->lp_ctx),
timestring(join, time(NULL)));
- printf("Resetting ACB flags, force pw change time\n");
+ torture_comment(tctx, "Resetting ACB flags, force pw change time\n");
status = dcerpc_samr_SetUserInfo_r(b, join, &s);
if (!NT_STATUS_IS_OK(status)) {
- printf("SetUserInfo failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "SetUserInfo failed - %s\n", nt_errstr(status));
goto failed;
}
if (!NT_STATUS_IS_OK(s.out.result)) {
- printf("SetUserInfo failed - %s\n", nt_errstr(s.out.result));
+ torture_comment(tctx, "SetUserInfo failed - %s\n", nt_errstr(s.out.result));
goto failed;
}
@@ -391,7 +392,7 @@ again:
return join;
failed:
- torture_leave_domain(torture, join);
+ torture_leave_domain(tctx, join);
return NULL;
}
@@ -484,7 +485,8 @@ NTSTATUS torture_delete_testuser(struct torture_context *torture,
{
NTSTATUS status;
- status = DeleteUser_byname(join->p->binding_handle,
+ status = DeleteUser_byname(torture,
+ join->p->binding_handle,
torture,
&join->domain_handle,
username);
@@ -608,10 +610,10 @@ _PUBLIC_ struct test_join *torture_join_domain(struct torture_context *tctx,
status = dcerpc_samr_SetUserInfo_r(tj->p->binding_handle, tj, &s);
if (!NT_STATUS_IS_OK(status)) {
- printf("SetUserInfo (non-critical) failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "SetUserInfo (non-critical) failed - %s\n", nt_errstr(status));
}
if (!NT_STATUS_IS_OK(s.out.result)) {
- printf("SetUserInfo (non-critical) failed - %s\n", nt_errstr(s.out.result));
+ torture_comment(tctx, "SetUserInfo (non-critical) failed - %s\n", nt_errstr(s.out.result));
}
*machine_credentials = cli_credentials_init(tj);
@@ -722,7 +724,7 @@ static NTSTATUS torture_leave_ads_domain(struct torture_context *torture,
leave the domain, deleting the machine acct
*/
-_PUBLIC_ void torture_leave_domain(struct torture_context *torture, struct test_join *join)
+_PUBLIC_ void torture_leave_domain(struct torture_context *tctx, struct test_join *join)
{
struct samr_DeleteUser d;
NTSTATUS status;
@@ -736,17 +738,17 @@ _PUBLIC_ void torture_leave_domain(struct torture_context *torture, struct test_
/* Delete machine account */
status = dcerpc_samr_DeleteUser_r(join->p->binding_handle, join, &d);
if (!NT_STATUS_IS_OK(status)) {
- printf("DeleteUser failed\n");
+ torture_comment(tctx, "DeleteUser failed\n");
} else if (!NT_STATUS_IS_OK(d.out.result)) {
- printf("Delete of machine account %s failed\n",
+ torture_comment(tctx, "Delete of machine account %s failed\n",
join->netbios_name);
} else {
- printf("Delete of machine account %s was successful.\n",
+ torture_comment(tctx, "Delete of machine account %s was successful.\n",
join->netbios_name);
}
if (join->libnet_r) {
- status = torture_leave_ads_domain(torture, join, join->libnet_r);
+ status = torture_leave_ads_domain(tctx, join, join->libnet_r);
}
talloc_free(join);
--
2.7.4
From 654571fa45f77c27991e63f7c1460b1ebb166097 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd at samba.org>
Date: Mon, 22 Feb 2016 15:46:24 +0100
Subject: [PATCH 03/10] s4:torture:smb2:maxwrite: prefer torture_comment() to
printf().
Guenther
Signed-off-by: Guenther Deschner <gd at samba.org>
---
source4/torture/smb2/maxwrite.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/source4/torture/smb2/maxwrite.c b/source4/torture/smb2/maxwrite.c
index 892bbd7..c9dede9 100644
--- a/source4/torture/smb2/maxwrite.c
+++ b/source4/torture/smb2/maxwrite.c
@@ -57,20 +57,20 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx,
w.in.data.data[i] = i % 256;
}
- printf("trying to write %d bytes (min=%d max=%d)\n",
+ torture_comment(tctx, "trying to write %d bytes (min=%d max=%d)\n",
len, min, max);
status = smb2_write(tree, &w);
if (!NT_STATUS_IS_OK(status)) {
- printf("write failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "write failed - %s\n", nt_errstr(status));
max = len-1;
status = smb2_util_close(tree, handle);
if (!NT_STATUS_IS_OK(status)) {
/* vista bug */
- printf("coping with server disconnect\n");
+ torture_comment(tctx, "coping with server disconnect\n");
talloc_free(tree);
- if (!torture_smb2_connection(torture, &tree)) {
- printf("failed to reconnect\n");
+ if (!torture_smb2_connection(tctx, &tree)) {
+ torture_comment(tctx, "failed to reconnect\n");
return NT_STATUS_NET_WRITE_FAULT;
}
}
@@ -86,20 +86,20 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx,
r.in.length = len;
r.in.offset = 0;
- printf("reading %d bytes\n", len);
+ torture_comment(tctx, "reading %d bytes\n", len);
status = smb2_read(tree, tmp_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- printf("read failed - %s\n", nt_errstr(status));
+ torture_comment(tctx, "read failed - %s\n", nt_errstr(status));
} else if (w.in.data.length != r.out.data.length ||
memcmp(w.in.data.data, r.out.data.data, len) != 0) {
- printf("read data mismatch\n");
+ torture_comment(tctx, "read data mismatch\n");
}
talloc_free(tmp_ctx);
}
- printf("converged: len=%d\n", max);
+ torture_comment(tctx, "converged: len=%d\n", max);
smb2_util_close(tree, handle);
smb2_util_unlink(tree, FNAME);
@@ -111,22 +111,22 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx,
/*
basic testing of SMB2 connection calls
*/
-bool torture_smb2_maxwrite(struct torture_context *torture)
+bool torture_smb2_maxwrite(struct torture_context *tctx)
{
struct smb2_tree *tree;
struct smb2_handle h1;
- NTSTATUS status;
- if (!torture_smb2_connection(torture, &tree)) {
+ if (!torture_smb2_connection(tctx, &tree)) {
return false;
}
- h1 = torture_smb2_create(tree, FNAME);
- status = torture_smb2_write(torture, tree, h1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Write failed - %s\n", nt_errstr(status));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx,
+ torture_smb2_createfile(tctx, tree, FNAME, &h1),
+ "failed to create file handle");
+
+ torture_assert_ntstatus_ok(tctx,
+ torture_smb2_write(tctx, tree, h1),
+ "Write failed");
return true;
}
--
2.7.4
From 004f044cfb270b4ccc32c09b9e70fdf79dfcd573 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd at samba.org>
Date: Fri, 26 Feb 2016 17:15:32 +0100
Subject: [PATCH 04/10] s4-torture: reformat TORTURE_SMB2 wscript_build list.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Guenther
Signed-off-by: Günther Deschner <gd at samba.org>
---
source4/torture/smb2/wscript_build | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/source4/torture/smb2/wscript_build b/source4/torture/smb2/wscript_build
index e667f00..a2e27db 100644
--- a/source4/torture/smb2/wscript_build
+++ b/source4/torture/smb2/wscript_build
@@ -1,10 +1,34 @@
#!/usr/bin/env python
bld.SAMBA_MODULE('TORTURE_SMB2',
- source='''connect.c scan.c util.c getinfo.c setinfo.c lock.c notify.c
- smb2.c durable_open.c durable_v2_open.c oplock.c dir.c lease.c create.c
- acls.c read.c compound.c streams.c ioctl.c rename.c maxfid.c
- session.c delete-on-close.c replay.c notify_disabled.c dosmode.c''',
+ source='''
+ acls.c
+ compound.c
+ connect.c
+ create.c
+ delete-on-close.c
+ dir.c
+ dosmode.c
+ durable_open.c
+ durable_v2_open.c
+ getinfo.c
+ ioctl.c
+ lease.c
+ lock.c
+ maxfid.c
+ notify.c
+ notify_disabled.c
+ oplock.c
+ read.c
+ rename.c
+ replay.c
+ scan.c
+ session.c
+ setinfo.c
+ smb2.c
+ streams.c
+ util.c
+ ''',
subsystem='smbtorture',
deps='LIBCLI_SMB2 POPT_CREDENTIALS torture NDR_IOCTL',
internal_module=True,
--
2.7.4
From 4d56e272bead46c8609daac23b06c706007de0a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd at samba.org>
Date: Fri, 26 Feb 2016 17:25:58 +0100
Subject: [PATCH 05/10] s4:torture:smb2:maxwrite: compile maxwrite test at
least.
Guenther
Signed-off-by: Guenther Deschner <gd at samba.org>
---
source4/torture/smb2/connect.c | 8 ++++----
source4/torture/smb2/maxwrite.c | 7 ++++++-
source4/torture/smb2/wscript_build | 1 +
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/source4/torture/smb2/connect.c b/source4/torture/smb2/connect.c
index cbfad24..063b298 100644
--- a/source4/torture/smb2/connect.c
+++ b/source4/torture/smb2/connect.c
@@ -139,10 +139,10 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tre
/*
send a create
*/
-static NTSTATUS torture_smb2_createfile(struct torture_context *tctx,
- struct smb2_tree *tree,
- const char *fname,
- struct smb2_handle *handle)
+NTSTATUS torture_smb2_createfile(struct torture_context *tctx,
+ struct smb2_tree *tree,
+ const char *fname,
+ struct smb2_handle *handle)
{
struct smb2_create io;
NTSTATUS status;
diff --git a/source4/torture/smb2/maxwrite.c b/source4/torture/smb2/maxwrite.c
index c9dede9..bc52ebc 100644
--- a/source4/torture/smb2/maxwrite.c
+++ b/source4/torture/smb2/maxwrite.c
@@ -74,7 +74,12 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx,
return NT_STATUS_NET_WRITE_FAULT;
}
}
- handle = torture_smb2_create(tree, FNAME);
+ status = torture_smb2_createfile(tctx, tree, FNAME, &handle);
+ if (!NT_STATUS_IS_OK(status)) {
+ torture_comment(tctx, "failed to create file handle\n");
+ talloc_free(tmp_ctx);
+ return status;
+ }
continue;
} else {
min = len;
diff --git a/source4/torture/smb2/wscript_build b/source4/torture/smb2/wscript_build
index a2e27db..ba7a9bd 100644
--- a/source4/torture/smb2/wscript_build
+++ b/source4/torture/smb2/wscript_build
@@ -16,6 +16,7 @@ bld.SAMBA_MODULE('TORTURE_SMB2',
lease.c
lock.c
maxfid.c
+ maxwrite.c
notify.c
notify_disabled.c
oplock.c
--
2.7.4
From 1067aeec24ffa17b05f38e029219a990eeb336c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd at samba.org>
Date: Mon, 22 Feb 2016 15:51:06 +0100
Subject: [PATCH 06/10] s4:torture:smb2:getinfo: prefer torture_comment() to
printf().
Guenther
Signed-off-by: Guenther Deschner <gd at samba.org>
---
source4/torture/smb2/getinfo.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index 82eda75..ead401a 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -94,7 +94,7 @@ static bool torture_smb2_fileinfo(struct torture_context *tctx, struct smb2_tree
torture_assert_ntstatus_ok(tctx, status, "Unable to create test dir "
DNAME "\n");
- printf("Testing file info levels\n");
+ torture_comment(tctx, "Testing file info levels\n");
torture_smb2_all_info(tree, hfile);
torture_smb2_all_info(tree, hdir);
@@ -181,7 +181,7 @@ static bool torture_smb2_fsinfo(struct torture_context *tctx)
NTSTATUS status;
struct smb2_handle handle;
- printf("Testing fsinfo levels\n");
+ torture_comment(tctx, "Testing fsinfo levels\n");
ret = torture_smb2_connection(tctx, &tree);
torture_assert(tctx, ret, "connection failed");
@@ -267,7 +267,7 @@ static bool torture_smb2_qfs_buffercheck(struct torture_context *tctx)
{ 11, 28 },
};
- printf("Testing SMB2_GETINFO_FS buffer sizes\n");
+ torture_comment(tctx, "Testing SMB2_GETINFO_FS buffer sizes\n");
ret = torture_smb2_connection(tctx, &tree);
torture_assert(tctx, ret, "connection failed");
@@ -331,7 +331,7 @@ static bool torture_smb2_qfile_buffercheck(struct torture_context *tctx)
{ 35, 8 },
};
- printf("Testing SMB2_GETINFO_FILE buffer sizes\n");
+ torture_comment(tctx, "Testing SMB2_GETINFO_FILE buffer sizes\n");
ret = torture_smb2_connection(tctx, &tree);
torture_assert(tctx, ret, "connection failed");
@@ -397,7 +397,7 @@ static bool torture_smb2_qsec_buffercheck(struct torture_context *tctx)
NTSTATUS status;
struct smb2_handle handle;
- printf("Testing SMB2_GETINFO_SECURITY buffer sizes\n");
+ torture_comment(tctx, "Testing SMB2_GETINFO_SECURITY buffer sizes\n");
ret = torture_smb2_connection(tctx, &tree);
torture_assert(tctx, ret, "connection failed");
--
2.7.4
From 875b7764d4f3030c96cf79ac753ade01ea04145e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd at samba.org>
Date: Mon, 22 Feb 2016 16:06:51 +0100
Subject: [PATCH 07/10] s4:torture:smb2:scan: prefer torture_comment() to
printf().
Guenther
Signed-off-by: Guenther Deschner <gd at samba.org>
---
source4/torture/smb2/scan.c | 90 +++++++++++++++++++++------------------------
1 file changed, 41 insertions(+), 49 deletions(-)
diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c
index 18a5cbf..a0e3b81 100644
--- a/source4/torture/smb2/scan.c
+++ b/source4/torture/smb2/scan.c
@@ -32,7 +32,7 @@
/*
scan for valid SMB2 getinfo levels
*/
-static bool torture_smb2_getinfo_scan(struct torture_context *torture)
+static bool torture_smb2_getinfo_scan(struct torture_context *tctx)
{
struct smb2_tree *tree;
NTSTATUS status;
@@ -45,13 +45,13 @@ static bool torture_smb2_getinfo_scan(struct torture_context *torture)
static const char *DNAME = "scan-getinfo.dir";
static const char *DNAME2 = "scan-getinfo.dir:2ndstream";
- if (!torture_smb2_connection(torture, &tree)) {
+ if (!torture_smb2_connection(tctx, &tree)) {
return false;
}
status = torture_setup_complex_file(tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to setup complex file '%s': %s\n",
+ torture_comment(tctx, "Failed to setup complex file '%s': %s\n",
FNAME, nt_errstr(status));
return false;
}
@@ -59,7 +59,7 @@ static bool torture_smb2_getinfo_scan(struct torture_context *torture)
status = torture_setup_complex_dir(tree, DNAME);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to setup complex dir '%s': %s\n",
+ torture_comment(tctx, "Failed to setup complex dir '%s': %s\n",
DNAME, nt_errstr(status));
smb2_util_unlink(tree, FNAME);
return false;
@@ -79,9 +79,9 @@ static bool torture_smb2_getinfo_scan(struct torture_context *torture)
io.in.info_class = i;
io.in.file.handle = fhandle;
- status = smb2_getinfo(tree, torture, &io);
+ status = smb2_getinfo(tree, tctx, &io);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) {
- printf("file level 0x%02x:%02x %u is %ld bytes - %s\n",
+ torture_comment(tctx, "file level 0x%02x:%02x %u is %ld bytes - %s\n",
io.in.info_type, io.in.info_class,
(unsigned)io.in.info_class,
(long)io.out.blob.length, nt_errstr(status));
@@ -89,9 +89,9 @@ static bool torture_smb2_getinfo_scan(struct torture_context *torture)
}
io.in.file.handle = dhandle;
- status = smb2_getinfo(tree, torture, &io);
+ status = smb2_getinfo(tree, tctx, &io);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) {
- printf("dir level 0x%02x:%02x %u is %ld bytes - %s\n",
+ torture_comment(tctx, "dir level 0x%02x:%02x %u is %ld bytes - %s\n",
io.in.info_type, io.in.info_class,
(unsigned)io.in.info_class,
(long)io.out.blob.length, nt_errstr(status));
@@ -108,7 +108,7 @@ static bool torture_smb2_getinfo_scan(struct torture_context *torture)
/*
scan for valid SMB2 setinfo levels
*/
-static bool torture_smb2_setinfo_scan(struct torture_context *torture)
+static bool torture_smb2_setinfo_scan(struct torture_context *tctx)
{
static const char *FNAME = "scan-setinfo.dat";
static const char *FNAME2 = "scan-setinfo.dat:2ndstream";
@@ -119,13 +119,13 @@ static bool torture_smb2_setinfo_scan(struct torture_context *torture)
struct smb2_handle handle;
int c, i;
- if (!torture_smb2_connection(torture, &tree)) {
+ if (!torture_smb2_connection(tctx, &tree)) {
return false;
}
status = torture_setup_complex_file(tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to setup complex file '%s': %s\n",
+ torture_comment(tctx, "Failed to setup complex file '%s': %s\n",
FNAME, nt_errstr(status));
return false;
}
@@ -134,7 +134,7 @@ static bool torture_smb2_setinfo_scan(struct torture_context *torture)
torture_smb2_testfile(tree, FNAME, &handle);
ZERO_STRUCT(io);
- io.in.blob = data_blob_talloc_zero(torture, 1024);
+ io.in.blob = data_blob_talloc_zero(tctx, 1024);
for (c=1;c<5;c++) {
for (i=0;i<0x100;i++) {
@@ -142,7 +142,7 @@ static bool torture_smb2_setinfo_scan(struct torture_context *torture)
io.in.file.handle = handle;
status = smb2_setinfo(tree, &io);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) {
- printf("file level 0x%04x - %s\n",
+ torture_comment(tctx, "file level 0x%04x - %s\n",
io.in.level, nt_errstr(status));
}
}
@@ -156,7 +156,7 @@ static bool torture_smb2_setinfo_scan(struct torture_context *torture)
/*
scan for valid SMB2 scan levels
*/
-static bool torture_smb2_find_scan(struct torture_context *torture)
+static bool torture_smb2_find_scan(struct torture_context *tctx)
{
struct smb2_tree *tree;
NTSTATUS status;
@@ -164,15 +164,13 @@ static bool torture_smb2_find_scan(struct torture_context *torture)
struct smb2_handle handle;
int i;
- if (!torture_smb2_connection(torture, &tree)) {
+ if (!torture_smb2_connection(tctx, &tree)) {
return false;
}
- status = smb2_util_roothandle(tree, &handle);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to open roothandle - %s\n", nt_errstr(status));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx,
+ smb2_util_roothandle(tree, &handle),
+ "Failed to open roothandle");
ZERO_STRUCT(io);
io.in.file.handle = handle;
@@ -184,11 +182,11 @@ static bool torture_smb2_find_scan(struct torture_context *torture)
io.in.level = i;
io.in.file.handle = handle;
- status = smb2_find(tree, torture, &io);
+ status = smb2_find(tree, tctx, &io);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS) &&
!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) &&
!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
- printf("find level 0x%04x is %ld bytes - %s\n",
+ torture_comment(tctx, "find level 0x%04x is %ld bytes - %s\n",
io.in.level, (long)io.out.blob.length, nt_errstr(status));
dump_data(1, io.out.blob.data, io.out.blob.length);
}
@@ -200,31 +198,28 @@ static bool torture_smb2_find_scan(struct torture_context *torture)
/*
scan for valid SMB2 opcodes
*/
-static bool torture_smb2_scan(struct torture_context *torture)
+static bool torture_smb2_scan(struct torture_context *tctx)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
- const char *host = torture_setting_string(torture, "host", NULL);
- const char *share = torture_setting_string(torture, "share", NULL);
+ const char *host = torture_setting_string(tctx, "host", NULL);
+ const char *share = torture_setting_string(tctx, "share", NULL);
struct cli_credentials *credentials = cmdline_credentials;
NTSTATUS status;
int opcode;
struct smb2_request *req;
struct smbcli_options options;
- lpcfg_smbcli_options(torture->lp_ctx, &options);
+ lpcfg_smbcli_options(tctx->lp_ctx, &options);
- status = smb2_connect(mem_ctx, host,
- lpcfg_smb_ports(torture->lp_ctx),
- share,
- lpcfg_resolve_context(torture->lp_ctx),
- credentials, &tree, torture->ev, &options,
- lpcfg_socket_options(torture->lp_ctx),
- lpcfg_gensec_settings(torture, torture->lp_ctx));
- if (!NT_STATUS_IS_OK(status)) {
- printf("Connection failed - %s\n", nt_errstr(status));
- return false;
- }
+ status = smb2_connect(mem_ctx, host,
+ lpcfg_smb_ports(tctx->lp_ctx),
+ share,
+ lpcfg_resolve_context(tctx->lp_ctx),
+ credentials, &tree, tctx->ev, &options,
+ lpcfg_socket_options(tctx->lp_ctx),
+ lpcfg_gensec_settings(tctx, tctx->lp_ctx));
+ torture_assert_ntstatus_ok(tctx, status, "Connection failed");
tree->session->transport->options.request_timeout = 3;
@@ -234,21 +229,18 @@ static bool torture_smb2_scan(struct torture_context *torture)
smb2_transport_send(req);
if (!smb2_request_receive(req)) {
talloc_free(tree);
- status = smb2_connect(mem_ctx, host,
- lpcfg_smb_ports(torture->lp_ctx),
- share,
- lpcfg_resolve_context(torture->lp_ctx),
- credentials, &tree, torture->ev, &options,
- lpcfg_socket_options(torture->lp_ctx),
- lpcfg_gensec_settings(mem_ctx, torture->lp_ctx));
- if (!NT_STATUS_IS_OK(status)) {
- printf("Connection failed - %s\n", nt_errstr(status));
- return false;
- }
+ status = smb2_connect(mem_ctx, host,
+ lpcfg_smb_ports(tctx->lp_ctx),
+ share,
+ lpcfg_resolve_context(tctx->lp_ctx),
+ credentials, &tree, tctx->ev, &options,
+ lpcfg_socket_options(tctx->lp_ctx),
+ lpcfg_gensec_settings(mem_ctx, tctx->lp_ctx));
+ torture_assert_ntstatus_ok(tctx, status, "Connection failed");
tree->session->transport->options.request_timeout = 3;
} else {
status = smb2_request_destroy(req);
- printf("active opcode %4d gave status %s\n", opcode, nt_errstr(status));
+ torture_comment(tctx, "active opcode %4d gave status %s\n", opcode, nt_errstr(status));
}
}
--
2.7.4
From 3d2f82f0aeff74c3005cd4c9a7ab72d7fb03ec66 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd at samba.org>
Date: Mon, 22 Feb 2016 16:26:34 +0100
Subject: [PATCH 08/10] s4:torture:smb2:read: prefer torture_comment() to
printf().
Guenther
Signed-off-by: Guenther Deschner <gd at samba.org>
---
source4/torture/smb2/read.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/source4/torture/smb2/read.c b/source4/torture/smb2/read.c
index c4469df..4904632 100644
--- a/source4/torture/smb2/read.c
+++ b/source4/torture/smb2/read.c
@@ -28,17 +28,17 @@
#define CHECK_STATUS(_status, _expected) \
- torture_assert_ntstatus_equal_goto(torture, _status, _expected, \
+ torture_assert_ntstatus_equal_goto(tctx, _status, _expected, \
ret, done, "Incorrect status")
#define CHECK_VALUE(v, correct) \
- torture_assert_int_equal_goto(torture, v, correct, \
+ torture_assert_int_equal_goto(tctx, v, correct, \
ret, done, "Incorrect value")
#define FNAME "smb2_readtest.dat"
#define DNAME "smb2_readtest.dir"
-static bool test_read_eof(struct torture_context *torture, struct smb2_tree *tree)
+static bool test_read_eof(struct torture_context *tctx, struct smb2_tree *tree)
{
bool ret = true;
NTSTATUS status;
@@ -130,7 +130,7 @@ done:
}
-static bool test_read_position(struct torture_context *torture, struct smb2_tree *tree)
+static bool test_read_position(struct torture_context *tctx, struct smb2_tree *tree)
{
bool ret = true;
NTSTATUS status;
@@ -163,7 +163,7 @@ static bool test_read_position(struct torture_context *torture, struct smb2_tree
status = smb2_getinfo_file(tree, tmp_ctx, &info);
CHECK_STATUS(status, NT_STATUS_OK);
- if (torture_setting_bool(torture, "windows", false)) {
+ if (torture_setting_bool(tctx, "windows", false)) {
CHECK_VALUE(info.all_info2.out.position, 0);
} else {
CHECK_VALUE(info.all_info2.out.position, 10);
@@ -175,7 +175,7 @@ done:
return ret;
}
-static bool test_read_dir(struct torture_context *torture, struct smb2_tree *tree)
+static bool test_read_dir(struct torture_context *tctx, struct smb2_tree *tree)
{
bool ret = true;
NTSTATUS status;
@@ -205,7 +205,7 @@ static bool test_read_dir(struct torture_context *torture, struct smb2_tree *tre
rd.in.length = 0;
rd.in.min_count = 2592;
status = smb2_read(tree, tmp_ctx, &rd);
- if (torture_setting_bool(torture, "windows", false)) {
+ if (torture_setting_bool(tctx, "windows", false)) {
CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
} else {
CHECK_STATUS(status, NT_STATUS_INVALID_DEVICE_REQUEST);
@@ -215,7 +215,7 @@ static bool test_read_dir(struct torture_context *torture, struct smb2_tree *tre
rd.in.min_count = 0;
rd.in.channel = 0;
status = smb2_read(tree, tmp_ctx, &rd);
- if (torture_setting_bool(torture, "windows", false)) {
+ if (torture_setting_bool(tctx, "windows", false)) {
CHECK_STATUS(status, NT_STATUS_OK);
} else {
CHECK_STATUS(status, NT_STATUS_INVALID_DEVICE_REQUEST);
@@ -226,7 +226,7 @@ done:
return ret;
}
-static bool test_read_access(struct torture_context *torture,
+static bool test_read_access(struct torture_context *tctx,
struct smb2_tree *tree)
{
bool ret = true;
--
2.7.4
From 166cf9d08560e3666302c4add09dfbec1f7950dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd at samba.org>
Date: Mon, 22 Feb 2016 16:27:44 +0100
Subject: [PATCH 09/10] s4:torture:smb2:acls: prefer torture_comment() to
printf().
Guenther
Signed-off-by: Guenther Deschner <gd at samba.org>
---
source4/torture/smb2/acls.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source4/torture/smb2/acls.c b/source4/torture/smb2/acls.c
index 8066bc9..d4c575b 100644
--- a/source4/torture/smb2/acls.c
+++ b/source4/torture/smb2/acls.c
@@ -1887,8 +1887,8 @@ static bool torture_smb2_con_share(struct torture_context *tctx,
lpcfg_gensec_settings(tctx, tctx->lp_ctx)
);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
- host, share, nt_errstr(status));
+ torture_comment(tctx, "Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
+ host, share, nt_errstr(status));
return false;
}
return true;
--
2.7.4
From 6f19bba27de239c27f07842ed9173a582b904719 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCnther=20Deschner?= <gd at samba.org>
Date: Mon, 22 Feb 2016 15:40:50 +0100
Subject: [PATCH 10/10] s4:torture:smb2 prefer torture_comment() to printf().
Guenther
Signed-off-by: Guenther Deschner <gd at samba.org>
---
source4/torture/smb2/connect.c | 4 +-
source4/torture/smb2/create.c | 2 +-
source4/torture/smb2/dir.c | 4 +-
source4/torture/smb2/getinfo.c | 28 ++++++-------
source4/torture/smb2/notify.c | 18 ++++-----
source4/torture/smb2/scan.c | 12 +++---
source4/torture/smb2/setinfo.c | 8 ++--
source4/torture/smb2/util.c | 92 +++++++++++++++++++++++-------------------
8 files changed, 88 insertions(+), 80 deletions(-)
diff --git a/source4/torture/smb2/connect.c b/source4/torture/smb2/connect.c
index 063b298..ecb4871 100644
--- a/source4/torture/smb2/connect.c
+++ b/source4/torture/smb2/connect.c
@@ -96,7 +96,7 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tre
return status;
}
- torture_smb2_all_info(tree, handle);
+ torture_smb2_all_info(tctx, tree, handle);
status = smb2_write(tree, &w);
if (!NT_STATUS_IS_OK(status)) {
@@ -104,7 +104,7 @@ static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tre
return status;
}
- torture_smb2_all_info(tree, handle);
+ torture_smb2_all_info(tctx, tree, handle);
ZERO_STRUCT(f);
f.in.file.handle = handle;
diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c
index 7e6be8d..9b38400 100644
--- a/source4/torture/smb2/create.c
+++ b/source4/torture/smb2/create.c
@@ -808,7 +808,7 @@ static bool test_smb2_open(struct torture_context *tctx,
smb2_util_close(tree, h1);
smb2_util_unlink(tree, fname);
- status = smb2_create_complex_file(tree, fname, &h1);
+ status = smb2_create_complex_file(tctx, tree, fname, &h1);
CHECK_STATUS(status, NT_STATUS_OK);
smb2_util_close(tree, h1);
diff --git a/source4/torture/smb2/dir.c b/source4/torture/smb2/dir.c
index 98844b4..715e984 100644
--- a/source4/torture/smb2/dir.c
+++ b/source4/torture/smb2/dir.c
@@ -441,7 +441,7 @@ static bool test_one_file(struct torture_context *tctx,
status = torture_smb2_testdir(tree, DNAME, &h);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "");
- status = smb2_create_complex_file(tree, DNAME "\\torture_search.txt",
+ status = smb2_create_complex_file(tctx, tree, DNAME "\\torture_search.txt",
&h2);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "");
@@ -1012,7 +1012,7 @@ static bool test_modify_search(struct torture_context *tctx,
smb2_util_close(tree, create.out.file.handle);
files[num_files + 2].name = talloc_asprintf(mem_ctx, "T013-13.txt.3");
- status = smb2_create_complex_file(tree, DNAME "\\T013-13.txt.3", &h);
+ status = smb2_create_complex_file(tctx, tree, DNAME "\\T013-13.txt.3", &h);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "");
smb2_util_unlink(tree, DNAME "\\T014-14.txt");
diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index ead401a..78f62e7 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -95,8 +95,8 @@ static bool torture_smb2_fileinfo(struct torture_context *tctx, struct smb2_tree
DNAME "\n");
torture_comment(tctx, "Testing file info levels\n");
- torture_smb2_all_info(tree, hfile);
- torture_smb2_all_info(tree, hdir);
+ torture_smb2_all_info(tctx, tree, hfile);
+ torture_smb2_all_info(tctx, tree, hdir);
for (i=0;i<ARRAY_SIZE(file_levels);i++) {
if (file_levels[i].level == RAW_FILEINFO_SEC_DESC) {
@@ -441,35 +441,35 @@ static bool torture_smb2_qsec_buffercheck(struct torture_context *tctx)
/* basic testing of all SMB2 getinfo levels
*/
-static bool torture_smb2_getinfo(struct torture_context *torture)
+static bool torture_smb2_getinfo(struct torture_context *tctx)
{
struct smb2_tree *tree;
bool ret = true;
NTSTATUS status;
- ret = torture_smb2_connection(torture, &tree);
- torture_assert(torture, ret, "connection failed");
+ ret = torture_smb2_connection(tctx, &tree);
+ torture_assert(tctx, ret, "connection failed");
smb2_deltree(tree, FNAME);
smb2_deltree(tree, DNAME);
- status = torture_setup_complex_file(tree, FNAME);
- torture_assert_ntstatus_ok(torture, status,
+ status = torture_setup_complex_file(tctx, tree, FNAME);
+ torture_assert_ntstatus_ok(tctx, status,
"setup complex file " FNAME);
- status = torture_setup_complex_file(tree, FNAME ":streamtwo");
- torture_assert_ntstatus_ok(torture, status,
+ status = torture_setup_complex_file(tctx, tree, FNAME ":streamtwo");
+ torture_assert_ntstatus_ok(tctx, status,
"setup complex file " FNAME ":streamtwo");
- status = torture_setup_complex_dir(tree, DNAME);
- torture_assert_ntstatus_ok(torture, status,
+ status = torture_setup_complex_dir(tctx, tree, DNAME);
+ torture_assert_ntstatus_ok(tctx, status,
"setup complex dir " DNAME);
- status = torture_setup_complex_file(tree, DNAME ":streamtwo");
- torture_assert_ntstatus_ok(torture, status,
+ status = torture_setup_complex_file(tctx, tree, DNAME ":streamtwo");
+ torture_assert_ntstatus_ok(tctx, status,
"setup complex dir " DNAME ":streamtwo");
- ret &= torture_smb2_fileinfo(torture, tree);
+ ret &= torture_smb2_fileinfo(tctx, tree);
return ret;
}
diff --git a/source4/torture/smb2/notify.c b/source4/torture/smb2/notify.c
index de4ff58..d9b0f59 100644
--- a/source4/torture/smb2/notify.c
+++ b/source4/torture/smb2/notify.c
@@ -114,7 +114,7 @@ static bool test_valid_request(struct torture_context *torture,
}
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(torture, tree, FNAME);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_notify_recv(req, torture, &n);
@@ -136,7 +136,7 @@ static bool test_valid_request(struct torture_context *torture,
}
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(torture, tree, FNAME);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_notify_recv(req, torture, &n);
@@ -155,7 +155,7 @@ static bool test_valid_request(struct torture_context *torture,
}
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(torture, tree, FNAME);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_notify_recv(req, torture, &n);
@@ -187,7 +187,7 @@ static bool test_valid_request(struct torture_context *torture,
}
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(torture, tree, FNAME);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_notify_recv(req, torture, &n);
@@ -201,7 +201,7 @@ static bool test_valid_request(struct torture_context *torture,
}
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(torture, tree, FNAME);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_notify_recv(req, torture, &n);
@@ -1066,7 +1066,7 @@ static bool torture_smb2_notify_mask(struct torture_context *torture,
sinfo.basic_info.in.create_time = 0;
torture_comment(torture, "Testing set file create time\n");
NOTIFY_MASK_TEST("Testing set file create time",
- smb2_create_complex_file(tree2,
+ smb2_create_complex_file(torture, tree2,
BASEDIR "\\tname1", &h2);,
smb2_setinfo_file(tree2, &sinfo);,
(smb2_util_close(tree2, h2),
@@ -1081,7 +1081,7 @@ static bool torture_smb2_notify_mask(struct torture_context *torture,
sinfo.basic_info.in.access_time = 0;
torture_comment(torture, "Testing set file access time\n");
NOTIFY_MASK_TEST("Testing set file access time",
- smb2_create_complex_file(tree2, BASEDIR "\\tname1", &h2);,
+ smb2_create_complex_file(torture, tree2, BASEDIR "\\tname1", &h2);,
smb2_setinfo_file(tree2, &sinfo);,
(smb2_util_close(tree2, h2),
smb2_util_unlink(tree2, BASEDIR "\\tname1"));,
@@ -1094,7 +1094,7 @@ static bool torture_smb2_notify_mask(struct torture_context *torture,
sinfo.basic_info.in.change_time = 0;
torture_comment(torture, "Testing set file change time\n");
NOTIFY_MASK_TEST("Testing set file change time",
- smb2_create_complex_file(tree2, BASEDIR "\\tname1", &h2);,
+ smb2_create_complex_file(torture, tree2, BASEDIR "\\tname1", &h2);,
smb2_setinfo_file(tree2, &sinfo);,
(smb2_util_close(tree2, h2),
smb2_util_unlink(tree2, BASEDIR "\\tname1"));,
@@ -1104,7 +1104,7 @@ static bool torture_smb2_notify_mask(struct torture_context *torture,
torture_comment(torture, "Testing write\n");
NOTIFY_MASK_TEST("Testing write",
- smb2_create_complex_file(tree2, BASEDIR "\\tname1", &h2);,
+ smb2_create_complex_file(torture, tree2, BASEDIR "\\tname1", &h2);,
smb2_util_write(tree2, h2, &c, 10000, 1);,
(smb2_util_close(tree2, h2),
smb2_util_unlink(tree2, BASEDIR "\\tname1"));,
diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c
index a0e3b81..f1527d6 100644
--- a/source4/torture/smb2/scan.c
+++ b/source4/torture/smb2/scan.c
@@ -49,22 +49,22 @@ static bool torture_smb2_getinfo_scan(struct torture_context *tctx)
return false;
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(tctx, tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
torture_comment(tctx, "Failed to setup complex file '%s': %s\n",
FNAME, nt_errstr(status));
return false;
}
- torture_setup_complex_file(tree, FNAME2);
+ torture_setup_complex_file(tctx, tree, FNAME2);
- status = torture_setup_complex_dir(tree, DNAME);
+ status = torture_setup_complex_dir(tctx, tree, DNAME);
if (!NT_STATUS_IS_OK(status)) {
torture_comment(tctx, "Failed to setup complex dir '%s': %s\n",
DNAME, nt_errstr(status));
smb2_util_unlink(tree, FNAME);
return false;
}
- torture_setup_complex_file(tree, DNAME2);
+ torture_setup_complex_file(tctx, tree, DNAME2);
torture_smb2_testfile(tree, FNAME, &fhandle);
torture_smb2_testdir(tree, DNAME, &dhandle);
@@ -123,13 +123,13 @@ static bool torture_smb2_setinfo_scan(struct torture_context *tctx)
return false;
}
- status = torture_setup_complex_file(tree, FNAME);
+ status = torture_setup_complex_file(tctx, tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
torture_comment(tctx, "Failed to setup complex file '%s': %s\n",
FNAME, nt_errstr(status));
return false;
}
- torture_setup_complex_file(tree, FNAME2);
+ torture_setup_complex_file(tctx, tree, FNAME2);
torture_smb2_testfile(tree, FNAME, &handle);
diff --git a/source4/torture/smb2/setinfo.c b/source4/torture/smb2/setinfo.c
index fee7293..3b01b05 100644
--- a/source4/torture/smb2/setinfo.c
+++ b/source4/torture/smb2/setinfo.c
@@ -102,7 +102,7 @@ bool torture_smb2_setinfo(struct torture_context *tctx)
#define RECREATE_FILE(fname) do { \
smb2_util_close(tree, handle); \
- status = smb2_create_complex_file(tree, fname, &handle); \
+ status = smb2_create_complex_file(tctx, tree, fname, &handle); \
if (!NT_STATUS_IS_OK(status)) { \
torture_result(tctx, TORTURE_FAIL, "(%s) ERROR: open of %s failed (%s)\n", \
__location__, fname, nt_errstr(status)); \
@@ -147,7 +147,7 @@ bool torture_smb2_setinfo(struct torture_context *tctx)
torture_result(tctx, TORTURE_FAIL, "(%s) %s - %s/%s should be 0x%x - 0x%x\n", __location__, \
call_name, #stype, #field, \
(unsigned int)value, (unsigned int)finfo2.stype.out.field); \
- torture_smb2_all_info(tree, handle); \
+ torture_smb2_all_info(tctx, tree, handle); \
ret = false; \
goto done; \
}} while (0)
@@ -161,7 +161,7 @@ bool torture_smb2_setinfo(struct torture_context *tctx)
(unsigned int)nt_time_to_unix(finfo2.stype.out.field)); \
torture_warning(tctx, "\t%s", timestring(tctx, value)); \
torture_warning(tctx, "\t%s\n", nt_time_string(tctx, finfo2.stype.out.field)); \
- torture_smb2_all_info(tree, handle); \
+ torture_smb2_all_info(tctx, tree, handle); \
ret = false; \
goto done; \
}} while (0)
@@ -174,7 +174,7 @@ bool torture_smb2_setinfo(struct torture_context *tctx)
goto done; \
}} while (0)
- torture_smb2_all_info(tree, handle);
+ torture_smb2_all_info(tctx, tree, handle);
torture_comment(tctx, "Test basic_information level\n");
basetime += 86400;
diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c
index d0fc695..2c9ff13 100644
--- a/source4/torture/smb2/util.c
+++ b/source4/torture/smb2/util.c
@@ -55,8 +55,11 @@ NTSTATUS smb2_util_write(struct smb2_tree *tree,
/*
create a complex file/dir using the SMB2 protocol
*/
-static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
- struct smb2_handle *handle, bool dir)
+static NTSTATUS smb2_create_complex(struct torture_context *tctx,
+ struct smb2_tree *tree,
+ const char *fname,
+ struct smb2_handle *handle,
+ bool dir)
{
TALLOC_CTX *tmp_ctx = talloc_new(tree);
char buf[7] = "abc";
@@ -121,7 +124,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
status = smb2_setinfo_file(tree, &setfile);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to setup file times - %s\n", nt_errstr(status));
+ torture_comment(tctx, "Failed to setup file times - %s\n", nt_errstr(status));
return status;
}
@@ -131,14 +134,14 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
status = smb2_getinfo_file(tree, tree, &fileinfo);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to query file times - %s\n", nt_errstr(status));
+ torture_comment(tctx, "Failed to query file times - %s\n", nt_errstr(status));
return status;
}
#define CHECK_TIME(field) do {\
if (setfile.basic_info.in.field != fileinfo.all_info2.out.field) { \
- printf("(%s) " #field " not setup correctly: %s(%llu) => %s(%llu)\n", \
+ torture_comment(tctx, "(%s) " #field " not setup correctly: %s(%llu) => %s(%llu)\n", \
__location__, \
nt_time_string(tree, setfile.basic_info.in.field), \
(unsigned long long)setfile.basic_info.in.field, \
@@ -159,25 +162,28 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
/*
create a complex file using the SMB2 protocol
*/
-NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname,
- struct smb2_handle *handle)
+NTSTATUS smb2_create_complex_file(struct torture_context *tctx,
+ struct smb2_tree *tree, const char *fname,
+ struct smb2_handle *handle)
{
- return smb2_create_complex(tree, fname, handle, false);
+ return smb2_create_complex(tctx, tree, fname, handle, false);
}
/*
create a complex dir using the SMB2 protocol
*/
-NTSTATUS smb2_create_complex_dir(struct smb2_tree *tree, const char *fname,
+NTSTATUS smb2_create_complex_dir(struct torture_context *tctx,
+ struct smb2_tree *tree, const char *fname,
struct smb2_handle *handle)
{
- return smb2_create_complex(tree, fname, handle, true);
+ return smb2_create_complex(tctx, tree, fname, handle, true);
}
/*
show lots of information about a file
*/
-void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle)
+void torture_smb2_all_info(struct torture_context *tctx,
+ struct smb2_tree *tree, struct smb2_handle handle)
{
NTSTATUS status;
TALLOC_CTX *tmp_ctx = talloc_new(tree);
@@ -193,29 +199,29 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle)
return;
}
- d_printf("all_info for '%s'\n", io.all_info2.out.fname.s);
- d_printf("\tcreate_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.create_time));
- d_printf("\taccess_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.access_time));
- d_printf("\twrite_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.write_time));
- d_printf("\tchange_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.change_time));
- d_printf("\tattrib: 0x%x\n", io.all_info2.out.attrib);
- d_printf("\tunknown1: 0x%x\n", io.all_info2.out.unknown1);
- d_printf("\talloc_size: %llu\n", (long long)io.all_info2.out.alloc_size);
- d_printf("\tsize: %llu\n", (long long)io.all_info2.out.size);
- d_printf("\tnlink: %u\n", io.all_info2.out.nlink);
- d_printf("\tdelete_pending: %u\n", io.all_info2.out.delete_pending);
- d_printf("\tdirectory: %u\n", io.all_info2.out.directory);
- d_printf("\tfile_id: %llu\n", (long long)io.all_info2.out.file_id);
- d_printf("\tea_size: %u\n", io.all_info2.out.ea_size);
- d_printf("\taccess_mask: 0x%08x\n", io.all_info2.out.access_mask);
- d_printf("\tposition: 0x%llx\n", (long long)io.all_info2.out.position);
- d_printf("\tmode: 0x%llx\n", (long long)io.all_info2.out.mode);
+ torture_comment(tctx, "all_info for '%s'\n", io.all_info2.out.fname.s);
+ torture_comment(tctx, "\tcreate_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.create_time));
+ torture_comment(tctx, "\taccess_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.access_time));
+ torture_comment(tctx, "\twrite_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.write_time));
+ torture_comment(tctx, "\tchange_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.change_time));
+ torture_comment(tctx, "\tattrib: 0x%x\n", io.all_info2.out.attrib);
+ torture_comment(tctx, "\tunknown1: 0x%x\n", io.all_info2.out.unknown1);
+ torture_comment(tctx, "\talloc_size: %llu\n", (long long)io.all_info2.out.alloc_size);
+ torture_comment(tctx, "\tsize: %llu\n", (long long)io.all_info2.out.size);
+ torture_comment(tctx, "\tnlink: %u\n", io.all_info2.out.nlink);
+ torture_comment(tctx, "\tdelete_pending: %u\n", io.all_info2.out.delete_pending);
+ torture_comment(tctx, "\tdirectory: %u\n", io.all_info2.out.directory);
+ torture_comment(tctx, "\tfile_id: %llu\n", (long long)io.all_info2.out.file_id);
+ torture_comment(tctx, "\tea_size: %u\n", io.all_info2.out.ea_size);
+ torture_comment(tctx, "\taccess_mask: 0x%08x\n", io.all_info2.out.access_mask);
+ torture_comment(tctx, "\tposition: 0x%llx\n", (long long)io.all_info2.out.position);
+ torture_comment(tctx, "\tmode: 0x%llx\n", (long long)io.all_info2.out.mode);
/* short name, if any */
io.generic.level = RAW_FILEINFO_ALT_NAME_INFORMATION;
status = smb2_getinfo_file(tree, tmp_ctx, &io);
if (NT_STATUS_IS_OK(status)) {
- d_printf("\tshort name: '%s'\n", io.alt_name_info.out.fname.s);
+ torture_comment(tctx, "\tshort name: '%s'\n", io.alt_name_info.out.fname.s);
}
/* the EAs, if any */
@@ -224,7 +230,7 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle)
if (NT_STATUS_IS_OK(status)) {
int i;
for (i=0;i<io.all_eas.out.num_eas;i++) {
- d_printf("\tEA[%d] flags=%d len=%d '%s'\n", i,
+ torture_comment(tctx, "\tEA[%d] flags=%d len=%d '%s'\n", i,
io.all_eas.out.eas[i].flags,
(int)io.all_eas.out.eas[i].value.length,
io.all_eas.out.eas[i].name.s);
@@ -237,12 +243,12 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle)
if (NT_STATUS_IS_OK(status)) {
int i;
for (i=0;i<io.stream_info.out.num_streams;i++) {
- d_printf("\tstream %d:\n", i);
- d_printf("\t\tsize %ld\n",
+ torture_comment(tctx, "\tstream %d:\n", i);
+ torture_comment(tctx, "\t\tsize %ld\n",
(long)io.stream_info.out.streams[i].size);
- d_printf("\t\talloc size %ld\n",
+ torture_comment(tctx, "\t\talloc size %ld\n",
(long)io.stream_info.out.streams[i].alloc_size);
- d_printf("\t\tname %s\n", io.stream_info.out.streams[i].stream_name.s);
+ torture_comment(tctx, "\t\tname %s\n", io.stream_info.out.streams[i].stream_name.s);
}
}
@@ -358,7 +364,7 @@ bool torture_smb2_session_setup(struct torture_context *tctx,
status = smb2_session_setup_spnego(session, credentials,
previous_session_id);
if (!NT_STATUS_IS_OK(status)) {
- printf("session setup failed: %s\n", nt_errstr(status));
+ torture_comment(tctx, "session setup failed: %s\n", nt_errstr(status));
talloc_free(session);
return false;
}
@@ -395,7 +401,7 @@ bool torture_smb2_connection_ext(struct torture_context *tctx,
lpcfg_gensec_settings(tctx, tctx->lp_ctx)
);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
+ torture_comment(tctx, "Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
host, share, nt_errstr(status));
return false;
}
@@ -430,7 +436,7 @@ bool torture_smb2_con_sopt(struct torture_context *tctx,
lpcfg_smbcli_options(tctx->lp_ctx, &options);
if (share == NULL) {
- printf("No share for option %s\n", soption);
+ torture_comment(tctx, "No share for option %s\n", soption);
return false;
}
@@ -448,7 +454,7 @@ bool torture_smb2_con_sopt(struct torture_context *tctx,
lpcfg_gensec_settings(tctx, tctx->lp_ctx)
);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
+ torture_comment(tctx, "Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
host, share, nt_errstr(status));
return false;
}
@@ -538,10 +544,11 @@ NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname,
create a complex file using SMB2, to make it easier to
find fields in SMB2 getinfo levels
*/
-NTSTATUS torture_setup_complex_file(struct smb2_tree *tree, const char *fname)
+NTSTATUS torture_setup_complex_file(struct torture_context *tctx,
+ struct smb2_tree *tree, const char *fname)
{
struct smb2_handle handle;
- NTSTATUS status = smb2_create_complex_file(tree, fname, &handle);
+ NTSTATUS status = smb2_create_complex_file(tctx, tree, fname, &handle);
NT_STATUS_NOT_OK_RETURN(status);
return smb2_util_close(tree, handle);
}
@@ -551,10 +558,11 @@ NTSTATUS torture_setup_complex_file(struct smb2_tree *tree, const char *fname)
create a complex dir using SMB2, to make it easier to
find fields in SMB2 getinfo levels
*/
-NTSTATUS torture_setup_complex_dir(struct smb2_tree *tree, const char *fname)
+NTSTATUS torture_setup_complex_dir(struct torture_context *tctx,
+ struct smb2_tree *tree, const char *fname)
{
struct smb2_handle handle;
- NTSTATUS status = smb2_create_complex_dir(tree, fname, &handle);
+ NTSTATUS status = smb2_create_complex_dir(tctx, tree, fname, &handle);
NT_STATUS_NOT_OK_RETURN(status);
return smb2_util_close(tree, handle);
}
--
2.7.4
More information about the samba-technical
mailing list