]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:torture: Migrate locktest to new cmdline option parser
authorAndreas Schneider <asn@samba.org>
Thu, 17 Dec 2020 16:05:51 +0000 (17:05 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 16 Jun 2021 00:34:38 +0000 (00:34 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/torture/locktest.c
source4/torture/wscript_build

index a46c5aeb39f1e2baf0017b3fd5e6cf2b7a3335ca..6124f36965b8102c59a86b2bd3031108c730b015 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/cmdline/popt_common.h"
+#include "lib/cmdline/cmdline.h"
 #include "lib/events/events.h"
 #include "system/filesys.h"
 #include "system/time.h"
@@ -583,10 +583,12 @@ int main(int argc, const char *argv[])
                POPT_COMMON_CONNECTION
                POPT_COMMON_CREDENTIALS
                POPT_COMMON_VERSION
-               {0}
+               POPT_LEGACY_S4
+               POPT_TABLEEND
        };
        TALLOC_CTX *mem_ctx = NULL;
        int ret = -1;
+       bool ok;
 
        setlinebuf(stdout);
        seed = time(NULL);
@@ -597,12 +599,31 @@ int main(int argc, const char *argv[])
                exit(1);
        }
 
-       pc = poptGetContext("locktest", argc, argv, long_options,
-                           POPT_CONTEXT_KEEP_FIRST);
+       ok = samba_cmdline_init(mem_ctx,
+                               SAMBA_CMDLINE_CONFIG_CLIENT,
+                               false /* require_smbconf */);
+       if (!ok) {
+               DBG_ERR("Failed to init cmdline parser!\n");
+               TALLOC_FREE(mem_ctx);
+               exit(1);
+       }
+
+
+       pc = samba_popt_get_context("locktest",
+                                   argc,
+                                   argv,
+                                   long_options,
+                                   POPT_CONTEXT_KEEP_FIRST);
+       if (pc == NULL) {
+               DBG_ERR("Failed to setup popt context!\n");
+               TALLOC_FREE(mem_ctx);
+               exit(1);
+       }
 
        poptSetOtherOptionHelp(pc, "<unc1> <unc2>");
 
-       lp_ctx = cmdline_lp_ctx;
+       lp_ctx = samba_cmdline_get_lp_ctx();
+
        servers[0] = cli_credentials_init(mem_ctx);
        servers[1] = cli_credentials_init(mem_ctx);
        cli_credentials_guess(servers[0], lp_ctx);
@@ -611,7 +632,7 @@ int main(int argc, const char *argv[])
        while((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt) {
                case OPT_UNCLIST:
-                       lpcfg_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
+                       lpcfg_set_cmdline(lp_ctx, "torture:unclist", poptGetOptArg(pc));
                        break;
                case OPT_USER1:
                        cli_credentials_parse_string(servers[0],
@@ -649,8 +670,6 @@ int main(int argc, const char *argv[])
                all_string_sub(share[server],"/","\\",0);
        }
 
-       lp_ctx = cmdline_lp_ctx;
-
        if (username_count == 0) {
                usage(pc);
                poptFreeContext(pc);
index 7f315ef3030fd49c896564279d0c7cdae18de740..2f1a1cfa7b5914d62a03fe079f4b0283585018cf 100644 (file)
@@ -349,7 +349,7 @@ bld.SAMBA_BINARY('locktest',
        #cflags='--coverage',
        # GCOV='1',
        manpages='man/locktest.1',
-       deps='popt POPT_SAMBA POPT_CREDENTIALS samba-util LIBCLI_SMB samba-hostconfig param_options',
+       deps='popt CMDLINE_S4 samba-util LIBCLI_SMB samba-hostconfig param_options',
        )
 
 bld.SAMBA_MODULE('TORTURE_DSDB',