From: Andreas Schneider Date: Thu, 17 Dec 2020 15:25:08 +0000 (+0100) Subject: s4:torture: Migrate gentest to new cmdline option parser X-Git-Tag: tevent-0.11.0~355 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b4c1f438455c91f19957ab9b69c32947c55bdf79;p=thirdparty%2Fsamba.git s4:torture: Migrate gentest to new cmdline option parser Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index 76d0f9ca424..bc336aac052 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "lib/cmdline/popt_common.h" +#include "lib/cmdline/cmdline.h" #include "lib/events/events.h" #include "system/time.h" #include "system/filesys.h" @@ -3323,9 +3323,11 @@ 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; + bool ok; memset(&bad_smb2_handle, 0xFF, sizeof(bad_smb2_handle)); @@ -3341,12 +3343,29 @@ int main(int argc, const char *argv[]) exit(1); } - pc = poptGetContext("gentest", 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(getprogname(), + 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, " "); - lp_ctx = cmdline_lp_ctx; + lp_ctx = samba_cmdline_get_lp_ctx(); servers[0].credentials = cli_credentials_init(mem_ctx); servers[1].credentials = cli_credentials_init(mem_ctx); cli_credentials_guess(servers[0].credentials, lp_ctx); @@ -3355,7 +3374,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].credentials, diff --git a/source4/torture/wscript_build b/source4/torture/wscript_build index 4b3309a9ab4..7f315ef3030 100644 --- a/source4/torture/wscript_build +++ b/source4/torture/wscript_build @@ -331,7 +331,7 @@ bld.SAMBA_BINARY('smbtorture', bld.SAMBA_BINARY('gentest', source='gentest.c', manpages='man/gentest.1', - deps='samba-hostconfig samba-util popt POPT_SAMBA POPT_CREDENTIALS LIBCLI_SMB smbclient-raw param_options' + deps='samba-hostconfig samba-util popt CMDLINE_S4 LIBCLI_SMB smbclient-raw param_options' )