]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4/torture: change shares in used torture_suite_add_2ns_smb2_test()
authorRalph Boehme <slow@samba.org>
Sun, 11 Dec 2016 18:02:37 +0000 (19:02 +0100)
committerUri Simchoni <uri@samba.org>
Wed, 1 Mar 2017 23:32:23 +0000 (00:32 +0100)
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>
source4/torture/vfs/vfs.c

index 8b443fbecc9b94cd6a2dd26165f76c266f097091..a4f81256b09926ea176b68e0079753961c2016d6 100644 (file)
@@ -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,