summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2020-12-17 17:05:51 +0100
committerAndrew Bartlett <abartlet@samba.org>2021-06-16 00:34:38 +0000
commitcaafb3cd4a229974a88d1b355890e31b65e15e8d (patch)
tree54f658a50d1b5f9cd1c45f979e08258442f2162c /source4/torture
parentc0034d309e18a888a93f0c42dcd0d95c35ce8bad (diff)
downloadsamba-caafb3cd4a229974a88d1b355890e31b65e15e8d.tar.gz
s4:torture: Migrate locktest to new cmdline option parser
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/locktest.c35
-rw-r--r--source4/torture/wscript_build2
2 files changed, 28 insertions, 9 deletions
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index a46c5aeb39f..6124f36965b 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -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);
diff --git a/source4/torture/wscript_build b/source4/torture/wscript_build
index 7f315ef3030..2f1a1cfa7b5 100644
--- a/source4/torture/wscript_build
+++ b/source4/torture/wscript_build
@@ -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',