summaryrefslogtreecommitdiff
path: root/source4/torture/smbtorture.c
diff options
context:
space:
mode:
authorJames Peach <jpeach@samba.org>2010-03-19 21:24:15 -0700
committerJames Peach <jpeach@apple.com>2010-06-21 08:58:10 -0700
commit9f697903556529bb4fedd73d027c317e56f6bf21 (patch)
tree82283996917ec57011dcc62d448ee64fbe4f6032 /source4/torture/smbtorture.c
parenta5e14bded48ac53e21307eda1c9767be64b39a17 (diff)
downloadsamba-9f697903556529bb4fedd73d027c317e56f6bf21.tar.gz
smbtorture: Move interactive shell into a separate file.
Diffstat (limited to 'source4/torture/smbtorture.c')
-rw-r--r--source4/torture/smbtorture.c77
1 files changed, 18 insertions, 59 deletions
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index 96014a22066..b7140d70a57 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -40,7 +40,7 @@
static bool run_matching(struct torture_context *torture,
const char *prefix,
const char *expr,
- char **restricted,
+ const char **restricted,
struct torture_suite *suite,
bool *matched)
{
@@ -94,8 +94,8 @@ static bool run_matching(struct torture_context *torture,
/****************************************************************************
run a specified test or "ALL"
****************************************************************************/
-static bool run_test(struct torture_context *torture, const char *name,
- char **restricted)
+bool torture_run_named_tests(struct torture_context *torture, const char *name,
+ const char **restricted)
{
bool ret = true;
bool matched = false;
@@ -249,6 +249,15 @@ static void print_test_list(void)
}
}
+void torture_print_tests(bool structured)
+{
+ if (structured) {
+ print_structured_test_list();
+ } else {
+ print_test_list();
+ }
+}
+
_NORETURN_ static void usage(poptContext pc)
{
poptPrintUsage(pc, stdout, 0);
@@ -377,61 +386,6 @@ const static struct torture_ui_ops std_ui_ops = {
.progress = simple_progress,
};
-static void run_shell(struct torture_context *tctx)
-{
- char *cline;
- int argc;
- const char **argv;
- int ret;
-
- while (1) {
- cline = smb_readline("torture> ", NULL, NULL);
-
- if (cline == NULL)
- return;
-
-#if HAVE_ADD_HISTORY
- add_history(cline);
-#endif
-
- ret = poptParseArgvString(cline, &argc, &argv);
- if (ret != 0) {
- fprintf(stderr, "Error parsing line\n");
- continue;
- }
-
- if (!strcmp(argv[0], "quit")) {
- return;
- } else if (!strcmp(argv[0], "list")) {
- print_structured_test_list();
- } else if (!strcmp(argv[0], "set")) {
- if (argc < 3) {
- lp_dump(tctx->lp_ctx, stdout,
- false /* show_defaults */,
- 0 /* skip services */);
- } else {
- char *name = talloc_asprintf(NULL, "torture:%s", argv[1]);
- lp_set_cmdline(tctx->lp_ctx, name, argv[2]);
- talloc_free(name);
- }
- } else if (!strcmp(argv[0], "help")) {
- fprintf(stderr, "Available commands:\n"
- " help - This help command\n"
- " list - List the available\n"
- " run - Run test\n"
- " set - Change variables\n"
- "\n");
- } else if (!strcmp(argv[0], "run")) {
- if (argc < 2) {
- fprintf(stderr, "Usage: run TEST-NAME [OPTIONS...]\n");
- } else {
- run_test(tctx, argv[1]);
- }
- }
- free(cline);
- }
-}
-
/****************************************************************************
main program
****************************************************************************/
@@ -448,6 +402,7 @@ int main(int argc,char *argv[])
poptContext pc;
static const char *target = "other";
NTSTATUS status;
+ int shell = false;
static const char *ui_ops_name = "subunit";
const char *basedir = NULL;
const char *extra_module = NULL;
@@ -477,6 +432,7 @@ int main(int argc,char *argv[])
{"dangerous", 'X', POPT_ARG_NONE, NULL, OPT_DANGEROUS,
"run dangerous tests (eg. wiping out password database)", NULL},
{"load-module", 0, POPT_ARG_STRING, &extra_module, 0, "load tests from DSO file", "SOFILE"},
+ {"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},
@@ -695,9 +651,12 @@ int main(int argc,char *argv[])
if (argc_new == 0) {
printf("You must specify a testsuite to run, or 'ALL'\n");
+ } else if (shell) {
+ torture_shell(torture);
} else {
for (i=2;i<argc_new;i++) {
- if (!run_test(torture, argv_new[i], restricted)) {
+ if (!torture_run_named_tests(torture, argv_new[i],
+ (const char **)restricted)) {
correct = false;
}
}