summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Wiles <keith.wiles@intel.com>2017-09-09 18:21:10 -0500
committerKeith Wiles <keith.wiles@intel.com>2017-11-25 07:46:29 -0600
commita8177b88a3942343a77851aca078b02df42b5255 (patch)
tree352632221b9c4c477117ae6fa4ab2699bfdc5310
parentb63613fd4b2f633e2ca07c1acee9a4a1569c49b2 (diff)
downloaddpdk-draft-cli-a8177b88a3942343a77851aca078b02df42b5255.zip
dpdk-draft-cli-a8177b88a3942343a77851aca078b02df42b5255.tar.gz
dpdk-draft-cli-a8177b88a3942343a77851aca078b02df42b5255.tar.xz
cli_test: reformat file
-rw-r--r--examples/cli/main.c85
-rwxr-xr-xtest/cli_test/cli_test.py82
2 files changed, 88 insertions, 79 deletions
diff --git a/examples/cli/main.c b/examples/cli/main.c
index 84e8959..fab4a4b 100644
--- a/examples/cli/main.c
+++ b/examples/cli/main.c
@@ -107,19 +107,21 @@ pci_file(struct cli_node *node, char *buff, int len, uint32_t opt)
}
static struct cli_map show_map[] = {
- {10, "show %P"},
- {20, "show %P mac %m"},
- {30, "show %P vlan %d mac %m"},
- {40, "show %P %|vlan|mac"},
- {-1, NULL}};
+ {10, "show %P"},
+ {20, "show %P mac %m"},
+ {30, "show %P vlan %d mac %m"},
+ {40, "show %P %|vlan|mac"},
+ {-1, NULL}
+};
static const char *show_help[] = {
- "show <portlist>",
- "show <portlist> mac <ether_addr>",
- "show <portlist> vlan <vlanid> mac <ether_addr>",
- "show <portlist> [vlan|mac]",
- CLI_HELP_PAUSE,
- NULL};
+ "show <portlist>",
+ "show <portlist> mac <ether_addr>",
+ "show <portlist> vlan <vlanid> mac <ether_addr>",
+ "show <portlist> [vlan|mac]",
+ CLI_HELP_PAUSE,
+ NULL
+};
static int
show_cmd(int argc, char **argv)
@@ -141,40 +143,40 @@ show_cmd(int argc, char **argv)
rte_parse_portlist(argv[1], &portlist);
rte_ether_aton(argv[3], &mac);
cli_printf(" Show Portlist: %016lx, MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
- portlist,
- mac.addr_bytes[0],
- mac.addr_bytes[1],
- mac.addr_bytes[2],
- mac.addr_bytes[3],
- mac.addr_bytes[4],
- mac.addr_bytes[5]);
+ portlist,
+ mac.addr_bytes[0],
+ mac.addr_bytes[1],
+ mac.addr_bytes[2],
+ mac.addr_bytes[3],
+ mac.addr_bytes[4],
+ mac.addr_bytes[5]);
break;
case 30:
rte_parse_portlist(argv[1], &portlist);
rte_ether_aton(argv[5], &mac);
cli_printf(" Show Portlist: %016lx vlan %d MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
- portlist,
- atoi(argv[3]),
- mac.addr_bytes[0],
- mac.addr_bytes[1],
- mac.addr_bytes[2],
- mac.addr_bytes[3],
- mac.addr_bytes[4],
- mac.addr_bytes[5]);
+ portlist,
+ atoi(argv[3]),
+ mac.addr_bytes[0],
+ mac.addr_bytes[1],
+ mac.addr_bytes[2],
+ mac.addr_bytes[3],
+ mac.addr_bytes[4],
+ mac.addr_bytes[5]);
break;
case 40:
rte_parse_portlist(argv[1], &portlist);
rte_ether_aton("1234:4567:8901", &mac);
cli_printf(" Show Portlist: %016lx %s: ",
- portlist, argv[2]);
+ portlist, argv[2]);
if (argv[2][0] == 'm')
cli_printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
- mac.addr_bytes[0],
- mac.addr_bytes[1],
- mac.addr_bytes[2],
- mac.addr_bytes[3],
- mac.addr_bytes[4],
- mac.addr_bytes[5]);
+ mac.addr_bytes[0],
+ mac.addr_bytes[1],
+ mac.addr_bytes[2],
+ mac.addr_bytes[3],
+ mac.addr_bytes[4],
+ mac.addr_bytes[5]);
else
cli_printf("%d\n", 101);
break;
@@ -186,14 +188,15 @@ show_cmd(int argc, char **argv)
}
static struct cli_tree my_tree[] = {
- c_dir("/data"),
- c_file("pci", pci_file, "display lspci information"),
- c_dir("/bin"),
- c_cmd("show", show_cmd, "show mapping options"),
- c_cmd("hello", hello_cmd, "Hello-World!!"),
- c_alias("h", "history", "display history commands"),
- c_alias("ll", "ls -l", "long directory listing alias"),
- c_end()};
+ c_dir("/data"),
+ c_file("pci", pci_file, "display lspci information"),
+ c_dir("/bin"),
+ c_cmd("show", show_cmd, "show mapping options"),
+ c_cmd("hello", hello_cmd, "Hello-World!!"),
+ c_alias("h", "history", "display history commands"),
+ c_alias("ll", "ls -l", "long directory listing alias"),
+ c_end()
+};
static int
init_tree(void)
diff --git a/test/cli_test/cli_test.py b/test/cli_test/cli_test.py
index 1a055c4..e474ae7 100755
--- a/test/cli_test/cli_test.py
+++ b/test/cli_test/cli_test.py
@@ -33,16 +33,22 @@
# Script that runs cli_test app and feeds keystrokes into it.
-import sys, pexpect, string, os, cli_test_data
+import sys
+import string
+import os
+import pexpect
+import 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)
+
+
+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
@@ -57,57 +63,57 @@ def runTest(child,test):
# 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
+ # 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)
+ # 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)
+ 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)
+ 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)
+ 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"
+ runHistoryTest(child)
+ print "PASS"
except:
- print "FAIL"
- print child
- sys.exit(1)
+ print "FAIL"
+ print child
+ sys.exit(1)
child.close()
sys.exit(0)