s3:param: Migrate test_lp_load to new cmdline option parser
authorAndreas Schneider <asn@samba.org>
Fri, 8 Jan 2021 07:27:19 +0000 (08:27 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 20 May 2021 02:58:36 +0000 (02:58 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/param/test_lp_load.c
source3/param/wscript_build

index 2a50723b643eda0895e075fcd002ba2c6df3f045..b25a54798f8b353e1abb3aced8b92fd9c59407d2 100644 (file)
  */
 
 #include "includes.h"
-#include "popt_common.h"
+#include "lib/cmdline/cmdline.h"
 
 int main(int argc, const char **argv)
 {
-       const char *config_file = get_dyn_CONFIGFILE();
+       const char *config_file = NULL;
        int ret = 0;
        poptContext pc;
        char *count_str = NULL;
        int i, count = 1;
+       bool ok;
 
        struct poptOption long_options[] = {
                POPT_AUTOHELP
@@ -38,25 +39,43 @@ int main(int argc, const char **argv)
                        .val        = 1,
                        .descrip    = "Load config <count> number of times"
                },
-               POPT_COMMON_DEBUGLEVEL
+               POPT_COMMON_DEBUG_ONLY
+               POPT_COMMON_VERSION
                POPT_TABLEEND
        };
 
        TALLOC_CTX *frame = talloc_stackframe();
 
        smb_init_locale();
+
+       ok = samba_cmdline_init(frame,
+                               SAMBA_CMDLINE_CONFIG_NONE,
+                               false /* require_smbconf */);
+       if (!ok) {
+               DBG_ERR("Failed to init cmdline parser!\n");
+               TALLOC_FREE(frame);
+               exit(ENOMEM);
+       }
        lp_set_cmdline("log level", "0");
 
-       pc = poptGetContext(NULL, argc, argv, long_options,
-                           POPT_CONTEXT_KEEP_FIRST);
+       pc = samba_popt_get_context(getprogname(),
+                                   argc,
+                                   argv,
+                                   long_options,
+                                   0);
+       if (pc == NULL) {
+               DBG_ERR("Failed to setup popt context!\n");
+               TALLOC_FREE(frame);
+               exit(1);
+       }
        poptSetOtherOptionHelp(pc, "[OPTION...] <config-file>");
 
        while(poptGetNextOpt(pc) != -1);
 
-       setup_logging(poptGetArg(pc), DEBUG_STDERR);
-
        if (poptPeekArg(pc)) {
                config_file = poptGetArg(pc);
+       } else {
+               config_file = get_dyn_CONFIGFILE();
        }
 
        poptFreeContext(pc);
index 22faf5cdcce5c57d1a75dda73a46aab6ac3e5233..c14cf0df651725c699626b30f7d94b10c7f075c9 100644 (file)
@@ -40,5 +40,5 @@ bld.SAMBA3_BINARY('test_lp_load',
                  deps='''
                  talloc
                  smbconf
-                 popt_samba3''',
+                 CMDLINE_S3''',
                  install=False)