aboutsummaryrefslogtreecommitdiffstats
path: root/tests/vty
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-10-07 02:47:52 +0700
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-10-07 12:18:10 +0700
commit9a28d3c599b8be7b1442cce1d8598f48bd99bb86 (patch)
tree9d1cbe135b47b91794cd2eeeae158aaf5dd65bd1 /tests/vty
parent75fec3a419eb15a612921790df7af1ae657c1fc5 (diff)
tests/vty: verify 'show vty-attributes' / 'list' commands
Diffstat (limited to 'tests/vty')
-rw-r--r--tests/vty/vty_transcript_test.c119
-rw-r--r--tests/vty/vty_transcript_test.vty38
2 files changed, 157 insertions, 0 deletions
diff --git a/tests/vty/vty_transcript_test.c b/tests/vty/vty_transcript_test.c
index 6651097e..abe37027 100644
--- a/tests/vty/vty_transcript_test.c
+++ b/tests/vty/vty_transcript_test.c
@@ -142,9 +142,34 @@ static void signal_handler(int signal)
}
}
+/* Application specific VTY attributes */
+enum {
+ TEST_ATTR_UNBELIEVABLE,
+ TEST_ATTR_MAGNIFICENT,
+ TEST_ATTR_WONDERFUL,
+ TEST_ATTR_UNUSED,
+};
+
static struct vty_app_info vty_info = {
.name = "vty_transcript_test",
.version = PACKAGE_VERSION,
+ .usr_attr_desc = {
+ /* Some random description strings, who cares... */
+ [TEST_ATTR_UNBELIEVABLE] = \
+ "Unbelievable: not able to be believed; unlikely to be true",
+ [TEST_ATTR_MAGNIFICENT] = \
+ "Magnificent: impressively beautiful, elaborate, or extravagant",
+ [TEST_ATTR_WONDERFUL] = \
+ "Wonderful: inspiring delight, pleasure, or admiration",
+ [TEST_ATTR_UNUSED] = \
+ "Intentionally unused attribute, ignore me",
+ },
+ .usr_attr_letters = {
+ [TEST_ATTR_UNBELIEVABLE] = 'u',
+ [TEST_ATTR_MAGNIFICENT] = 'm',
+ [TEST_ATTR_WONDERFUL] = 'w',
+ [TEST_ATTR_UNUSED] = 'n',
+ },
};
static const struct log_info_cat default_categories[] = {};
@@ -186,12 +211,106 @@ DEFUN(multi2, multi2_cmd,
return CMD_SUCCESS;
}
+#define X(f) (1 << f)
+
+enum {
+ ATTR_TEST_NODE = _LAST_OSMOVTY_NODE + 1,
+};
+
+static struct cmd_node attr_test_node = {
+ ATTR_TEST_NODE,
+ "%s(config-attr-test)# ",
+ 1
+};
+
+DEFUN(cfg_attr_test, cfg_attr_test_cmd,
+ "attribute-test",
+ "Enter attribute test node\n")
+{
+ vty->index = NULL;
+ vty->node = ATTR_TEST_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFUN_ATTR(cfg_attr_immediate, cfg_attr_immediate_cmd,
+ "foo-immediate",
+ "Applies immediately\n",
+ CMD_ATTR_IMMEDIATE)
+{
+ return CMD_SUCCESS;
+}
+
+DEFUN_ATTR(cfg_attr_node_exit, cfg_attr_node_exit_cmd,
+ "foo-node-exit",
+ "Applies on node exit\n",
+ CMD_ATTR_NODE_EXIT)
+{
+ return CMD_SUCCESS;
+}
+
+DEFUN_USRATTR(cfg_app_attr_unbelievable,
+ cfg_app_attr_unbelievable_cmd,
+ X(TEST_ATTR_UNBELIEVABLE),
+ "app-unbelievable",
+ "Unbelievable help message\n")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUN_USRATTR(cfg_app_attr_magnificent,
+ cfg_app_attr_magnificent_cmd,
+ X(TEST_ATTR_MAGNIFICENT),
+ "app-magnificent",
+ "Magnificent help message\n")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUN_USRATTR(cfg_app_attr_wonderful,
+ cfg_app_attr_wonderful_cmd,
+ X(TEST_ATTR_WONDERFUL),
+ "app-wonderful",
+ "Wonderful help message\n")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUN_USRATTR(cfg_app_attr_unbelievable_magnificent,
+ cfg_app_attr_unbelievable_magnificent_cmd,
+ X(TEST_ATTR_UNBELIEVABLE) | X(TEST_ATTR_MAGNIFICENT),
+ "app-unbelievable-magnificent",
+ "Unbelievable & magnificent help message\n")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUN_USRATTR(cfg_app_attr_unbelievable_wonderful,
+ cfg_app_attr_unbelievable_wonderful_cmd,
+ X(TEST_ATTR_UNBELIEVABLE) | X(TEST_ATTR_WONDERFUL),
+ "app-unbelievable-wonderful",
+ "Unbelievable & wonderful help message\n")
+{
+ return CMD_SUCCESS;
+}
+
static void init_vty_cmds()
{
install_element_ve(&single0_cmd);
install_element_ve(&multi0_cmd);
install_element_ve(&multi1_cmd);
install_element_ve(&multi2_cmd);
+
+ install_element(CONFIG_NODE, &cfg_attr_test_cmd);
+ install_node(&attr_test_node, NULL);
+ install_element(ATTR_TEST_NODE, &cfg_attr_immediate_cmd);
+ install_element(ATTR_TEST_NODE, &cfg_attr_node_exit_cmd);
+
+ install_element(ATTR_TEST_NODE, &cfg_app_attr_unbelievable_cmd);
+ install_element(ATTR_TEST_NODE, &cfg_app_attr_magnificent_cmd);
+ install_element(ATTR_TEST_NODE, &cfg_app_attr_wonderful_cmd);
+
+ install_element(ATTR_TEST_NODE, &cfg_app_attr_unbelievable_magnificent_cmd);
+ install_element(ATTR_TEST_NODE, &cfg_app_attr_unbelievable_wonderful_cmd);
}
int main(int argc, char **argv)
diff --git a/tests/vty/vty_transcript_test.vty b/tests/vty/vty_transcript_test.vty
index db58830e..28edf29c 100644
--- a/tests/vty/vty_transcript_test.vty
+++ b/tests/vty/vty_transcript_test.vty
@@ -84,3 +84,41 @@ ok argc=1 one
vty_transcript_test> single0
ok argc=0
+
+vty_transcript_test> show vty-attributes
+ Global attributes:
+ . This command is deprecated
+ . This command is hidden
+ . This command applies immediately
+ . This command applies on VTY node exit
+ Library specific attributes:
+ A This command applies on ASP restart
+ Application specific attributes:
+ u Unbelievable: not able to be believed; unlikely to be true
+ m Magnificent: impressively beautiful, elaborate, or extravagant
+ w Wonderful: inspiring delight, pleasure, or admiration
+ n Intentionally unused attribute, ignore me
+
+vty_transcript_test> en
+vty_transcript_test# configure terminal
+vty_transcript_test(config)# attribute-test
+
+vty_transcript_test(config-attr-test)# list
+...
+ foo-immediate
+ foo-node-exit
+ app-unbelievable
+ app-magnificent
+ app-wonderful
+ app-unbelievable-magnificent
+ app-unbelievable-wonderful
+
+vty_transcript_test(config-attr-test)# list with-flags
+...
+ ... foo-immediate
+ ... foo-node-exit
+ u.. app-unbelievable
+ .m. app-magnificent
+ ..w app-wonderful
+ um. app-unbelievable-magnificent
+ u.w app-unbelievable-wonderful