diff options
author | Ralph Boehme <slow@samba.org> | 2016-12-11 19:02:37 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2017-03-07 08:28:15 +0100 |
commit | af6a0f80cdcfb9b4f193f5874b095eaf3e0071c0 (patch) | |
tree | d25fefdf86adc15489ae84fe4db2c1f852777f34 | |
parent | 5b18aeaab9c7374b59b9db2a88c33343a82c9ba5 (diff) | |
download | samba-af6a0f80cdcfb9b4f193f5874b095eaf3e0071c0.tar.gz |
s4/torture: change shares in used torture_suite_add_2ns_smb2_test()
torture_suite_add_2ns_smb2_test wan't used, change it to use the default
share as share 1 and a second share taken from torture option
"torture:share2".
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
(cherry picked from commit 08dc5b4673a955f365095824275e67b2ea8fc31e)
-rw-r--r-- | source4/torture/vfs/vfs.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/source4/torture/vfs/vfs.c b/source4/torture/vfs/vfs.c index 8b443fbecc9..a4f81256b09 100644 --- a/source4/torture/vfs/vfs.c +++ b/source4/torture/vfs/vfs.c @@ -38,42 +38,44 @@ static bool wrap_2ns_smb2_test(struct torture_context *torture_ctx, struct torture_test *test) { bool (*fn) (struct torture_context *, struct smb2_tree *, struct smb2_tree *); - bool ret = false; + bool ok; - struct smb2_tree *tree1; - struct smb2_tree *tree2; + struct smb2_tree *tree1 = NULL; + struct smb2_tree *tree2 = NULL; TALLOC_CTX *mem_ctx = talloc_new(torture_ctx); - if (!torture_smb2_con_sopt(torture_ctx, "share1", &tree1)) { + if (!torture_smb2_connection(torture_ctx, &tree1)) { torture_fail(torture_ctx, - "Establishing SMB2 connection failed\n"); - goto done; + "Establishing SMB2 connection failed\n"); + return false; } + /* + * This is a trick: + * The test might close the connection. If we steal the tree context + * before that and free the parent instead of tree directly, we avoid + * a double free error. + */ talloc_steal(mem_ctx, tree1); - if (!torture_smb2_con_sopt(torture_ctx, "share2", &tree2)) { - torture_fail(torture_ctx, - "Establishing SMB2 connection failed\n"); - goto done; + ok = torture_smb2_con_sopt(torture_ctx, "share2", &tree2); + if (ok) { + talloc_steal(mem_ctx, tree2); } - talloc_steal(mem_ctx, tree2); - fn = test->fn; - ret = fn(torture_ctx, tree1, tree2); + ok = fn(torture_ctx, tree1, tree2); -done: /* the test may already have closed some of the connections */ talloc_free(mem_ctx); - return ret; + return ok; } /* - * Run a test with 2 connected trees, Share names to connect are taken - * from option strings "torture:share1" and "torture:share2" + * Run a test with 2 connected trees, the default share and another + * taken from option strings "torture:share2" */ struct torture_test *torture_suite_add_2ns_smb2_test(struct torture_suite *suite, const char *name, |