Change in libosmocore[master]: tests/vty: verify 'show vty-attributes' / 'list' commands

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Wed Oct 7 10:02:31 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/20466 )

Change subject: tests/vty: verify 'show vty-attributes' / 'list' commands
......................................................................

tests/vty: verify 'show vty-attributes' / 'list' commands

Change-Id: I397cf642b323a9a99b2406aabaa67a7786dc2a50
Related: SYS#4937
---
M tests/vty/vty_transcript_test.c
M tests/vty/vty_transcript_test.vty
2 files changed, 157 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/tests/vty/vty_transcript_test.c b/tests/vty/vty_transcript_test.c
index 6651097..abe3702 100644
--- a/tests/vty/vty_transcript_test.c
+++ b/tests/vty/vty_transcript_test.c
@@ -142,9 +142,34 @@
 	}
 }
 
+/* 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 @@
 	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 db58830..28edf29 100644
--- a/tests/vty/vty_transcript_test.vty
+++ b/tests/vty/vty_transcript_test.vty
@@ -84,3 +84,41 @@
 
 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

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/20466
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I397cf642b323a9a99b2406aabaa67a7786dc2a50
Gerrit-Change-Number: 20466
Gerrit-PatchSet: 4
Gerrit-Owner: Vadim Yanitskiy <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201007/e7f02752/attachment.htm>


More information about the gerrit-log mailing list