summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-05-28 13:42:29 +1000
committerAndrew Bartlett <abartlet@samba.org>2008-05-28 13:42:29 +1000
commit0f2d8eacf5217b04c88420513a1a1f52e374d659 (patch)
tree0bfa7b93a0ba286db7839279ddb1f1279e658131 /source4/torture
parentbaa2dffdf34c2f3aa150695c60742d616eeb3b09 (diff)
parentbb264d3a1f212be7eca4b38e61db19de8a26e158 (diff)
downloadsamba-0f2d8eacf5217b04c88420513a1a1f52e374d659.tar.gz
samba-0f2d8eacf5217b04c88420513a1a1f52e374d659.tar.bz2
samba-0f2d8eacf5217b04c88420513a1a1f52e374d659.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into 4-0-abartlet
(This used to be commit 3038dd8a4ffae4113f49547a9d4d6b1c8c46397a)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/gentest.c7
-rw-r--r--source4/torture/gentest_smb2.c37
-rw-r--r--source4/torture/smb2/lock.c12
-rw-r--r--source4/torture/smb2/read.c55
4 files changed, 95 insertions, 16 deletions
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index cd33074b4f..068b6bdc2f 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -49,6 +49,7 @@ static struct gentest_options {
const char *seeds_file;
int use_preset_seeds;
int fast_reconnect;
+ int skip_cleanup;
} options;
/* mapping between open handles on the server and local handles */
@@ -1865,6 +1866,11 @@ static bool handler_notify(int instance)
static void wipe_files(void)
{
int i;
+
+ if (options.skip_cleanup) {
+ return;
+ }
+
for (i=0;i<NSERVERS;i++) {
int n = smbcli_deltree(servers[i].cli[0]->tree, "\\gentest");
if (n == -1) {
@@ -2196,6 +2202,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
{"unclist", 0, POPT_ARG_STRING, NULL, OPT_UNCLIST, "unclist", NULL},
{"seedsfile", 0, POPT_ARG_STRING, &options.seeds_file, 0, "seed file", NULL},
{ "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN/]USERNAME[%PASSWORD]" },
+ {"skip-cleanup", 0, POPT_ARG_NONE, &options.skip_cleanup, 0, "don't delete files at start", NULL},
POPT_COMMON_SAMBA
POPT_COMMON_CONNECTION
POPT_COMMON_CREDENTIALS
diff --git a/source4/torture/gentest_smb2.c b/source4/torture/gentest_smb2.c
index 3e705dc60d..60bf6264c2 100644
--- a/source4/torture/gentest_smb2.c
+++ b/source4/torture/gentest_smb2.c
@@ -56,6 +56,7 @@ static struct gentest_options {
int mask_indexing;
int no_eas;
int skip_cleanup;
+ int valid;
} options;
/* mapping between open handles on the server and local handles */
@@ -510,7 +511,7 @@ static uint32_t gen_bits_mask(uint_t mask)
*/
static uint32_t gen_bits_mask2(uint32_t mask1, uint32_t mask2)
{
- if (gen_chance(10)) return gen_bits_mask(mask2);
+ if (!options.valid && gen_chance(10)) return gen_bits_mask(mask2);
return gen_bits_mask(mask1);
}
@@ -519,21 +520,25 @@ static uint32_t gen_bits_mask2(uint32_t mask1, uint32_t mask2)
*/
static uint64_t gen_reserved8(void)
{
+ if (options.valid) return 0;
return gen_bits_mask(0xFF);
}
static uint64_t gen_reserved16(void)
{
+ if (options.valid) return 0;
return gen_bits_mask(0xFFFF);
}
static uint64_t gen_reserved32(void)
{
+ if (options.valid) return 0;
return gen_bits_mask(0xFFFFFFFF);
}
static uint64_t gen_reserved64(void)
{
+ if (options.valid) return 0;
return gen_bits_mask(0xFFFFFFFF) | (((uint64_t)gen_bits_mask(0xFFFFFFFF))<<32);
}
@@ -552,7 +557,7 @@ static bool gen_bool(void)
*/
static uint16_t gen_lock_flags(void)
{
- if (gen_chance(5)) return gen_bits_mask(0xFFFF);
+ if (!options.valid && gen_chance(5)) return gen_bits_mask(0xFFFF);
if (gen_chance(20)) return gen_bits_mask(0x1F);
if (gen_chance(50)) return SMB2_LOCK_FLAG_UNLOCK;
return gen_bits_mask(SMB2_LOCK_FLAG_SHARED |
@@ -573,9 +578,12 @@ static off_t gen_lock_count(void)
*/
static uint32_t gen_access_mask(void)
{
+ uint32_t ret;
if (gen_chance(70)) return SEC_FLAG_MAXIMUM_ALLOWED;
if (gen_chance(70)) return SEC_FILE_ALL;
- return gen_bits_mask(0xFFFFFFFF);
+ ret = gen_bits_mask(0xFFFFFFFF);
+ if (options.valid) ret &= ~SEC_MASK_INVALID;
+ return ret;
}
/*
@@ -583,7 +591,7 @@ static uint32_t gen_access_mask(void)
*/
static uint32_t gen_create_options(void)
{
- if (gen_chance(20)) return gen_bits_mask(0xFFFFFFFF);
+ if (!options.valid && gen_chance(20)) return gen_bits_mask(0xFFFFFFFF);
if (gen_chance(50)) return 0;
return gen_bits_mask(NTCREATEX_OPTIONS_DELETE_ON_CLOSE | NTCREATEX_OPTIONS_DIRECTORY);
}
@@ -594,7 +602,7 @@ static uint32_t gen_create_options(void)
static uint32_t gen_open_disp(void)
{
if (gen_chance(50)) return NTCREATEX_DISP_OPEN_IF;
- if (gen_chance(10)) return gen_bits_mask(0xFFFFFFFF);
+ if (!options.valid && gen_chance(10)) return gen_bits_mask(0xFFFFFFFF);
return gen_int_range(0, 5);
}
@@ -603,7 +611,12 @@ static uint32_t gen_open_disp(void)
*/
static uint32_t gen_attrib(void)
{
- if (gen_chance(20)) return gen_bits_mask(0xFFFFFFFF);
+ uint32_t ret;
+ if (gen_chance(20)) {
+ ret = gen_bits_mask(0xFFFFFFFF);
+ if (options.valid) ret &= FILE_ATTRIBUTE_ALL_MASK;
+ return ret;
+ }
return gen_bits_mask(FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY);
}
@@ -1097,10 +1110,7 @@ static bool handler_create(int instance)
parm[0].in.security_flags = gen_bits_levels(3, 90, 0x0, 70, 0x3, 100, 0xFF);
parm[0].in.oplock_level = gen_bits_levels(3, 90, 0x0, 70, 0x9, 100, 0xFF);
parm[0].in.impersonation_level = gen_bits_levels(3, 90, 0x0, 70, 0x3, 100, 0xFFFFFFFF);
- parm[0].in.create_flags = gen_bits_levels(2, 90, 0x0, 100, 0xFFFFFFFF);
- if (gen_chance(2)) {
- parm[0].in.create_flags |= gen_bits_mask(0xFFFFFFFF);
- }
+ parm[0].in.create_flags = gen_reserved64();
parm[0].in.reserved = gen_reserved64();
parm[0].in.desired_access = gen_access_mask();
parm[0].in.file_attributes = gen_attrib();
@@ -1115,6 +1125,12 @@ static bool handler_create(int instance)
parm[0].in.oplock_level = 0;
}
+ if (options.valid) {
+ parm[0].in.security_flags &= 3;
+ parm[0].in.oplock_level &= 9;
+ parm[0].in.impersonation_level &= 3;
+ }
+
GEN_COPY_PARM;
GEN_CALL(smb2_create(tree, current_op.mem_ctx, &parm[i]));
@@ -1926,6 +1942,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
{"maskindexing", 0, POPT_ARG_NONE, &options.mask_indexing, 0, "mask out the indexed file attrib", NULL},
{"noeas", 0, POPT_ARG_NONE, &options.no_eas, 0, "don't use extended attributes", NULL},
{"skip-cleanup", 0, POPT_ARG_NONE, &options.skip_cleanup, 0, "don't delete files at start", NULL},
+ {"valid", 0, POPT_ARG_NONE, &options.valid, 0, "generate only valid fields", NULL},
POPT_COMMON_SAMBA
POPT_COMMON_CONNECTION
POPT_COMMON_CREDENTIALS
diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c
index 4e21045a33..5a36ac3eae 100644
--- a/source4/torture/smb2/lock.c
+++ b/source4/torture/smb2/lock.c
@@ -252,12 +252,20 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
lck.in.lock_count = 1;
el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
- CHECK_STATUS(status, NT_STATUS_OK);
+ if (torture_setting_bool(torture, "windows", false)) {
+ CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+ } else {
+ CHECK_STATUS(status, NT_STATUS_OK);
+ }
lck.in.lock_count = 1;
el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
- CHECK_STATUS(status, NT_STATUS_OK);
+ if (torture_setting_bool(torture, "windows", false)) {
+ CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+ } else {
+ CHECK_STATUS(status, NT_STATUS_OK);
+ }
lck.in.lock_count = 1;
el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
diff --git a/source4/torture/smb2/read.c b/source4/torture/smb2/read.c
index 3e1d077b7d..62240f35ba 100644
--- a/source4/torture/smb2/read.c
+++ b/source4/torture/smb2/read.c
@@ -38,13 +38,13 @@
#define CHECK_VALUE(v, correct) do { \
if ((v) != (correct)) { \
- printf("(%s) Incorrect value %s=%d - should be %d\n", \
- __location__, #v, v, correct); \
+ printf("(%s) Incorrect value %s=%u - should be %u\n", \
+ __location__, #v, (unsigned)v, (unsigned)correct); \
ret = false; \
goto done; \
}} while (0)
-static bool test_read(struct torture_context *torture, struct smb2_tree *tree)
+static bool test_read_eof(struct torture_context *torture, struct smb2_tree *tree)
{
bool ret = true;
NTSTATUS status;
@@ -126,13 +126,60 @@ done:
return ret;
}
+
+static bool test_read_position(struct torture_context *torture, struct smb2_tree *tree)
+{
+ bool ret = true;
+ NTSTATUS status;
+ struct smb2_handle h;
+ uint8_t buf[70000];
+ struct smb2_read rd;
+ TALLOC_CTX *tmp_ctx = talloc_new(tree);
+ union smb_fileinfo info;
+
+ ZERO_STRUCT(buf);
+
+ status = torture_smb2_testfile(tree, "lock1.txt", &h);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ ZERO_STRUCT(rd);
+ rd.in.file.handle = h;
+ rd.in.length = 10;
+ rd.in.offset = 0;
+ rd.in.min_count = 1;
+
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VALUE(rd.out.data.length, 10);
+
+ info.generic.level = RAW_FILEINFO_SMB2_ALL_INFORMATION;
+ info.generic.in.file.handle = h;
+
+ status = smb2_getinfo_file(tree, tmp_ctx, &info);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ if (torture_setting_bool(torture, "windows", false)) {
+ CHECK_VALUE(info.all_info2.out.position, 0);
+ } else {
+ CHECK_VALUE(info.all_info2.out.position, 10);
+ }
+
+
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
/* basic testing of SMB2 read
*/
struct torture_suite *torture_smb2_read_init(void)
{
struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "READ");
- torture_suite_add_1smb2_test(suite, "READ", test_read);
+ torture_suite_add_1smb2_test(suite, "EOF", test_read_eof);
+ torture_suite_add_1smb2_test(suite, "POSITION", test_read_position);
suite->description = talloc_strdup(suite, "SMB2-READ tests");