gentest: Fix a warning.
[ira/wip.git] / source / torture / gentest.c
index 79eb7eb0e900b1c44c75117ab9b31a9b268c407e..d50393baf0e884b6a9f3b91e6c20516ef7663639 100644 (file)
@@ -25,6 +25,7 @@
 #include "libcli/raw/libcliraw.h"
 #include "librpc/gen_ndr/security.h"
 #include "auth/credentials/credentials.h"
+#include "libcli/resolve/resolve.h"
 #include "auth/gensec/gensec.h"
 #include "param/param.h"
 #include "dynconfig.h"
@@ -152,7 +153,7 @@ static bool connect_servers_fast(void)
 /***************************************************** 
 connect to the servers
 *******************************************************/
-static bool connect_servers(void)
+static bool connect_servers(struct loadparm_context *lp_ctx)
 {
        int i, j;
 
@@ -175,6 +176,7 @@ static bool connect_servers(void)
 
        for (i=0;i<NSERVERS;i++) {
                for (j=0;j<NINSTANCES;j++) {
+                       struct smbcli_options smb_options;
                        NTSTATUS status;
                        printf("Connecting to \\\\%s\\%s as %s - instance %d\n",
                               servers[i].server_name, servers[i].share_name, 
@@ -183,10 +185,14 @@ static bool connect_servers(void)
                        cli_credentials_set_workstation(servers[i].credentials, 
                                                        "gentest", CRED_SPECIFIED);
 
+                       lp_smbcli_options(lp_ctx, &smb_options);
                        status = smbcli_full_connection(NULL, &servers[i].cli[j],
                                                        servers[i].server_name, 
+                                                       lp_smb_ports(lp_ctx),
                                                        servers[i].share_name, NULL, 
-                                                       servers[i].credentials, NULL);
+                                                       servers[i].credentials, 
+                                                       lp_resolve_context(lp_ctx), 
+                                                       NULL, &smb_options);
                        if (!NT_STATUS_IS_OK(status)) {
                                printf("Failed to connect to \\\\%s\\%s - %s\n",
                                       servers[i].server_name, servers[i].share_name,
@@ -1631,7 +1637,8 @@ static bool cmp_fileinfo(int instance,
        case RAW_FILEINFO_UNIX_BASIC:
        case RAW_FILEINFO_UNIX_LINK:
        case RAW_FILEINFO_SMB2_ALL_EAS:
-       case RAW_FILEINFO_SMB2_ALL_INFORMATION: 
+       case RAW_FILEINFO_SMB2_ALL_INFORMATION:
+       case RAW_FILEINFO_UNIX_INFO2:
                break;
        }
 
@@ -1769,6 +1776,7 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
        case RAW_SFILEINFO_1032:
        case RAW_SFILEINFO_1039:
        case RAW_SFILEINFO_1040:
+       case RAW_SFILEINFO_UNIX_INFO2:
                /* Untested */
                break;
        }
@@ -1927,11 +1935,11 @@ static struct {
   run the test with the current set of op_parms parameters
   return the number of operations that completed successfully
 */
-static int run_test(void)
+static int run_test(struct loadparm_context *lp_ctx)
 {
        int op, i;
 
-       if (!connect_servers()) {
+       if (!connect_servers(lp_ctx)) {
                printf("Failed to connect to servers\n");
                exit(1);
        }
@@ -2008,7 +2016,7 @@ static int run_test(void)
    perform a backtracking analysis of the minimal set of operations
    to generate an error
 */
-static void backtrack_analyze(void)
+static void backtrack_analyze(struct loadparm_context *lp_ctx)
 {
        int chunk, ret;
 
@@ -2029,7 +2037,7 @@ static void backtrack_analyze(void)
                        }
                        printf("Testing %d ops with %d-%d disabled\n", 
                               options.numops, base, max-1);
-                       ret = run_test();
+                       ret = run_test(lp_ctx);
                        printf("Completed %d of %d ops\n", ret, options.numops);
                        for (i=base;i<max; i++) {
                                op_parms[i].disabled = false;
@@ -2061,7 +2069,7 @@ static void backtrack_analyze(void)
        } while (chunk > 0);
 
        printf("Reduced to %d ops\n", options.numops);
-       ret = run_test();
+       ret = run_test(lp_ctx);
        if (ret != options.numops - 1) {
                printf("Inconsistent result? ret=%d numops=%d\n", ret, options.numops);
        }
@@ -2070,7 +2078,7 @@ static void backtrack_analyze(void)
 /* 
    start the main gentest process
 */
-static bool start_gentest(void)
+static bool start_gentest(struct loadparm_context *lp_ctx)
 {
        int op;
        int ret;
@@ -2106,15 +2114,15 @@ static bool start_gentest(void)
                }
        }
 
-       ret = run_test();
+       ret = run_test(lp_ctx);
 
        if (ret != options.numops && options.analyze) {
                options.numops = ret+1;
-               backtrack_analyze();
+               backtrack_analyze(lp_ctx);
        } else if (options.analyze_always) {
-               backtrack_analyze();
+               backtrack_analyze(lp_ctx);
        } else if (options.analyze_continuous) {
-               while (run_test() == options.numops) ;
+               while (run_test(lp_ctx) == options.numops) ;
        }
 
        return ret == options.numops;
@@ -2172,6 +2180,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
        int opt;
        int i, username_count=0;
        bool ret;
+       struct loadparm_context *lp_ctx;
 
        setlinebuf(stdout);
 
@@ -2196,12 +2205,13 @@ static bool split_unc_name(const char *unc, char **server, char **share)
        argc -= NSERVERS;
        argv += NSERVERS;
 
-       lp_load(dyn_CONFIGFILE);
+       lp_ctx = loadparm_init(talloc_autofree_context());
+       lp_load(lp_ctx, dyn_CONFIGFILE);
 
        servers[0].credentials = cli_credentials_init(talloc_autofree_context());
        servers[1].credentials = cli_credentials_init(talloc_autofree_context());
-       cli_credentials_guess(servers[0].credentials);
-       cli_credentials_guess(servers[1].credentials);
+       cli_credentials_guess(servers[0].credentials, lp_ctx);
+       cli_credentials_guess(servers[1].credentials, lp_ctx);
 
        options.seed = time(NULL);
        options.numops = 1000;
@@ -2265,7 +2275,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
                }
        }
 
-       gensec_init();
+       gensec_init(lp_ctx);
 
        if (username_count == 0) {
                usage();
@@ -2277,7 +2287,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
 
        printf("seed=%u\n", options.seed);
 
-       ret = start_gentest();
+       ret = start_gentest(lp_ctx);
 
        if (ret) {
                printf("gentest completed - no errors\n");