r19878: Announce testsuites when using subunit.
[ira/wip.git] / source4 / torture / smbtorture.c
index b47127ff3fc94df887593a5ca575f6a882009b09..b06fb19f3d320b5fa29dcfc61b283ac6809969e7 100644 (file)
@@ -64,9 +64,11 @@ static bool run_matching(struct torture_context *torture,
 
                for (c = suite->children; c; c = c->next) {
                        asprintf(&name, "%s-%s", prefix, c->name);
+
                        if (gen_fnmatch(expr, name) == 0) {
                                *matched = true;
                                init_iconv();
+                               torture->active_testname = talloc_strdup(torture, prefix);
                                ret &= torture_run_suite(torture, c);
                                free(name);
                                continue;
@@ -82,7 +84,9 @@ static bool run_matching(struct torture_context *torture,
                        if (gen_fnmatch(expr, name) == 0) {
                                *matched = true;
                                init_iconv();
+                               torture->active_testname = talloc_strdup(torture, prefix);
                                ret &= torture_run_tcase(torture, t);
+                               talloc_free(torture->active_testname);
                        }
                        free(name);
                }
@@ -246,18 +250,6 @@ static void usage(poptContext pc)
        exit(1);
 }
 
-static bool is_binding_string(const char *binding_string)
-{
-       TALLOC_CTX *mem_ctx = talloc_named_const(NULL, 0, "is_binding_string");
-       struct dcerpc_binding *binding_struct;
-       NTSTATUS status;
-       
-       status = dcerpc_parse_binding(mem_ctx, binding_string, &binding_struct);
-
-       talloc_free(mem_ctx);
-       return NT_STATUS_IS_OK(status);
-}
-
 static void max_runtime_handler(int sig)
 {
        DEBUG(0,("maximum runtime exceeded for smbtorture - terminating\n"));
@@ -314,6 +306,11 @@ const static struct torture_ui_ops std_ui_ops = {
        .test_result = simple_test_result
 };
 
+static void subunit_suite_start(struct torture_context *ctx,
+                                                          struct torture_suite *suite)
+{
+       printf("testsuite: %s\n", suite->path);
+}
 
 static void subunit_test_start (struct torture_context *ctx, 
                                                            struct torture_tcase *tcase,
@@ -353,7 +350,8 @@ static void subunit_comment (struct torture_context *test,
 const static struct torture_ui_ops subunit_ui_ops = {
        .comment = subunit_comment,
        .test_start = subunit_test_start,
-       .test_result = subunit_test_result
+       .test_result = subunit_test_result,
+       .suite_start = subunit_suite_start
 };
 
 static void harness_test_start (struct torture_context *ctx, 
@@ -438,7 +436,7 @@ void run_recipe(struct torture_context *tctx, const char *recipe)
 
        for (i = 0; i < numlines; i++) {
                int argc;
-               char **argv;
+               const char **argv;
 
                ret = poptParseArgvString(lines[i], &argc, &argv);
                if (ret != 0) {
@@ -456,7 +454,7 @@ void run_shell(struct torture_context *tctx)
 {
        char *cline;
        int argc;
-       char **argv;
+       const char **argv;
        int ret;
 
        while (1) {
@@ -512,27 +510,30 @@ int main(int argc,char *argv[])
        poptContext pc;
        static const char *target = "other";
        const char **subunit_dir;
+       struct dcerpc_binding *binding_struct;
+       NTSTATUS status;
        int shell = False;
        static const char *ui_ops_name = "simple";
        enum {OPT_LOADFILE=1000,OPT_UNCLIST,OPT_TIMELIMIT,OPT_DNS,
-             OPT_DANGEROUS,OPT_SMB_PORTS,OPT_ASYNC};
+             OPT_DANGEROUS,OPT_SMB_PORTS,OPT_ASYNC,OPT_NUMPROGS, OPT_BASEDIR};
        
        struct poptOption long_options[] = {
                POPT_AUTOHELP
                {"format", 0, POPT_ARG_STRING, &ui_ops_name, 0, "Output format (one of: simple, subunit, harness)", NULL },
                {"smb-ports",   'p', POPT_ARG_STRING, NULL,     OPT_SMB_PORTS,  "SMB ports",    NULL},
+               {"basedir",       0, POPT_ARG_STRING, NULL, OPT_BASEDIR, "base directory", "BSAEDIR" },
                {"seed",          0, POPT_ARG_INT,  &torture_seed,      0,      "seed",         NULL},
+               {"num-progs",     0, POPT_ARG_INT,  NULL,       OPT_NUMPROGS,   "num progs",    NULL},
                {"num-ops",       0, POPT_ARG_INT,  &torture_numops,    0,      "num ops",      NULL},
                {"entries",       0, POPT_ARG_INT,  &torture_entries,   0,      "entries",      NULL},
-               {"show-all",      0, POPT_ARG_NONE, &torture_showall,   0,      "show all",     NULL},
                {"loadfile",      0, POPT_ARG_STRING,   NULL,   OPT_LOADFILE,   "loadfile",     NULL},
                {"unclist",       0, POPT_ARG_STRING,   NULL,   OPT_UNCLIST,    "unclist",      NULL},
-               {"timelimit",   't', POPT_ARG_STRING,   NULL,   OPT_TIMELIMIT,  "timelimit",    NULL},
+               {"timelimit",   't', POPT_ARG_INT,      NULL,   OPT_TIMELIMIT,  "timelimit",    NULL},
                {"failures",    'f', POPT_ARG_INT,  &torture_failures,  0,      "failures",     NULL},
                {"parse-dns",   'D', POPT_ARG_STRING,   NULL,   OPT_DNS,        "parse-dns",    NULL},
                {"dangerous",   'X', POPT_ARG_NONE,     NULL,   OPT_DANGEROUS,
                 "run dangerous tests (eg. wiping out password database)", NULL},
-               {"shell",               's', POPT_ARG_NONE, &shell, True, "Run shell", NULL},
+               {"shell",               0, POPT_ARG_NONE, &shell, True, "Run shell", NULL},
                {"target",              'T', POPT_ARG_STRING, &target, 0, "samba3|samba4|other", NULL},
                {"async",       'a', POPT_ARG_NONE,     NULL,   OPT_ASYNC,
                 "run async tests", NULL},
@@ -568,6 +569,12 @@ int main(int argc,char *argv[])
                case OPT_TIMELIMIT:
                        lp_set_cmdline("torture:timelimit", poptGetOptArg(pc));
                        break;
+               case OPT_NUMPROGS:
+                       lp_set_cmdline("torture:nprocs", poptGetOptArg(pc));
+                       break;
+               case OPT_BASEDIR:
+                       lp_set_cmdline("torture:basedir", poptGetOptArg(pc));
+                       break;
                case OPT_DNS:
                        parse_dns(poptGetOptArg(pc));
                        break;
@@ -634,7 +641,10 @@ int main(int argc,char *argv[])
        }
 
        /* see if its a RPC transport specifier */
-       if (is_binding_string(argv_new[1])) {
+       status = dcerpc_parse_binding(talloc_autofree_context(), argv_new[1], &binding_struct);
+       if (NT_STATUS_IS_OK(status)) {
+               lp_set_cmdline("torture:host", binding_struct->host);
+               lp_set_cmdline("torture:share", "IPC$");
                lp_set_cmdline("torture:binding", argv_new[1]);
        } else {
                char *binding = NULL;