s4/torture: make --unclist active with smb2 testcases
authorPeter Somogyi <psomogyi@hu.ibm.com>
Tue, 29 Aug 2017 09:15:11 +0000 (11:15 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 29 Aug 2017 22:16:51 +0000 (00:16 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12985

Signed-off-by: Peter Somogyi <psomogyi@hu.ibm.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Aug 30 00:16:51 CEST 2017 on sn-devel-144

lib/torture/torture.h
source4/torture/smb2/util.c

index 6b373a9ca153ec71221f555f9d63f2aca41bd6f5..c0fbdb9081d04ccfbd5ef47aef5bbf0c1ae9dd37 100644 (file)
@@ -101,6 +101,8 @@ struct torture_context
 
        /** Loadparm context (will go away in favor of torture_setting_ at some point) */
        struct loadparm_context *lp_ctx;
+
+       int conn_index;
 };
 
 struct torture_results
index 52a63dd962ae96da71ed40aadeb68b1fa31bc778..65090b0e8b75f9ab6c57c00e2c5d9aa7de8601ed 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "torture/torture.h"
 #include "torture/smb2/proto.h"
+#include "source4/torture/util.h"
 
 
 /*
@@ -385,6 +386,29 @@ bool torture_smb2_connection_ext(struct torture_context *tctx,
        NTSTATUS status;
        const char *host = torture_setting_string(tctx, "host", NULL);
        const char *share = torture_setting_string(tctx, "share", NULL);
+       const char *p = torture_setting_string(tctx, "unclist", NULL);
+       TALLOC_CTX *mem_ctx = NULL;
+       bool ok;
+
+       if (p != NULL) {
+               char *host2 = NULL;
+               char *share2 = NULL;
+
+               mem_ctx = talloc_new(tctx);
+               if (mem_ctx == NULL) {
+                       return false;
+               }
+
+               ok = torture_get_conn_index(tctx->conn_index++, mem_ctx, tctx,
+                                           &host2, &share2);
+               if (!ok) {
+                       TALLOC_FREE(mem_ctx);
+                       return false;
+               }
+
+               host = host2;
+               share = share2;
+       }
 
        status = smb2_connect_ext(tctx,
                                  host,
@@ -402,8 +426,11 @@ bool torture_smb2_connection_ext(struct torture_context *tctx,
        if (!NT_STATUS_IS_OK(status)) {
                torture_comment(tctx, "Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
                       host, share, nt_errstr(status));
+               TALLOC_FREE(mem_ctx);
                return false;
        }
+
+       TALLOC_FREE(mem_ctx);
        return true;
 }