From: Ralph Boehme Date: Sun, 11 Dec 2016 18:02:37 +0000 (+0100) Subject: s4/torture: change shares in used torture_suite_add_2ns_smb2_test() X-Git-Tag: tdb-1.3.13~692 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08dc5b4673a955f365095824275e67b2ea8fc31e;p=thirdparty%2Fsamba.git 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 Reviewed-by: Uri Simchoni --- 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,