s4:torture:vfs_fruit: fix test_aapl() to work with OS X
[samba.git] / source4 / torture / smbtorture.c
index 9620605174344b293f9c47f57c783082e7ccee80..fc50436933f8d20bc6ebb7a2a100a489ba776e8a 100644 (file)
@@ -32,7 +32,7 @@
 #include "librpc/rpc/dcerpc.h"
 #include "auth/gensec/gensec.h"
 #include "param/param.h"
-#include "lib/util/internal_module.h"
+#include "lib/util/samba_modules.h"
 
 #if HAVE_READLINE_HISTORY_H
 #include <readline/history.h>
@@ -158,12 +158,20 @@ bool torture_parse_target(struct loadparm_context *lp_ctx, const char *target)
 
        /* see if its a RPC transport specifier */
        if (!smbcli_parse_unc(target, NULL, &host, &share)) {
+               const char *h;
+
                status = dcerpc_parse_binding(talloc_autofree_context(), target, &binding_struct);
                if (NT_STATUS_IS_ERR(status)) {
                        d_printf("Invalid option: %s is not a valid torture target (share or binding string)\n\n", target);
                        return false;
                }
-               lpcfg_set_cmdline(lp_ctx, "torture:host", binding_struct->host);
+
+               h = dcerpc_binding_get_string_option(binding_struct, "host");
+               host = discard_const_p(char, h);
+               if (host != NULL) {
+                       lpcfg_set_cmdline(lp_ctx, "torture:host", host);
+               }
+
                if (lpcfg_parm_string(lp_ctx, NULL, "torture", "share") == NULL)
                        lpcfg_set_cmdline(lp_ctx, "torture:share", "IPC$");
                lpcfg_set_cmdline(lp_ctx, "torture:binding", target);
@@ -350,73 +358,10 @@ _NORETURN_ static void max_runtime_handler(int sig)
        exit(1);
 }
 
-struct timeval last_suite_started;
-
-static void simple_suite_start(struct torture_context *ctx,
-                              struct torture_suite *suite)
-{
-       last_suite_started = timeval_current();
-       printf("Running %s\n", suite->name);
-}
-
-static void simple_suite_finish(struct torture_context *ctx,
-                               struct torture_suite *suite)
-{
-
-       printf("%s took %g secs\n\n", suite->name, 
-                  timeval_elapsed(&last_suite_started));
-}
-
-static void simple_test_result(struct torture_context *context, 
-                              enum torture_result res, const char *reason)
-{
-       switch (res) {
-       case TORTURE_OK:
-               if (reason)
-                       printf("OK: %s\n", reason);
-               break;
-       case TORTURE_FAIL:
-               printf("TEST %s FAILED! - %s\n", context->active_test->name, reason);
-               break;
-       case TORTURE_ERROR:
-               printf("ERROR IN TEST %s! - %s\n", context->active_test->name, reason); 
-               break;
-       case TORTURE_SKIP:
-               printf("SKIP: %s - %s\n", context->active_test->name, reason);
-               break;
-       }
-}
-
-static void simple_comment(struct torture_context *test, 
-                          const char *comment)
-{
-       printf("%s", comment);
-}
-
-static void simple_warning(struct torture_context *test, 
-                          const char *comment)
-{
-       fprintf(stderr, "WARNING: %s\n", comment);
-}
-
-static void simple_progress(struct torture_context *test,
-       int offset, enum torture_progress_whence whence)
-{
-}
-
-const static struct torture_ui_ops std_ui_ops = {
-       .comment = simple_comment,
-       .warning = simple_warning,
-       .suite_start = simple_suite_start,
-       .suite_finish = simple_suite_finish,
-       .test_result = simple_test_result,
-       .progress = simple_progress,
-};
-
 /****************************************************************************
   main program
 ****************************************************************************/
-int main(int argc,char *argv[])
+int main(int argc, const char *argv[])
 {
        int opt, i;
        bool correct = true;
@@ -436,7 +381,7 @@ int main(int argc,char *argv[])
        const char *extra_module = NULL;
        static int list_tests = 0, list_testsuites = 0;
        int num_extra_users = 0;
-       char **restricted = NULL;
+       const char **restricted = NULL;
        int num_restricted = -1;
        const char *load_list = NULL;
        enum {OPT_LOADFILE=1000,OPT_UNCLIST,OPT_TIMELIMIT,OPT_DNS, OPT_LIST,
@@ -483,10 +428,12 @@ int main(int argc,char *argv[])
 
        setlinebuf(stdout);
 
+       printf("smbtorture %s\n", samba_version_string());
+
        /* we are never interested in SIGPIPE */
        BlockSignals(true, SIGPIPE);
 
-       pc = poptGetContext("smbtorture", argc, (const char **) argv, long_options, 
+       pc = poptGetContext("smbtorture", argc, argv, long_options,
                            POPT_CONTEXT_KEEP_FIRST);
 
        poptSetOtherOptionHelp(pc, "<binding>|<unc> TEST1 TEST2 ...");
@@ -535,8 +482,9 @@ int main(int argc,char *argv[])
        }
 
        if (load_list != NULL) {
-               restricted = file_lines_load(load_list, &num_restricted, 0,
-                                                                        talloc_autofree_context());
+               char **r;
+               r = file_lines_load(load_list, &num_restricted, 0, talloc_autofree_context());
+               restricted = discard_const_p(const char *, r);
                if (restricted == NULL) {
                        printf("Unable to read load list file '%s'\n", load_list);
                        exit(1);
@@ -548,6 +496,9 @@ int main(int argc,char *argv[])
                lpcfg_set_cmdline(cmdline_lp_ctx, "torture:resume_key_support", "false");
        } else if (strcmp(target, "samba4") == 0) {
                lpcfg_set_cmdline(cmdline_lp_ctx, "torture:samba4", "true");
+       } else if (strcmp(target, "samba4-ntvfs") == 0) {
+               lpcfg_set_cmdline(cmdline_lp_ctx, "torture:samba4", "true");
+               lpcfg_set_cmdline(cmdline_lp_ctx, "torture:samba4-ntvfs", "true");
        } else if (strcmp(target, "winxp") == 0) {
                lpcfg_set_cmdline(cmdline_lp_ctx, "torture:winxp", "true");
        } else if (strcmp(target, "w2k3") == 0) {
@@ -556,6 +507,8 @@ int main(int argc,char *argv[])
                lpcfg_set_cmdline(cmdline_lp_ctx, "torture:w2k8", "true");
                lpcfg_set_cmdline(cmdline_lp_ctx,
                    "torture:invalid_lock_range_support", "false");
+       } else if (strcmp(target, "w2k12") == 0) {
+               lpcfg_set_cmdline(cmdline_lp_ctx, "torture:w2k12", "true");
        } else if (strcmp(target, "win7") == 0) {
                lpcfg_set_cmdline(cmdline_lp_ctx, "torture:win7", "true");
                lpcfg_set_cmdline(cmdline_lp_ctx, "torture:cn_max_buffer_size",
@@ -602,7 +555,7 @@ int main(int argc,char *argv[])
        }
 
        if (extra_module != NULL) {
-               samba_init_module_fn fn = load_module(poptGetOptArg(pc), false, NULL);
+               init_module_fn fn = load_module(poptGetOptArg(pc), false, NULL);
 
                if (fn == NULL) 
                        d_printf("Unable to load module from %s\n", poptGetOptArg(pc));
@@ -650,7 +603,7 @@ int main(int argc,char *argv[])
        srandom(torture_seed);
 
        if (!strcmp(ui_ops_name, "simple")) {
-               ui_ops = &std_ui_ops;
+               ui_ops = &torture_simple_ui_ops;
        } else if (!strcmp(ui_ops_name, "subunit")) {
                ui_ops = &torture_subunit_ui_ops;
        } else {