* This test tests durable open with all possible oplock types.
*/
-struct persistent_open_vs_oplock {
+struct oplock_open_input {
const char *level;
const char *share_mode;
- bool durable;
- bool persistent;
};
-
#define NUM_OPLOCK_TYPES 4
#define NUM_SHARE_MODES 8
#define NUM_OPLOCK_OPEN_TESTS ( NUM_OPLOCK_TYPES * NUM_SHARE_MODES )
-struct persistent_open_vs_oplock persistent_open_vs_oplock_table[NUM_OPLOCK_OPEN_TESTS] =
-{
- { "", "", true, true },
- { "", "R", true, true },
- { "", "W", true, true },
- { "", "D", true, true },
- { "", "RD", true, true },
- { "", "RW", true, true },
- { "", "WD", true, true },
- { "", "RWD", true, true },
-
- { "s", "", true, true },
- { "s", "R", true, true },
- { "s", "W", true, true },
- { "s", "D", true, true },
- { "s", "RD", true, true },
- { "s", "RW", true, true },
- { "s", "WD", true, true },
- { "s", "RWD", true, true },
- { "x", "", true, true },
- { "x", "R", true, true },
- { "x", "W", true, true },
- { "x", "D", true, true },
- { "x", "RD", true, true },
- { "x", "RW", true, true },
- { "x", "WD", true, true },
- { "x", "RWD", true, true },
-
- { "b", "", true, true },
- { "b", "R", true, true },
- { "b", "W", true, true },
- { "b", "D", true, true },
- { "b", "RD", true, true },
- { "b", "RW", true, true },
- { "b", "WD", true, true },
- { "b", "RWD", true, true },
+struct oplock_open_input open_oplock_input_table[NUM_OPLOCK_OPEN_TESTS] =
+{
+ { "", "" },
+ { "", "R" },
+ { "", "W" },
+ { "", "D" },
+ { "", "RD" },
+ { "", "RW" },
+ { "", "WD" },
+ { "", "RWD" },
+
+ { "s", "" },
+ { "s", "R" },
+ { "s", "W" },
+ { "s", "D" },
+ { "s", "RD" },
+ { "s", "RW" },
+ { "s", "WD" },
+ { "s", "RWD" },
+
+ { "x", "" },
+ { "x", "R" },
+ { "x", "W" },
+ { "x", "D" },
+ { "x", "RD" },
+ { "x", "RW" },
+ { "x", "WD" },
+ { "x", "RWD" },
+
+ { "b", "" },
+ { "b", "R" },
+ { "b", "W" },
+ { "b", "D" },
+ { "b", "RD" },
+ { "b", "RW" },
+ { "b", "WD" },
+ { "b", "RWD" },
};
static bool test_one_persistent_open_oplock(struct torture_context *tctx,
struct smb2_tree *tree,
const char *fname,
- struct persistent_open_vs_oplock test)
+ struct oplock_open_input input,
+ bool expected_durable_v2,
+ bool expected_persistent)
{
NTSTATUS status;
TALLOC_CTX *mem_ctx = talloc_new(tctx);
smb2_util_unlink(tree, fname);
smb2_oplock_create_share(&io, fname,
- smb2_util_share_access(test.share_mode),
- smb2_util_oplock_level(test.level));
+ smb2_util_share_access(input.share_mode),
+ smb2_util_oplock_level(input.level));
io.in.durable_open = false;
io.in.durable_open_v2 = true;
io.in.persistent_open = true;
h = &_h;
CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
CHECK_VAL(io.out.durable_open, false);
- CHECK_VAL(io.out.durable_open_v2, test.durable);
- CHECK_VAL(io.out.persistent_open, test.persistent);
- CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level(test.level));
+ CHECK_VAL(io.out.durable_open_v2, expected_durable_v2);
+ CHECK_VAL(io.out.persistent_open, expected_persistent);
+ CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level(input.level));
done:
if (h != NULL) {
char fname[256];
bool ret = true;
int i;
- bool share_is_ca;
+ bool share_is_ca = false;
/* Choose a random name in case the state is left a little funky. */
snprintf(fname, 256, "persistent_open_oplock_%s.dat", generate_random_str(tctx, 8));
ret = test_one_persistent_open_oplock(tctx,
tree,
fname,
- persistent_open_vs_oplock_table[i]);
+ open_oplock_input_table[i],
+ share_is_ca, /* expected durable v2 */
+ share_is_ca /* expexted persistent */);
if (ret == false) {
goto done;
}
* This test tests persistent open with all valid lease types.
*/
-struct persistent_open_vs_lease {
+struct open_lease_input {
const char *type;
const char *share_mode;
- bool durable;
- bool persistent;
};
#define NUM_LEASE_TYPES 5
#define NUM_LEASE_OPEN_TESTS ( NUM_LEASE_TYPES * NUM_SHARE_MODES )
-struct persistent_open_vs_lease persistent_open_vs_lease_table[NUM_LEASE_OPEN_TESTS] =
-{
- { "", "", true, true },
- { "", "R", true, true },
- { "", "W", true, true },
- { "", "D", true, true },
- { "", "RW", true, true },
- { "", "RD", true, true },
- { "", "WD", true, true },
- { "", "RWD", true, true },
-
- { "R", "", true, true },
- { "R", "R", true, true },
- { "R", "W", true, true },
- { "R", "D", true, true },
- { "R", "RW", true, true },
- { "R", "RD", true, true },
- { "R", "DW", true, true },
- { "R", "RWD", true, true },
-
- { "RW", "", true, true },
- { "RW", "R", true, true },
- { "RW", "W", true, true },
- { "RW", "D", true, true },
- { "RW", "RW", true, true },
- { "RW", "RD", true, true },
- { "RW", "WD", true, true },
- { "RW", "RWD", true, true },
-
- { "RH", "", true, true },
- { "RH", "R", true, true },
- { "RH", "W", true, true },
- { "RH", "D", true, true },
- { "RH", "RW", true, true },
- { "RH", "RD", true, true },
- { "RH", "WD", true, true },
- { "RH", "RWD", true, true },
- { "RHW", "", true, true },
- { "RHW", "R", true, true },
- { "RHW", "W", true, true },
- { "RHW", "D", true, true },
- { "RHW", "RW", true, true },
- { "RHW", "RD", true, true },
- { "RHW", "WD", true, true },
- { "RHW", "RWD", true, true },
+struct open_lease_input open_lease_input_table[NUM_LEASE_OPEN_TESTS] =
+{
+ { "", "" },
+ { "", "R" },
+ { "", "W" },
+ { "", "D" },
+ { "", "RW" },
+ { "", "RD" },
+ { "", "WD" },
+ { "", "RWD" },
+
+ { "R", "" },
+ { "R", "R" },
+ { "R", "W" },
+ { "R", "D" },
+ { "R", "RW" },
+ { "R", "RD" },
+ { "R", "DW" },
+ { "R", "RWD" },
+
+ { "RW", "" },
+ { "RW", "R" },
+ { "RW", "W" },
+ { "RW", "D" },
+ { "RW", "RW" },
+ { "RW", "RD" },
+ { "RW", "WD" },
+ { "RW", "RWD" },
+
+ { "RH", "" },
+ { "RH", "R" },
+ { "RH", "W" },
+ { "RH", "D" },
+ { "RH", "RW" },
+ { "RH", "RD" },
+ { "RH", "WD" },
+ { "RH", "RWD" },
+
+ { "RHW", "" },
+ { "RHW", "R" },
+ { "RHW", "W" },
+ { "RHW", "D" },
+ { "RHW", "RW" },
+ { "RHW", "RD" },
+ { "RHW", "WD" },
+ { "RHW", "RWD" },
};
static bool test_one_persistent_open_lease(struct torture_context *tctx,
struct smb2_tree *tree,
const char *fname,
- struct persistent_open_vs_lease test)
+ struct open_lease_input input,
+ bool expected_durable_v2,
+ bool expected_persistent)
{
NTSTATUS status;
TALLOC_CTX *mem_ctx = talloc_new(tctx);
lease = random();
smb2_lease_create_share(&io, &ls, false /* dir */, fname,
- smb2_util_share_access(test.share_mode),
+ smb2_util_share_access(input.share_mode),
lease,
- smb2_util_lease_state(test.type));
+ smb2_util_lease_state(input.type));
io.in.durable_open = false;
io.in.durable_open_v2 = true;
io.in.persistent_open = true;
h = &_h;
CHECK_CREATED(&io, CREATED, FILE_ATTRIBUTE_ARCHIVE);
CHECK_VAL(io.out.durable_open, false);
- CHECK_VAL(io.out.durable_open_v2, test.durable);
- CHECK_VAL(io.out.persistent_open, test.persistent);
+ CHECK_VAL(io.out.durable_open_v2, expected_durable_v2);
+ CHECK_VAL(io.out.persistent_open, expected_persistent);
CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_LEASE);
CHECK_VAL(io.out.lease_response.lease_key.data[0], lease);
CHECK_VAL(io.out.lease_response.lease_key.data[1], ~lease);
CHECK_VAL(io.out.lease_response.lease_state,
- smb2_util_lease_state(test.type));
+ smb2_util_lease_state(input.type));
done:
if (h != NULL) {
smb2_util_close(tree, *h);
bool ret = true;
int i;
uint32_t caps;
+ bool share_is_ca;
+ bool share_is_scaleout;
+ bool expected_persistent;
+ bool expected_durable_v2;
caps = smb2cli_conn_server_capabilities(tree->session->transport->conn);
if (!(caps & SMB2_CAP_LEASING)) {
smb2_util_unlink(tree, fname);
+ share_is_ca = tree->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY;
+ share_is_scaleout = tree->capabilities & SMB2_SHARE_CAP_SCALEOUT;
+
+ expected_persistent = share_is_ca;
+ expected_durable_v2 = !share_is_scaleout;
/* test various oplock levels with persistent open */
ret = test_one_persistent_open_lease(tctx,
tree,
fname,
- persistent_open_vs_lease_table[i]);
+ open_lease_input_table[i],
+ share_is_ca, /* expected durable v2 */
+ share_is_ca /* expected persistent */);
if (ret == false) {
goto done;
}