summaryrefslogtreecommitdiff
path: root/source4/torture/shell.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/shell.c
parenta5e14bded48ac53e21307eda1c9767be64b39a17 (diff)
downloadsamba-9f697903556529bb4fedd73d027c317e56f6bf21.tar.gz
smbtorture: Move interactive shell into a separate file.
Diffstat (limited to 'source4/torture/shell.c')
-rw-r--r--source4/torture/shell.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/source4/torture/shell.c b/source4/torture/shell.c
new file mode 100644
index 00000000000..1da4c590819
--- /dev/null
+++ b/source4/torture/shell.c
@@ -0,0 +1,79 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB torture tester
+ Copyright (C) Andrew Tridgell 1997-2003
+ Copyright (C) Jelmer Vernooij 2006-2008
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "system/readline.h"
+#include "lib/smbreadline/smbreadline.h"
+#include "torture/smbtorture.h"
+
+void torture_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")) {
+ torture_print_tests(true);
+ } 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 {
+ torture_run_named_tests(tctx, argv[1]);
+ }
+ }
+ free(cline);
+ }
+}