summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Wiles <keith.wiles@intel.com>2017-09-09 18:04:23 -0500
committerKeith Wiles <keith.wiles@intel.com>2017-11-25 07:43:12 -0600
commit09e545987714f93c0ea88908bb7a789f840bbb01 (patch)
treec37fa3aed04a6d315eb49a87c7bbc764c369a459
parent6c50bbbcb009d6d5d4707b6ef50a55d435c80a1f (diff)
downloaddpdk-draft-cli-09e545987714f93c0ea88908bb7a789f840bbb01.zip
dpdk-draft-cli-09e545987714f93c0ea88908bb7a789f840bbb01.tar.gz
dpdk-draft-cli-09e545987714f93c0ea88908bb7a789f840bbb01.tar.xz
cli_test: add new cli test code
-rw-r--r--test/Makefile1
-rwxr-xr-xtest/cli_test/Makefile52
-rw-r--r--test/cli_test/cli_test.c70
-rwxr-xr-xtest/cli_test/cli_test.py113
-rw-r--r--test/cli_test/cli_test_cmds.c114
-rwxr-xr-xtest/cli_test/cli_test_data.py312
6 files changed, 662 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile
index e996fd8..b426c1c 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -35,5 +35,6 @@ DIRS-$(CONFIG_RTE_APP_TEST) += test
DIRS-$(CONFIG_RTE_LIBRTE_ACL) += test-acl
DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += test-pipeline
DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_test
+DIRS-$(CONFIG_RTE_LIBRTE_CLI) += cli_test
include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/test/cli_test/Makefile b/test/cli_test/Makefile
new file mode 100755
index 0000000..dc0a6f2
--- /dev/null
+++ b/test/cli_test/Makefile
@@ -0,0 +1,52 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+ifeq ($(CONFIG_RTE_LIBRTE_CLI),y)
+
+#
+# library name
+#
+APP = cli_test
+
+#
+# all sources are stored in SRCS-y
+#
+SRCS-y += cli_test.c
+SRCS-y += cli_test_cmds.c
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+include $(RTE_SDK)/mk/rte.app.mk
+
+endif
diff --git a/test/cli_test/cli_test.c b/test/cli_test/cli_test.c
new file mode 100644
index 0000000..7091579
--- /dev/null
+++ b/test/cli_test/cli_test.c
@@ -0,0 +1,70 @@
+/*-
+ * BSD LICENSE
+ *
+ * Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Created 2016 by Keith Wiles @ intel.com */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <libgen.h>
+#include <getopt.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+
+#include <rte_eal.h>
+#include <rte_version.h>
+#include <cli.h>
+
+int test_cli_tree_init(void);
+
+static void
+my_prompt(int cont __rte_unused)
+{
+ cli_printf("CLI_TEST>> ");
+}
+
+int
+main(int argc __rte_unused, char *argv[] __rte_unused)
+{
+ if (cli_create(my_prompt, test_cli_tree_init,
+ CLI_DEFAULT_NODES,
+ CLI_DEFAULT_HISTORY))
+ return -1;
+
+ cli_start("CLI Test Application");
+
+ cli_destroy();
+
+ return 0;
+}
diff --git a/test/cli_test/cli_test.py b/test/cli_test/cli_test.py
new file mode 100755
index 0000000..1a055c4
--- /dev/null
+++ b/test/cli_test/cli_test.py
@@ -0,0 +1,113 @@
+#!/usr/bin/python
+
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Script that runs cli_test app and feeds keystrokes into it.
+
+import sys, pexpect, string, os, cli_test_data
+
+#
+# function to run test
+#
+def runTest(child,test):
+ child.send(test["Sequence"])
+ if test["Result"] == None:
+ return 0
+ child.expect(test["Result"],1)
+
+#
+# history test is a special case
+#
+# This test does the following:
+# 1) fills the history with garbage up to its full capacity
+# (just enough to remove last entry)
+# 2) scrolls back history to the very beginning
+# 3) checks if the output is as expected, that is, the first
+# number in the sequence (not the last entry before it)
+#
+# This is a self-contained test, it needs only a pexpect child
+#
+def runHistoryTest(child):
+ # find out history size
+ child.sendline(cli_test_data.CMD_GET_BUFSIZE)
+ child.expect("History buffer size: \\d+", timeout=1)
+ history_size = int(child.after[len(cli_test_data.BUFSIZE_TEMPLATE):])
+ i = 0
+
+ # fill the history with numbers
+ while i < history_size:
+ # add 1 to prevent from parsing as octals
+ child.send("1" + str(i).zfill(8) + cli_test_data.ENTER)
+ # the app will simply print out the number
+ child.expect(str(i + 100000000), timeout=1)
+ i += 1
+ # scroll back history
+ child.send(cli_test_data.UP * (i + 2) + cli_test_data.ENTER)
+ child.expect("100000000", timeout=1)
+
+# the path to cli_test executable is supplied via command-line.
+if len(sys.argv) < 2:
+ print "Error: please supply cli_test app path"
+ sys.exit(1)
+
+test_app_path = sys.argv[1]
+
+if not os.path.exists(test_app_path):
+ print "Error: please supply cli_test app path"
+ sys.exit(1)
+
+child = pexpect.spawn(test_app_path + " --no-pci --no-huge")
+
+print "Running command-line tests..."
+for test in cli_test_data.tests:
+ print (test["Name"] + ":").ljust(30),
+ try:
+ runTest(child,test)
+ print "PASS"
+ except:
+ print "FAIL"
+ print child
+ sys.exit(1)
+
+# since last test quits the app, run new instance
+child = pexpect.spawn(test_app_path + " --no-pci --no-huge")
+
+print ("History fill test:").ljust(30),
+try:
+ runHistoryTest(child)
+ print "PASS"
+except:
+ print "FAIL"
+ print child
+ sys.exit(1)
+child.close()
+sys.exit(0)
diff --git a/test/cli_test/cli_test_cmds.c b/test/cli_test/cli_test_cmds.c
new file mode 100644
index 0000000..9c01845
--- /dev/null
+++ b/test/cli_test/cli_test_cmds.c
@@ -0,0 +1,114 @@
+/*-
+ * BSD LICENSE
+ *
+ * Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Created 2016 by Keith Wiles @ intel.com */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <libgen.h>
+#include <getopt.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+
+#include <rte_eal.h>
+#include <rte_version.h>
+#include <cli.h>
+
+extern int test_cli_tree_init(void);
+
+static int
+single_cmd(int argc __rte_unused, char * *argv __rte_unused)
+{
+ cli_printf("Single word command parsed!\n");
+ return 0;
+}
+
+static int
+long_single_cmd(int argc __rte_unused, char * *argv __rte_unused)
+{
+ cli_printf("Single long word command parsed!\n");
+ return 0;
+}
+
+static int
+ambiguous_cmd(int argc __rte_unused, char **argv)
+{
+ if (argc == 1)
+ return -1;
+
+ if (strcmp(argv[1], "first") == 0)
+ cli_printf("Command 1 parsed!\n");
+ else if (strcmp(argv[1], "second") == 0)
+ cli_printf("Command 2 parsed!\n");
+ else if (strcmp(argv[1], "ambiguous") == 0)
+ cli_printf("Ambiguous command\n");
+ else if (strcmp(argv[1], "ambiguous2") == 0)
+ cli_printf("Ambiguous command\n");
+ else
+ return -1;
+
+ return 0;
+}
+
+static int
+get_hist_size_cmd(int argc __rte_unused, char * *argv __rte_unused)
+{
+ cli_printf("History buffer size: %d\n", cli_get_history_size());
+ return 0;
+}
+
+static struct cli_tree test_tree[] = {
+ c_dir("/tbin"),
+ c_cmd("single", single_cmd, "single command"),
+ c_cmd("long_single", long_single_cmd, "single long command"),
+ c_cmd("get_history_size", get_hist_size_cmd, "Get the history size"),
+ c_cmd("ambiguous", ambiguous_cmd, "ambiguous command"),
+
+ c_end()
+};
+
+int
+test_cli_tree_init(void)
+{
+ if (cli_default_tree_init())
+ return -1;
+
+ if (cli_add_tree(NULL, test_tree))
+ return -1;
+
+ return cli_add_bin_path("/tbin");
+
+ return 0;
+}
diff --git a/test/cli_test/cli_test_data.py b/test/cli_test/cli_test_data.py
new file mode 100755
index 0000000..854fd1f
--- /dev/null
+++ b/test/cli_test/cli_test_data.py
@@ -0,0 +1,312 @@
+#!/usr/bin/python
+
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# collection of static data
+
+import sys
+
+# keycode constants
+CTRL_A = chr(1)
+CTRL_B = chr(2)
+CTRL_C = chr(3)
+CTRL_D = chr(4)
+CTRL_E = chr(5)
+CTRL_F = chr(6)
+CTRL_K = chr(11)
+CTRL_L = chr(12)
+CTRL_N = chr(14)
+CTRL_P = chr(16)
+CTRL_W = chr(23)
+CTRL_X = chr(24)
+CTRL_Y = chr(25)
+ALT_B = chr(27) + chr(98)
+ALT_D = chr(27) + chr(100)
+ALT_F = chr(27) + chr(102)
+ALT_BKSPACE = chr(27) + chr(127)
+DEL = chr(27) + chr(91) + chr(51) + chr(126)
+TAB = chr(9)
+HELP = chr(63)
+BKSPACE = chr(127)
+RIGHT = chr(27) + chr(91) + chr(67)
+DOWN = chr(27) + chr(91) + chr(66)
+LEFT = chr(27) + chr(91) + chr(68)
+UP = chr(27) + chr(91) + chr(65)
+ENTER2 = '\r'
+ENTER = '\n'
+
+# expected result constants
+NOT_FOUND = "command not found"
+BAD_ARG = "Bad arguments"
+AMBIG = "Ambiguous command"
+CMD1 = "Command 1 parsed!"
+CMD2 = "Command 2 parsed!"
+SINGLE = "Single word command parsed!"
+SINGLE_LONG = "Single long word command parsed!"
+AUTO1 = "Autocomplete command 1 parsed!"
+AUTO2 = "Autocomplete command 2 parsed!"
+
+# misc defines
+CMD_QUIT = "quit"
+CMD_GET_BUFSIZE = "get_history_size"
+BUFSIZE_TEMPLATE = "History buffer size: "
+PROMPT = "CLI_TEST>>"
+
+# test defines
+# each test tests progressively diverse set of keys. this way for example
+# if we want to use some key sequence in the test, we first need to test
+# that it itself does what it is expected to do. Most of the tests are
+# designed that way.
+#
+# example: "arrows & delete test 1". we enter a partially valid command,
+# then move 3 chars left and use delete three times. this way we get to
+# know that "delete", "left" and "ctrl+B" all work (because if any of
+# them fails, the whole test will fail and next tests won't be run).
+#
+# each test consists of name, character sequence to send to child,
+# and expected output (if any).
+
+tests = [
+# test basic commands
+ {"Name" : "command test 1",
+ "Sequence" : "ambiguous first" + ENTER,
+ "Result" : CMD1},
+ {"Name" : "command test 2",
+ "Sequence" : "ambiguous second" + ENTER,
+ "Result" : CMD2},
+ {"Name" : "command test 3",
+ "Sequence" : "ambiguous ambiguous" + ENTER,
+ "Result" : AMBIG},
+ {"Name" : "command test 4",
+ "Sequence" : "ambiguous ambiguous2" + ENTER,
+ "Result" : AMBIG},
+
+ {"Name" : "invalid command test 1",
+ "Sequence" : "ambiguous invalid" + ENTER,
+ "Result" : BAD_ARG},
+# test invalid commands
+ {"Name" : "invalid command test 2",
+ "Sequence" : "invalid" + ENTER,
+ "Result" : NOT_FOUND},
+ {"Name" : "invalid command test 3",
+ "Sequence" : "ambiguousinvalid" + ENTER2,
+ "Result" : NOT_FOUND},
+
+# test arrows and deletes
+ {"Name" : "arrows & delete test 1",
+ "Sequence" : "singlebad" + LEFT*2 + CTRL_B + DEL*3 + ENTER,
+ "Result" : SINGLE},
+ {"Name" : "arrows & delete test 2",
+ "Sequence" : "singlebad" + LEFT*5 + RIGHT + CTRL_F + DEL*3 + ENTER,
+ "Result" : SINGLE},
+
+# test backspace
+ {"Name" : "backspace test",
+ "Sequence" : "singlebad" + BKSPACE*3 + ENTER,
+ "Result" : SINGLE},
+
+# test goto left and goto right
+ {"Name" : "goto left test",
+ "Sequence" : "biguous first" + CTRL_A + "am" + ENTER,
+ "Result" : CMD1},
+ {"Name" : "goto right test",
+ "Sequence" : "biguous fir" + CTRL_A + "am" + CTRL_E + "st" + ENTER,
+ "Result" : CMD1},
+
+# test goto words
+ {"Name" : "goto left word test",
+ "Sequence" : "ambiguous st" + ALT_B + "fir" + ENTER,
+ "Result" : CMD1},
+ {"Name" : "goto right word test",
+ "Sequence" : "ambig first" + CTRL_A + ALT_F + "uous" + ENTER,
+ "Result" : CMD1},
+
+# test removing words
+ {"Name" : "remove left word 1",
+ "Sequence" : "single invalid" + CTRL_W + ENTER,
+ "Result" : SINGLE},
+ {"Name" : "remove left word 2",
+ "Sequence" : "single invalid" + ALT_BKSPACE + ENTER,
+ "Result" : SINGLE},
+ {"Name" : "remove right word",
+ "Sequence" : "single invalid" + ALT_B + ALT_D + ENTER,
+ "Result" : SINGLE},
+
+# test kill buffer (copy and paste)
+ {"Name" : "killbuffer test 1",
+ "Sequence" : "ambiguous" + CTRL_A + CTRL_K + " first" + CTRL_A + CTRL_Y + ENTER,
+ "Result" : CMD1},
+ {"Name" : "killbuffer test 2",
+ "Sequence" : "ambiguous" + CTRL_A + CTRL_K + CTRL_Y*26 + ENTER,
+ "Result" : NOT_FOUND},
+
+# test newline
+ {"Name" : "newline test",
+ "Sequence" : "invalid" + CTRL_C + "single" + ENTER,
+ "Result" : SINGLE},
+
+# test redisplay (nothing should really happen)
+ {"Name" : "redisplay test",
+ "Sequence" : "single" + CTRL_L + ENTER,
+ "Result" : SINGLE},
+
+# test autocomplete
+ {"Name" : "autocomplete test 1",
+ "Sequence" : "si" + TAB + ENTER,
+ "Result" : SINGLE},
+ {"Name" : "autocomplete test 2",
+ "Sequence" : "lo" + TAB + ENTER,
+ "Result" : SINGLE_LONG},
+ {"Name" : "autocomplete test 3",
+ "Sequence" : "in" + TAB + ENTER,
+ "Result" : NOT_FOUND},
+ {"Name" : "autocomplete test 4",
+ "Sequence" : "am" + TAB + ENTER,
+ "Result" : BAD_ARG},
+# {"Name" : "autocomplete test 5",
+# "Sequence" : "am" + TAB + "fir" + TAB + ENTER,
+# "Result" : CMD1},
+# {"Name" : "autocomplete test 6",
+# "Sequence" : "am" + TAB + "fir" + TAB + TAB + ENTER,
+# "Result" : CMD1},
+# {"Name" : "autocomplete test 7",
+# "Sequence" : "am" + TAB + "fir" + TAB + " " + TAB + ENTER,
+# "Result" : CMD1},
+# {"Name" : "autocomplete test 8",
+# "Sequence" : "am" + TAB + " am" + TAB + " " + ENTER,
+# "Result" : AMBIG},
+# {"Name" : "autocomplete test 9",
+# "Sequence" : "am" + TAB + "inv" + TAB + ENTER,
+# "Result" : BAD_ARG},
+# {"Name" : "autocomplete test 10",
+# "Sequence" : "au" + TAB + ENTER,
+# "Result" : NOT_FOUND},
+# {"Name" : "autocomplete test 11",
+# "Sequence" : "au" + TAB + "1" + ENTER,
+# "Result" : AUTO1},
+# {"Name" : "autocomplete test 12",
+# "Sequence" : "au" + TAB + "2" + ENTER,
+# "Result" : AUTO2},
+# {"Name" : "autocomplete test 13",
+# "Sequence" : "au" + TAB + "2" + TAB + ENTER,
+# "Result" : AUTO2},
+# {"Name" : "autocomplete test 14",
+# "Sequence" : "au" + TAB + "2 " + TAB + ENTER,
+# "Result" : AUTO2},
+# {"Name" : "autocomplete test 15",
+# "Sequence" : "24" + TAB + ENTER,
+# "Result" : "24"},
+
+# test history
+ {"Name" : "history test 1",
+ "Sequence" : "invalid" + ENTER + "single" + ENTER + "invalid" + ENTER + UP + CTRL_P + ENTER,
+ "Result" : SINGLE},
+ {"Name" : "history test 2",
+ "Sequence" : "invalid" + ENTER + "ambiguous first" + ENTER + "invalid" + ENTER + "single" + ENTER + UP * 3 + CTRL_N + DOWN + ENTER,
+ "Result" : SINGLE},
+
+#
+# tests that improve coverage
+#
+
+# empty space tests
+ {"Name" : "empty space test 1",
+ "Sequence" : RIGHT + LEFT + CTRL_B + CTRL_F + ENTER,
+ "Result" : PROMPT},
+ {"Name" : "empty space test 2",
+ "Sequence" : BKSPACE + ENTER,
+ "Result" : PROMPT},
+ {"Name" : "empty space test 3",
+ "Sequence" : CTRL_E*2 + CTRL_A*2 + ENTER,
+ "Result" : PROMPT},
+ {"Name" : "empty space test 4",
+ "Sequence" : ALT_F*2 + ALT_B*2 + ENTER,
+ "Result" : PROMPT},
+ {"Name" : "empty space test 5",
+ "Sequence" : " " + CTRL_E*2 + CTRL_A*2 + ENTER,
+ "Result" : PROMPT},
+ {"Name" : "empty space test 6",
+ "Sequence" : " " + CTRL_A + ALT_F*2 + ALT_B*2 + ENTER,
+ "Result" : PROMPT},
+ {"Name" : "empty space test 7",
+ "Sequence" : " " + CTRL_A + CTRL_D + CTRL_E + CTRL_D + ENTER,
+ "Result" : PROMPT},
+ {"Name" : "empty space test 8",
+ "Sequence" : " space" + CTRL_W*2 + ENTER,
+ "Result" : PROMPT},
+ {"Name" : "empty space test 9",
+ "Sequence" : " space" + ALT_BKSPACE*2 + ENTER,
+ "Result" : PROMPT},
+ {"Name" : "empty space test 10",
+ "Sequence" : " space " + CTRL_A + ALT_D*3 + ENTER,
+ "Result" : PROMPT},
+
+# non-printable char tests
+ {"Name" : "non-printable test 1",
+ "Sequence" : chr(27) + chr(47) + ENTER,
+ "Result" : PROMPT},
+ {"Name" : "non-printable test 2",
+ "Sequence" : chr(27) + chr(128) + ENTER*7,
+ "Result" : PROMPT},
+ {"Name" : "non-printable test 3",
+ "Sequence" : chr(27) + chr(91) + chr(127) + ENTER*6,
+ "Result" : PROMPT},
+
+# miscellaneous tests
+ {"Name" : "misc test 1",
+ "Sequence" : ENTER,
+ "Result" : PROMPT},
+ {"Name" : "misc test 2",
+ "Sequence" : "single #comment" + ENTER,
+ "Result" : SINGLE},
+ {"Name" : "misc test 3",
+ "Sequence" : "#empty line" + ENTER,
+ "Result" : PROMPT},
+ {"Name" : "misc test 4",
+ "Sequence" : " single " + ENTER,
+ "Result" : SINGLE},
+# {"Name" : "misc test 5",
+# "Sequence" : "single#" + ENTER,
+# "Result" : SINGLE},
+ {"Name" : "misc test 6",
+ "Sequence" : 'a' * 257 + ENTER,
+ "Result" : NOT_FOUND},
+ {"Name" : "misc test 7",
+ "Sequence" : "clear_history" + UP*5 + DOWN*5 + ENTER,
+ "Result" : PROMPT},
+ {"Name" : "misc test 8",
+ "Sequence" : "a" + HELP + CTRL_C,
+ "Result" : PROMPT},
+ {"Name" : "misc test 9",
+ "Sequence" : CTRL_X*3,
+ "Result" : None},
+]