Two small cleanup patches for torture

Volker Lendecke Volker.Lendecke at SerNet.DE
Sat Apr 27 06:26:20 MDT 2013


Hi!

Please review & push if ok.

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 08406d351a50bd3c99b02320af3e182decf36f56 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 17 Apr 2013 12:34:14 +0200
Subject: [PATCH 1/2] torture: Use ZERO_STRUCTPN instead of explicit deref

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/torture/smb2/util.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c
index 59748b7..cb9a527 100644
--- a/source4/torture/smb2/util.c
+++ b/source4/torture/smb2/util.c
@@ -692,7 +692,7 @@ void smb2_generic_create_share(struct smb2_create *io, struct smb2_lease *ls,
 	}
 
 	if (ls) {
-		ZERO_STRUCT(*ls);
+		ZERO_STRUCTPN(ls);
 		ls->lease_key.data[0] = leasekey;
 		ls->lease_key.data[1] = ~leasekey;
 		ls->lease_state = leasestate;
-- 
1.7.9.5


From 24225b6224cbc60bf45d079029fdc1087657caf3 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 17 Apr 2013 13:41:54 +0200
Subject: [PATCH 2/2] torture: Only test leases if supported

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/torture/smb2/lease.c |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c
index 21d4679..992c21b 100644
--- a/source4/torture/smb2/lease.c
+++ b/source4/torture/smb2/lease.c
@@ -25,6 +25,7 @@
 #include "libcli/smb2/smb2_calls.h"
 #include "torture/torture.h"
 #include "torture/smb2/proto.h"
+#include "libcli/smb/smbXcli_base.h"
 
 #define CHECK_VAL(v, correct) do { \
 	if ((v) != (correct)) { \
@@ -117,6 +118,12 @@ static bool test_lease_request(struct torture_context *tctx,
 	const char *dname = "lease.dir";
 	bool ret = true;
 	int i;
+	uint32_t caps;
+
+	caps = smb2cli_conn_server_capabilities(tree->session->transport->conn);
+	if (!(caps & SMB2_CAP_LEASING)) {
+		torture_skip(tctx, "leases are not supported");
+	}
 
 	smb2_util_unlink(tree, fname);
 	smb2_util_unlink(tree, fname2);
@@ -193,6 +200,12 @@ static bool test_lease_upgrade(struct torture_context *tctx,
 	NTSTATUS status;
 	const char *fname = "lease.dat";
 	bool ret = true;
+	uint32_t caps;
+
+	caps = smb2cli_conn_server_capabilities(tree->session->transport->conn);
+	if (!(caps & SMB2_CAP_LEASING)) {
+		torture_skip(tctx, "leases are not supported");
+	}
 
 	smb2_util_unlink(tree, fname);
 
@@ -301,6 +314,12 @@ static bool test_lease_upgrade2(struct torture_context *tctx,
 	const char *fname = "lease.dat";
 	bool ret = true;
 	int i;
+	uint32_t caps;
+
+	caps = smb2cli_conn_server_capabilities(tree->session->transport->conn);
+	if (!(caps & SMB2_CAP_LEASING)) {
+		torture_skip(tctx, "leases are not supported");
+	}
 
 	for (i = 0; i < NUM_UPGRADE_TESTS; i++) {
 		struct lease_upgrade2_test t = lease_upgrade2_tests[i];
@@ -515,6 +534,12 @@ static bool test_lease_break(struct torture_context *tctx,
 	const char *fname = "lease.dat";
 	bool ret = true;
 	int i;
+	uint32_t caps;
+
+	caps = smb2cli_conn_server_capabilities(tree->session->transport->conn);
+	if (!(caps & SMB2_CAP_LEASING)) {
+		torture_skip(tctx, "leases are not supported");
+	}
 
 	tree->session->transport->lease.handler	= torture_lease_handler;
 	tree->session->transport->lease.private_data = tree;
@@ -677,6 +702,12 @@ static bool test_lease_oplock(struct torture_context *tctx,
 	const char *fname = "lease.dat";
 	bool ret = true;
 	int i;
+	uint32_t caps;
+
+	caps = smb2cli_conn_server_capabilities(tree->session->transport->conn);
+	if (!(caps & SMB2_CAP_LEASING)) {
+		torture_skip(tctx, "leases are not supported");
+	}
 
 	tree->session->transport->lease.handler	= torture_lease_handler;
 	tree->session->transport->lease.private_data = tree;
@@ -796,6 +827,12 @@ static bool test_lease_multibreak(struct torture_context *tctx,
 	NTSTATUS status;
 	const char *fname = "lease.dat";
 	bool ret = true;
+	uint32_t caps;
+
+	caps = smb2cli_conn_server_capabilities(tree->session->transport->conn);
+	if (!(caps & SMB2_CAP_LEASING)) {
+		torture_skip(tctx, "leases are not supported");
+	}
 
 	tree->session->transport->lease.handler	= torture_lease_handler;
 	tree->session->transport->lease.private_data = tree;
-- 
1.7.9.5



More information about the samba-technical mailing list