s3:rpc_server: Migrate test_mdsparser_es to new cmdline option parser
authorAndreas Schneider <asn@samba.org>
Wed, 13 Jan 2021 12:53:55 +0000 (13:53 +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/rpc_server/mdssvc/test_mdsparser_es.c
source3/wscript_build

index 23b93dfa660722fe3117e3be02f1a7bf630f417d..b5cb86db9a730c4dc24d5995c56818743e030510 100644 (file)
@@ -21,8 +21,7 @@
 #include <cmocka.h>
 #include <jansson.h>
 #include <talloc.h>
-#include "popt.h"
-#include "popt_common_cmdline.h"
+#include "lib/cmdline/cmdline.h"
 #include "libcli/util/ntstatus.h"
 #include "lib/util/samba_util.h"
 #include "lib/torture/torture.h"
@@ -199,7 +198,6 @@ static void test_mdsparser_es(void **state)
 
 int main(int argc, const char *argv[])
 {
-       const char **argv_const = discard_const_p(const char *, argv);
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(test_mdsparser_es),
        };
@@ -210,12 +208,31 @@ int main(int argc, const char *argv[])
        };
        poptContext pc;
        int opt;
+       bool ok;
+       TALLOC_CTX *frame = talloc_stackframe();
 
        smb_init_locale();
-       setup_logging(argv[0], DEBUG_STDERR);
+
+       ok = samba_cmdline_init(frame,
+                               SAMBA_CMDLINE_CONFIG_CLIENT,
+                               false /* require_smbconf */);
+       if (!ok) {
+               DBG_ERR("Failed to init cmdline parser!\n");
+               TALLOC_FREE(frame);
+               exit(1);
+       }
        lp_set_cmdline("log level", "1");
 
-       pc = poptGetContext(argv[0], argc, argv_const, long_options, 0);
+       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);
+       }
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
                switch(opt) {
@@ -225,8 +242,6 @@ int main(int argc, const char *argv[])
                }
        }
 
-       lp_load_global(get_dyn_CONFIGFILE());
-
        cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
 
        return cmocka_run_group_tests(tests, NULL, NULL);
index 8ef119100498af5b6f7ab8828d5d0689239cb8b1..f5deff37c4b2f1db2d66c27e9a2dc4c06bd6c533 100644 (file)
@@ -1291,7 +1291,7 @@ bld.SAMBA3_BINARY('test_mdsparser_es',
                  smbconf
                  jansson
                  cmocka
-                 popt_samba3_cmdline
+                 CMDLINE_S3
                  ''',
                  enabled=bld.env.spotlight_backend_es,
                  for_selftest=True)