[SCM] Samba Shared Repository - branch master updated

Michael Adam obnox at samba.org
Mon Oct 31 21:59:03 MDT 2011


The branch, master has been updated
       via  06f4672 s4:torture:smb2: add a new durable-open.upgrade2 test to test all upgrade combinations
       via  53d1d7b s4:torture:smb2: expand durable-open.open2 test matrix by all share-modes
       via  18ca6c8 s4:torture:smb2: expand durable-open.open1 test matrix by all share-modes
       via  a4e36df s4:torture:smb2: rename the durable-open.basic2 test to durable-open.open2 for clarity
       via  a9b31e6 s4:torture:smb2: rename the durable-open.basic1 test to durable-open.open1 for clarity
      from  4bc8b0c tdb2: use HAVE_LIBREPLACE instead of _SAMBA_BUILD_.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 06f4672d23e6eaee294b4f14f0bee7285cc641c8
Author: Michael Adam <obnox at samba.org>
Date:   Tue Nov 1 01:50:52 2011 +0100

    s4:torture:smb2: add a new durable-open.upgrade2 test to test all upgrade combinations
    
    Autobuild-User: Michael Adam <obnox at samba.org>
    Autobuild-Date: Tue Nov  1 04:58:03 CET 2011 on sn-devel-104

commit 53d1d7b9390e49c73851b411819accc57a7ba054
Author: Michael Adam <obnox at samba.org>
Date:   Tue Nov 1 00:56:29 2011 +0100

    s4:torture:smb2: expand durable-open.open2 test matrix by all share-modes

commit 18ca6c850f79d053c6fe26ffc0a2cfdedf952660
Author: Michael Adam <obnox at samba.org>
Date:   Tue Nov 1 00:55:48 2011 +0100

    s4:torture:smb2: expand durable-open.open1 test matrix by all share-modes

commit a4e36df78ab3b500dc92d3fe5dbc6b58958f9a19
Author: Michael Adam <obnox at samba.org>
Date:   Tue Nov 1 00:01:31 2011 +0100

    s4:torture:smb2: rename the durable-open.basic2 test to durable-open.open2 for clarity

commit a9b31e68cfc8232e7e9aa60f70895f2ad0f245be
Author: Michael Adam <obnox at samba.org>
Date:   Mon Oct 31 23:54:06 2011 +0100

    s4:torture:smb2: rename the durable-open.basic1 test to durable-open.open1 for clarity

-----------------------------------------------------------------------

Summary of changes:
 source4/torture/smb2/durable_open.c |  183 ++++++++++++++++++++++++++---------
 source4/torture/smb2/lease.c        |   90 +++++++++++++++++
 2 files changed, 228 insertions(+), 45 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/torture/smb2/durable_open.c b/source4/torture/smb2/durable_open.c
index 33ce1e9..4bce89b 100644
--- a/source4/torture/smb2/durable_open.c
+++ b/source4/torture/smb2/durable_open.c
@@ -72,6 +72,28 @@ static inline uint32_t map_lease(const char *ls)
 	return val;
 }
 
+static inline uint32_t map_sharemode(const char *sharemode)
+{
+	uint32_t val = NTCREATEX_SHARE_ACCESS_NONE; /* 0 */
+	int i;
+
+	for (i = 0; i < strlen(sharemode); i++) {
+		switch(sharemode[i]) {
+		case 'R':
+			val |= NTCREATEX_SHARE_ACCESS_READ;
+			break;
+		case 'W':
+			val |= NTCREATEX_SHARE_ACCESS_WRITE;
+			break;
+		case 'D':
+			val |= NTCREATEX_SHARE_ACCESS_DELETE;
+			break;
+		}
+	}
+
+	return val;
+}
+
 /**
  * basic durable_open test.
  * durable state should only be granted when requested
@@ -82,23 +104,57 @@ static inline uint32_t map_lease(const char *ls)
 
 struct durable_open_vs_oplock {
 	uint8_t level;
+	const char *share_mode;
 	bool expected;
 };
 
-#define NUM_OPLOCK_OPEN_TESTS 4
+#define NUM_OPLOCK_TYPES 4
+#define NUM_SHARE_MODES 8
+#define NUM_OPLOCK_OPEN_TESTS ( NUM_OPLOCK_TYPES * NUM_SHARE_MODES )
 struct durable_open_vs_oplock durable_open_vs_oplock_table[NUM_OPLOCK_OPEN_TESTS] =
 {
-	{ SMB2_OPLOCK_LEVEL_NONE, false },
-	{ SMB2_OPLOCK_LEVEL_II, false },
-	{ SMB2_OPLOCK_LEVEL_EXCLUSIVE, false },
-	{ SMB2_OPLOCK_LEVEL_BATCH, true },
+	{ SMB2_OPLOCK_LEVEL_NONE, "", false },
+	{ SMB2_OPLOCK_LEVEL_NONE, "R", false },
+	{ SMB2_OPLOCK_LEVEL_NONE, "W", false },
+	{ SMB2_OPLOCK_LEVEL_NONE, "D", false },
+	{ SMB2_OPLOCK_LEVEL_NONE, "RD", false },
+	{ SMB2_OPLOCK_LEVEL_NONE, "RW", false },
+	{ SMB2_OPLOCK_LEVEL_NONE, "WD", false },
+	{ SMB2_OPLOCK_LEVEL_NONE, "RWD", false },
+
+	{ SMB2_OPLOCK_LEVEL_II, "", false },
+	{ SMB2_OPLOCK_LEVEL_II, "R", false },
+	{ SMB2_OPLOCK_LEVEL_II, "W", false },
+	{ SMB2_OPLOCK_LEVEL_II, "D", false },
+	{ SMB2_OPLOCK_LEVEL_II, "RD", false },
+	{ SMB2_OPLOCK_LEVEL_II, "RW", false },
+	{ SMB2_OPLOCK_LEVEL_II, "WD", false },
+	{ SMB2_OPLOCK_LEVEL_II, "RWD", false },
+
+	{ SMB2_OPLOCK_LEVEL_EXCLUSIVE, "", false },
+	{ SMB2_OPLOCK_LEVEL_EXCLUSIVE, "R", false },
+	{ SMB2_OPLOCK_LEVEL_EXCLUSIVE, "W", false },
+	{ SMB2_OPLOCK_LEVEL_EXCLUSIVE, "D", false },
+	{ SMB2_OPLOCK_LEVEL_EXCLUSIVE, "RD", false },
+	{ SMB2_OPLOCK_LEVEL_EXCLUSIVE, "RW", false },
+	{ SMB2_OPLOCK_LEVEL_EXCLUSIVE, "WD", false },
+	{ SMB2_OPLOCK_LEVEL_EXCLUSIVE, "RWD", false },
+
+	{ SMB2_OPLOCK_LEVEL_BATCH, "", true },
+	{ SMB2_OPLOCK_LEVEL_BATCH, "R", true },
+	{ SMB2_OPLOCK_LEVEL_BATCH, "W", true },
+	{ SMB2_OPLOCK_LEVEL_BATCH, "D", true },
+	{ SMB2_OPLOCK_LEVEL_BATCH, "RD", true },
+	{ SMB2_OPLOCK_LEVEL_BATCH, "RW", true },
+	{ SMB2_OPLOCK_LEVEL_BATCH, "WD", true },
+	{ SMB2_OPLOCK_LEVEL_BATCH, "RWD", true },
 };
 
-static bool test_one_durable_open_basic1(struct torture_context *tctx,
-					 struct smb2_tree *tree,
-					 const char *fname,
-					 struct smb2_create io,
-					 struct durable_open_vs_oplock test)
+static bool test_one_durable_open_open1(struct torture_context *tctx,
+					struct smb2_tree *tree,
+					const char *fname,
+					struct smb2_create io,
+					struct durable_open_vs_oplock test)
 {
 	NTSTATUS status;
 	TALLOC_CTX *mem_ctx = talloc_new(tctx);
@@ -109,6 +165,7 @@ static bool test_one_durable_open_basic1(struct torture_context *tctx,
 	smb2_util_unlink(tree, fname);
 
 	io.in.fname = fname;
+	io.in.share_access = map_sharemode(test.share_mode);
 	io.in.oplock_level = test.level;
 	status = smb2_create(tree, mem_ctx, &io);
 	CHECK_STATUS(status, NT_STATUS_OK);
@@ -128,8 +185,8 @@ done:
 	return ret;
 }
 
-bool test_durable_open_basic1(struct torture_context *tctx,
-			      struct smb2_tree *tree)
+bool test_durable_open_open1(struct torture_context *tctx,
+			     struct smb2_tree *tree)
 {
 	TALLOC_CTX *mem_ctx = talloc_new(tctx);
 	struct smb2_create io;
@@ -138,7 +195,7 @@ bool test_durable_open_basic1(struct torture_context *tctx,
 	int i;
 
 	/* Choose a random name in case the state is left a little funky. */
-	snprintf(fname, 256, "durable_open_basic1_%s.dat", generate_random_str(tctx, 8));
+	snprintf(fname, 256, "durable_open_open1_%s.dat", generate_random_str(tctx, 8));
 
 	smb2_util_unlink(tree, fname);
 
@@ -149,9 +206,6 @@ bool test_durable_open_basic1(struct torture_context *tctx,
 	io.in.reserved			= 0x00000000;
 	io.in.desired_access		= SEC_RIGHTS_FILE_ALL;
 	io.in.file_attributes		= FILE_ATTRIBUTE_NORMAL;
-	io.in.share_access		= NTCREATEX_SHARE_ACCESS_READ |
-					  NTCREATEX_SHARE_ACCESS_WRITE |
-					  NTCREATEX_SHARE_ACCESS_DELETE;
 	io.in.create_disposition	= NTCREATEX_DISP_OPEN_IF;
 	io.in.create_options		= NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
 					  NTCREATEX_OPTIONS_ASYNC_ALERT	|
@@ -163,11 +217,11 @@ bool test_durable_open_basic1(struct torture_context *tctx,
 	/* test various oplock levels with durable open */
 
 	for (i = 0; i < NUM_OPLOCK_OPEN_TESTS; i++) {
-		ret = test_one_durable_open_basic1(tctx,
-						   tree,
-						   fname,
-						   io,
-						   durable_open_vs_oplock_table[i]);
+		ret = test_one_durable_open_open1(tctx,
+						  tree,
+						  fname,
+						  io,
+						  durable_open_vs_oplock_table[i]);
 		if (ret == false) {
 			goto done;
 		}
@@ -191,24 +245,65 @@ done:
 
 struct durable_open_vs_lease {
 	const char *type;
+	const char *share_mode;
 	bool expected;
 };
 
-#define NUM_LEASE_OPEN_TESTS 5
+#define NUM_LEASE_TYPES 5
+#define NUM_LEASE_OPEN_TESTS ( NUM_LEASE_TYPES * NUM_SHARE_MODES )
 struct durable_open_vs_lease durable_open_vs_lease_table[NUM_LEASE_OPEN_TESTS] =
 {
-	{ "", false },
-	{ "R", false },
-	{ "RW", false },
-	{ "RH", true },
-	{ "RHW", true },
+	{ "", "", false },
+	{ "", "R", false },
+	{ "", "W", false },
+	{ "", "D", false },
+	{ "", "RW", false },
+	{ "", "RD", false },
+	{ "", "WD", false },
+	{ "", "RWD", false },
+
+	{ "R", "", false },
+	{ "R", "R", false },
+	{ "R", "W", false },
+	{ "R", "D", false },
+	{ "R", "RW", false },
+	{ "R", "RD", false },
+	{ "R", "DW", false },
+	{ "R", "RWD", false },
+
+	{ "RW", "", false },
+	{ "RW", "R", false },
+	{ "RW", "W", false },
+	{ "RW", "D", false },
+	{ "RW", "RW", false },
+	{ "RW", "RD", false },
+	{ "RW", "WD", false },
+	{ "RW", "RWD", false },
+
+	{ "RH", "", true },
+	{ "RH", "R", true },
+	{ "RH", "W", true },
+	{ "RH", "D", true },
+	{ "RH", "RW", true },
+	{ "RH", "RD", true },
+	{ "RH", "WD", true },
+	{ "RH", "RWD", true },
+
+	{ "RHW", "", true },
+	{ "RHW", "R", true },
+	{ "RHW", "W", true },
+	{ "RHW", "D", true },
+	{ "RHW", "RW", true },
+	{ "RHW", "RD", true },
+	{ "RHW", "WD", true },
+	{ "RHW", "RWD", true },
 };
 
-static bool test_one_durable_open_basic2(struct torture_context *tctx,
-					 struct smb2_tree *tree,
-					 const char *fname,
-					 struct smb2_create io,
-					 struct durable_open_vs_lease test)
+static bool test_one_durable_open_open2(struct torture_context *tctx,
+					struct smb2_tree *tree,
+					const char *fname,
+					struct smb2_create io,
+					struct durable_open_vs_lease test)
 {
 	NTSTATUS status;
 	TALLOC_CTX *mem_ctx = talloc_new(tctx);
@@ -221,6 +316,7 @@ static bool test_one_durable_open_basic2(struct torture_context *tctx,
 	smb2_util_unlink(tree, fname);
 
 	io.in.fname = fname;
+	io.in.share_access = map_sharemode(test.share_mode);
 	io.in.oplock_level = SMB2_OPLOCK_LEVEL_LEASE;
 
 	lease = random();
@@ -251,8 +347,8 @@ done:
 	return ret;
 }
 
-bool test_durable_open_basic2(struct torture_context *tctx,
-			      struct smb2_tree *tree)
+bool test_durable_open_open2(struct torture_context *tctx,
+			     struct smb2_tree *tree)
 {
 	TALLOC_CTX *mem_ctx = talloc_new(tctx);
 	struct smb2_create io;
@@ -261,7 +357,7 @@ bool test_durable_open_basic2(struct torture_context *tctx,
 	int i;
 
 	/* Choose a random name in case the state is left a little funky. */
-	snprintf(fname, 256, "durable_open_basic2_%s.dat", generate_random_str(tctx, 8));
+	snprintf(fname, 256, "durable_open_open2_%s.dat", generate_random_str(tctx, 8));
 
 	smb2_util_unlink(tree, fname);
 
@@ -272,9 +368,6 @@ bool test_durable_open_basic2(struct torture_context *tctx,
 	io.in.reserved			= 0x00000000;
 	io.in.desired_access		= SEC_RIGHTS_FILE_ALL;
 	io.in.file_attributes		= FILE_ATTRIBUTE_NORMAL;
-	io.in.share_access		= NTCREATEX_SHARE_ACCESS_READ |
-					  NTCREATEX_SHARE_ACCESS_WRITE |
-					  NTCREATEX_SHARE_ACCESS_DELETE;
 	io.in.create_disposition	= NTCREATEX_DISP_OPEN_IF;
 	io.in.create_options		= NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
 					  NTCREATEX_OPTIONS_ASYNC_ALERT	|
@@ -286,11 +379,11 @@ bool test_durable_open_basic2(struct torture_context *tctx,
 	/* test various oplock levels with durable open */
 
 	for (i = 0; i < NUM_LEASE_OPEN_TESTS; i++) {
-		ret = test_one_durable_open_basic2(tctx,
-						   tree,
-						   fname,
-						   io,
-						   durable_open_vs_lease_table[i]);
+		ret = test_one_durable_open_open2(tctx,
+						  tree,
+						  fname,
+						  io,
+						  durable_open_vs_lease_table[i]);
 		if (ret == false) {
 			goto done;
 		}
@@ -867,8 +960,8 @@ struct torture_suite *torture_smb2_durable_open_init(void)
 	struct torture_suite *suite =
 	    torture_suite_create(talloc_autofree_context(), "durable-open");
 
-	torture_suite_add_1smb2_test(suite, "basic1", test_durable_open_basic1);
-	torture_suite_add_1smb2_test(suite, "basic2", test_durable_open_basic2);
+	torture_suite_add_1smb2_test(suite, "open1", test_durable_open_open1);
+	torture_suite_add_1smb2_test(suite, "open2", test_durable_open_open2);
 	torture_suite_add_2smb2_test(suite, "file-position",
 	    test_durable_open_file_position);
 	torture_suite_add_2smb2_test(suite, "oplock", test_durable_open_oplock);
diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c
index 3d3f17d..4b1352b 100644
--- a/source4/torture/smb2/lease.c
+++ b/source4/torture/smb2/lease.c
@@ -301,6 +301,95 @@ static bool test_lease_upgrade(struct torture_context *tctx,
 	return ret;
 }
 
+struct lease_upgrade_test {
+	const char *initial;
+	const char *upgrade_to;
+	const char *expected;
+};
+
+#define NUM_LEASE_TYPES 5
+#define NUM_UPGRADE_TESTS ( NUM_LEASE_TYPES * NUM_LEASE_TYPES )
+struct lease_upgrade_test lease_upgrade_tests[NUM_UPGRADE_TESTS] = {
+	{ "", "", "" },
+	{ "", "R", "R" },
+	{ "", "RH", "RH" },
+	{ "", "RW", "RW" },
+	{ "", "RWH", "RWH" },
+
+	{ "R", "", "R" },
+	{ "R", "R", "R" },
+	{ "R", "RH", "RH" },
+	{ "R", "RW", "RW" },
+	{ "R", "RWH", "RWH" },
+
+	{ "RH", "", "RH" },
+	{ "RH", "R", "RH" },
+	{ "RH", "RH", "RH" },
+	{ "RH", "RW", "RH" },
+	{ "RH", "RWH", "RWH" },
+
+	{ "RW", "", "RW" },
+	{ "RW", "R", "RW" },
+	{ "RW", "RH", "RW" },
+	{ "RW", "RW", "RW" },
+	{ "RW", "RWH", "RWH" },
+
+	{ "RWH", "", "RWH" },
+	{ "RWH", "R", "RWH" },
+	{ "RWH", "RH", "RWH" },
+	{ "RWH", "RW", "RWH" },
+	{ "RWH", "RWH", "RWH" },
+};
+
+static bool test_lease_upgrade2(struct torture_context *tctx,
+                                struct smb2_tree *tree)
+{
+	TALLOC_CTX *mem_ctx = talloc_new(tctx);
+	struct smb2_handle h, hnew;
+	NTSTATUS status;
+	struct smb2_create io;
+	struct smb2_lease ls;
+	const char *fname = "lease.dat";
+	bool ret = true;
+	int i;
+
+	for (i = 0; i < NUM_UPGRADE_TESTS; i++) {
+		struct lease_upgrade_test t = lease_upgrade_tests[i];
+
+		smb2_util_unlink(tree, fname);
+
+		/* Grab a lease. */
+		smb2_lease_create(&io, &ls, false, fname, LEASE1, lease(t.initial));
+		status = smb2_create(tree, mem_ctx, &io);
+		CHECK_STATUS(status, NT_STATUS_OK);
+		CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+		CHECK_LEASE(&io, t.initial, true, LEASE1);
+		h = io.out.file.handle;
+
+		/* Upgrade. */
+		smb2_lease_create(&io, &ls, false, fname, LEASE1, lease(t.upgrade_to));
+		status = smb2_create(tree, mem_ctx, &io);
+		CHECK_STATUS(status, NT_STATUS_OK);
+		CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
+		CHECK_LEASE(&io, t.expected, true, LEASE1);
+		hnew = io.out.file.handle;
+
+		smb2_util_close(tree, hnew);
+		smb2_util_close(tree, h);
+	}
+
+ done:
+	smb2_util_close(tree, h);
+	smb2_util_close(tree, hnew);
+
+	smb2_util_unlink(tree, fname);
+
+	talloc_free(mem_ctx);
+
+	return ret;
+}
+
+
 #define CHECK_LEASE_BREAK(__lb, __oldstate, __state, __key)		\
 	do {								\
 		CHECK_VAL((__lb)->new_lease_state, lease(__state));	\
@@ -836,6 +925,7 @@ struct torture_suite *torture_smb2_lease_init(void)
 
 	torture_suite_add_1smb2_test(suite, "request", test_lease_request);
 	torture_suite_add_1smb2_test(suite, "upgrade", test_lease_upgrade);
+	torture_suite_add_1smb2_test(suite, "upgrade2", test_lease_upgrade2);
 	torture_suite_add_1smb2_test(suite, "break", test_lease_break);
 	torture_suite_add_1smb2_test(suite, "oplock", test_lease_oplock);
 	torture_suite_add_1smb2_test(suite, "multibreak", test_lease_multibreak);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list