aboutsummaryrefslogtreecommitdiffstats
path: root/tests/vty
diff options
context:
space:
mode:
Diffstat (limited to 'tests/vty')
-rw-r--r--tests/vty/vty_test.c148
-rw-r--r--tests/vty/vty_test.err77
-rw-r--r--tests/vty/vty_test.ok57
-rw-r--r--tests/vty/vty_transcript_test.c228
-rw-r--r--tests/vty/vty_transcript_test.vty123
5 files changed, 619 insertions, 14 deletions
diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c
index 9627b6d2..a3f8489f 100644
--- a/tests/vty/vty_test.c
+++ b/tests/vty/vty_test.c
@@ -13,15 +13,12 @@
* 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, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -42,6 +39,7 @@
#include <osmocom/vty/stats.h>
static enum event last_vty_connection_event = -1;
+static const char *cfg_path = NULL;
void *ctx = NULL;
static void test_cmd_string_from_valstr(void)
@@ -295,9 +293,12 @@ static void test_stats_vty(void)
void test_exit_by_indent(const char *fname, int expect_rc)
{
+ char fpath[PATH_MAX];
int rc;
+
printf("reading file %s, expecting rc=%d\n", fname, expect_rc);
- rc = vty_read_config_file(fname, NULL);
+ snprintf(&fpath[0], sizeof(fpath), "%s/%s", cfg_path, fname);
+ rc = vty_read_config_file(fpath, NULL);
printf("got rc=%d\n", rc);
OSMO_ASSERT(rc == expect_rc);
}
@@ -438,7 +439,48 @@ DEFUN(cfg_ret_warning, cfg_ret_warning_cmd,
return CMD_WARNING;
}
-void test_vty_add_cmds()
+DEFUN(cfg_numeric_range, cfg_numeric_range_cmd,
+#if ULONG_MAX == 18446744073709551615UL
+ "numeric-range <0-18446744073709551615>",
+#else
+ "numeric-range <0-4294967295>",
+#endif
+ "testing numeric range\n"
+ "the numeric range\n")
+{
+ printf("Called: 'return-success'\n");
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_range_base10, cfg_range_base10_cmd,
+ "range-base10 <0-999999>",
+ "testing decimal range\n"
+ "the decimal range\n")
+{
+ printf("Called: 'return-success'\n");
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_range_base16, cfg_range_base16_cmd,
+ "range-base16 <0x0-0x8888>",
+ "testing hexadecimal range\n"
+ "the hexadecimal range\n")
+{
+ printf("Called: 'return-success'\n");
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_range_baseboth, cfg_range_baseboth_cmd,
+ "range-baseboth (<0-999999>|<0x0-0x8888>)",
+ "testing both ranges\n"
+ "the decimal range\n"
+ "the hexadecimal range\n")
+{
+ printf("Called: 'return-success'\n");
+ return CMD_SUCCESS;
+}
+
+void test_vty_add_cmds(void)
{
install_element(CONFIG_NODE, &cfg_ret_warning_cmd);
install_element(CONFIG_NODE, &cfg_ret_success_cmd);
@@ -461,9 +503,15 @@ void test_vty_add_cmds()
install_element_ve(&cfg_ambiguous_nr_2_cmd);
install_element_ve(&cfg_ambiguous_str_1_cmd);
install_element_ve(&cfg_ambiguous_str_2_cmd);
+
+ install_element_ve(&cfg_numeric_range_cmd);
+
+ install_element_ve(&cfg_range_base10_cmd);
+ install_element_ve(&cfg_range_base16_cmd);
+ install_element_ve(&cfg_range_baseboth_cmd);
}
-void test_is_cmd_ambiguous()
+void test_is_cmd_ambiguous(void)
{
struct vty *vty;
struct vty_test test;
@@ -482,11 +530,88 @@ void test_is_cmd_ambiguous()
destroy_test_vty(&test, vty);
}
+void test_numeric_range(void)
+{
+ struct vty *vty;
+ struct vty_test test;
+
+ printf("Going to test test_numeric_range()\n");
+ vty = create_test_vty(&test);
+
+ OSMO_ASSERT(do_vty_command(vty, "numeric-range 0") == CMD_SUCCESS);
+ OSMO_ASSERT(do_vty_command(vty, "numeric-range 40000") == CMD_SUCCESS);
+ OSMO_ASSERT(do_vty_command(vty, "numeric-range -400000") == CMD_ERR_NO_MATCH);
+
+ destroy_test_vty(&test, vty);
+}
+
+void test_ranges(void)
+{
+ struct vty *vty;
+ struct vty_test test;
+
+ printf("Going to test test_ranges()\n");
+ vty = create_test_vty(&test);
+
+ printf("test range-base10\n");
+ OSMO_ASSERT(do_vty_command(vty, "range-base10 0") == CMD_SUCCESS);
+ OSMO_ASSERT(do_vty_command(vty, "range-base10 40000") == CMD_SUCCESS);
+ OSMO_ASSERT(do_vty_command(vty, "range-base10 -400000") == CMD_ERR_NO_MATCH);
+ OSMO_ASSERT(do_vty_command(vty, "range-base10 0x0") == CMD_ERR_NO_MATCH);
+ OSMO_ASSERT(do_vty_command(vty, "range-base10 0x343") == CMD_ERR_NO_MATCH);
+ OSMO_ASSERT(do_vty_command(vty, "range-base10 -0x343") == CMD_ERR_NO_MATCH);
+
+ printf("test range-base16\n");
+ OSMO_ASSERT(do_vty_command(vty, "range-base16 0") == CMD_ERR_NO_MATCH);
+ OSMO_ASSERT(do_vty_command(vty, "range-base16 40000") == CMD_ERR_NO_MATCH);
+ OSMO_ASSERT(do_vty_command(vty, "range-base16 -400000") == CMD_ERR_NO_MATCH);
+ OSMO_ASSERT(do_vty_command(vty, "range-base16 0x0") == CMD_SUCCESS);
+ OSMO_ASSERT(do_vty_command(vty, "range-base16 0x343") == CMD_SUCCESS);
+ OSMO_ASSERT(do_vty_command(vty, "range-base16 -0x343") == CMD_ERR_NO_MATCH);
+
+ printf("test range-baseboth\n");
+ OSMO_ASSERT(do_vty_command(vty, "range-baseboth 0") == CMD_SUCCESS);
+ OSMO_ASSERT(do_vty_command(vty, "range-baseboth 40000") == CMD_SUCCESS);
+ OSMO_ASSERT(do_vty_command(vty, "range-baseboth -400000") == CMD_ERR_NO_MATCH);
+ OSMO_ASSERT(do_vty_command(vty, "range-baseboth 0x0") == CMD_SUCCESS);
+ OSMO_ASSERT(do_vty_command(vty, "range-baseboth 0x343") == CMD_SUCCESS);
+ OSMO_ASSERT(do_vty_command(vty, "range-baseboth -0x343") == CMD_ERR_NO_MATCH);
+
+ destroy_test_vty(&test, vty);
+}
+/* Application specific attributes */
+enum vty_test_attr {
+ VTY_TEST_ATTR_FOO = 0,
+ VTY_TEST_ATTR_BAR,
+ VTY_TEST_ATTR_ZOO,
+ VTY_TEST_ATTR_FOO_DUP,
+ VTY_TEST_ATTR_ZOO_DUP,
+ VTY_TEST_ATTR_UPPER,
+ VTY_TEST_ATTR_RAFC_DOT,
+ VTY_TEST_ATTR_RAFC_EXCL,
+ VTY_TEST_ATTR_RAFC_AT,
+};
+
int main(int argc, char **argv)
{
struct vty_app_info vty_info = {
.name = "VtyTest",
.version = 0,
+ .usr_attr_letters = {
+ [VTY_TEST_ATTR_FOO] = 'f',
+ [VTY_TEST_ATTR_BAR] = 'b',
+ [VTY_TEST_ATTR_ZOO] = 'z',
+
+ /* Duplicate detection check */
+ [VTY_TEST_ATTR_FOO_DUP] = 'f',
+ [VTY_TEST_ATTR_ZOO_DUP] = 'z',
+ /* Reserved for libraries */
+ [VTY_TEST_ATTR_UPPER] = 'X',
+ /* Reserved for global attribues */
+ [VTY_TEST_ATTR_RAFC_DOT] = '.',
+ [VTY_TEST_ATTR_RAFC_EXCL] = '!',
+ [VTY_TEST_ATTR_RAFC_AT] = '@',
+ },
};
const struct log_info_cat default_categories[] = {};
@@ -497,6 +622,12 @@ int main(int argc, char **argv)
};
void *stats_ctx;
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s CFG_PATH\n", argv[0]);
+ return 1;
+ }
+ cfg_path = argv[1];
+
ctx = talloc_named_const(NULL, 0, "stats test context");
stats_ctx = talloc_named_const(ctx, 1, "stats test context");
@@ -535,6 +666,9 @@ int main(int argc, char **argv)
test_is_cmd_ambiguous();
+ test_numeric_range();
+ test_ranges();
+
/* Leak check */
OSMO_ASSERT(talloc_total_blocks(stats_ctx) == 1);
diff --git a/tests/vty/vty_test.err b/tests/vty/vty_test.err
new file mode 100644
index 00000000..b021425d
--- /dev/null
+++ b/tests/vty/vty_test.err
@@ -0,0 +1,77 @@
+Found duplicate flag letter 'f' in application specific attributes (index 0 vs 3)! Please fix.
+Found duplicate flag letter 'z' in application specific attributes (index 2 vs 4)! Please fix.
+Attribute flag letter 'X' is reserved for libraries! Please fix.
+Attribute flag character '.' is reserved for globals! Please fix.
+Attribute flag character '!' is reserved for globals! Please fix.
+Attribute flag character '@' is reserved for globals! Please fix.
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 1
+Got VTY event: 3
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 1
+Got VTY event: 2
+Got VTY event: 3
+There is no such command.
+Error occurred during reading the below line:
+ level1 b
+
+Inconsistent indentation -- leading whitespace must match adjacent lines, and
+indentation must reflect child node levels. A mix of tabs and spaces is
+allowed, but their sequence must not change within a child block.
+Error occurred during reading the below line:
+ level1 b
+
+Inconsistent indentation -- leading whitespace must match adjacent lines, and
+indentation must reflect child node levels. A mix of tabs and spaces is
+allowed, but their sequence must not change within a child block.
+Error occurred during reading the below line:
+ child1 b
+
+Error occurred during reading the below line:
+return-warning
+
+% Ignoring deprecated 'logging level depr (debug|info|notice|error|fatal)'
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 1
+Got VTY event: 3
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 1
+Got VTY event: 3
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 2
+Got VTY event: 1
+Got VTY event: 3
diff --git a/tests/vty/vty_test.ok b/tests/vty/vty_test.ok
index d2c96111..e97fbfc4 100644
--- a/tests/vty/vty_test.ok
+++ b/tests/vty/vty_test.ok
@@ -311,4 +311,61 @@ Returned: 0, Current node: 1 '%s> '
Going to execute 'ambiguous_str arg keyword'
Called: 'ambiguous_str ARG keyword'
Returned: 0, Current node: 1 '%s> '
+Going to test test_numeric_range()
+Going to execute 'numeric-range 0'
+Called: 'return-success'
+Returned: 0, Current node: 1 '%s> '
+Going to execute 'numeric-range 40000'
+Called: 'return-success'
+Returned: 0, Current node: 1 '%s> '
+Going to execute 'numeric-range -400000'
+Returned: 2, Current node: 1 '%s> '
+Going to test test_ranges()
+test range-base10
+Going to execute 'range-base10 0'
+Called: 'return-success'
+Returned: 0, Current node: 1 '%s> '
+Going to execute 'range-base10 40000'
+Called: 'return-success'
+Returned: 0, Current node: 1 '%s> '
+Going to execute 'range-base10 -400000'
+Returned: 2, Current node: 1 '%s> '
+Going to execute 'range-base10 0x0'
+Returned: 2, Current node: 1 '%s> '
+Going to execute 'range-base10 0x343'
+Returned: 2, Current node: 1 '%s> '
+Going to execute 'range-base10 -0x343'
+Returned: 2, Current node: 1 '%s> '
+test range-base16
+Going to execute 'range-base16 0'
+Returned: 2, Current node: 1 '%s> '
+Going to execute 'range-base16 40000'
+Returned: 2, Current node: 1 '%s> '
+Going to execute 'range-base16 -400000'
+Returned: 2, Current node: 1 '%s> '
+Going to execute 'range-base16 0x0'
+Called: 'return-success'
+Returned: 0, Current node: 1 '%s> '
+Going to execute 'range-base16 0x343'
+Called: 'return-success'
+Returned: 0, Current node: 1 '%s> '
+Going to execute 'range-base16 -0x343'
+Returned: 2, Current node: 1 '%s> '
+test range-baseboth
+Going to execute 'range-baseboth 0'
+Called: 'return-success'
+Returned: 0, Current node: 1 '%s> '
+Going to execute 'range-baseboth 40000'
+Called: 'return-success'
+Returned: 0, Current node: 1 '%s> '
+Going to execute 'range-baseboth -400000'
+Returned: 2, Current node: 1 '%s> '
+Going to execute 'range-baseboth 0x0'
+Called: 'return-success'
+Returned: 0, Current node: 1 '%s> '
+Going to execute 'range-baseboth 0x343'
+Called: 'return-success'
+Returned: 0, Current node: 1 '%s> '
+Going to execute 'range-baseboth -0x343'
+Returned: 2, Current node: 1 '%s> '
All tests passed
diff --git a/tests/vty/vty_transcript_test.c b/tests/vty/vty_transcript_test.c
index 6651097e..5602c505 100644
--- a/tests/vty/vty_transcript_test.c
+++ b/tests/vty/vty_transcript_test.c
@@ -17,10 +17,6 @@
* 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, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define _GNU_SOURCE
@@ -41,7 +37,7 @@
void *root_ctx = NULL;
-static void print_help()
+static void print_help(void)
{
printf( "options:\n"
" -h --help this text\n"
@@ -142,9 +138,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 +207,205 @@ DEFUN(multi2, multi2_cmd,
return CMD_SUCCESS;
}
-static void init_vty_cmds()
+#define X(f) (1 << f)
+
+enum {
+ ATTR_TEST_NODE = _LAST_OSMOVTY_NODE + 1,
+ NEST_A_NODE,
+ NEST_B_NODE,
+ NEST_C_NODE,
+};
+
+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_DEPRECATED(cfg_attr_deprecated,
+ cfg_attr_deprecated_cmd,
+ "foo-deprecated",
+ "This command is deprecated\n")
+{
+ return CMD_WARNING;
+}
+
+DEFUN_HIDDEN(cfg_attr_hidden,
+ cfg_attr_hidden_cmd,
+ "foo-hidden [expert-mode]",
+ "This command is hidden\n"
+ "But can be seen in the expert mode\n")
+{
+ 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;
+}
+
+DEFUN_ATTR_USRATTR(cfg_attr_hidden_app_attr_unbelievable,
+ cfg_attr_hidden_app_attr_unbelievable_cmd,
+ CMD_ATTR_HIDDEN, X(TEST_ATTR_UNBELIEVABLE),
+ "app-hidden-unbelievable",
+ "Hidden, but still unbelievable help message\n")
+{
+ return CMD_SUCCESS;
+}
+
+static struct cmd_node nest_a_node = {
+ NEST_A_NODE,
+ "%s(config-a)# ",
+ 1
+};
+
+static struct cmd_node nest_b_node = {
+ NEST_B_NODE,
+ "%s(config-b)# ",
+ 1
+};
+
+static struct cmd_node nest_c_node = {
+ NEST_C_NODE,
+ "%s(config-c)# ",
+ 1
+};
+
+DEFUN(cfg_nest_a, cfg_nest_a_cmd,
+ "nest NAME",
+ "Enter nest level a\n"
+ "Set a name to mark the node's state\n")
+{
+ vty->index = talloc_strdup(root_ctx, argv[0]);
+ vty->node = NEST_A_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_nest_b, cfg_nest_b_cmd,
+ "nest NAME",
+ "Enter nest level b\n"
+ "Set a name to mark the node's state\n")
+{
+ vty->index = talloc_strdup(root_ctx, argv[0]);
+ vty->node = NEST_B_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_nest_c, cfg_nest_c_cmd,
+ "nest NAME",
+ "Enter nest level c\n"
+ "Set a name to mark the node's state\n")
+{
+ vty->index = talloc_strdup(root_ctx, argv[0]);
+ vty->node = NEST_C_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_nest_state, cfg_nest_state_cmd,
+ "state",
+ "Show this node's mark\n")
+{
+ vty_out(vty, "%s%s", (const char *)vty->index, VTY_NEWLINE);
+ return CMD_SUCCESS;
+}
+
+static void init_vty_cmds(void)
{
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_deprecated_cmd);
+ install_element(ATTR_TEST_NODE, &cfg_attr_hidden_cmd);
+ 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);
+ install_element(ATTR_TEST_NODE, &cfg_attr_hidden_app_attr_unbelievable_cmd);
+
+ install_element(CONFIG_NODE, &cfg_nest_a_cmd);
+ install_node(&nest_a_node, NULL);
+ install_element(NEST_A_NODE, &cfg_nest_b_cmd);
+ install_node(&nest_b_node, NULL);
+ install_element(NEST_B_NODE, &cfg_nest_c_cmd);
+ install_node(&nest_c_node, NULL);
+
+ install_element(NEST_A_NODE, &cfg_nest_state_cmd);
+ install_element(NEST_B_NODE, &cfg_nest_state_cmd);
+ install_element(NEST_C_NODE, &cfg_nest_state_cmd);
}
int main(int argc, char **argv)
@@ -217,7 +431,7 @@ int main(int argc, char **argv)
}
}
- rc = telnet_init_dynif(root_ctx, NULL, vty_get_bind_addr(), 42042);
+ rc = telnet_init_default(root_ctx, NULL, 42042);
if (rc < 0)
return 2;
diff --git a/tests/vty/vty_transcript_test.vty b/tests/vty/vty_transcript_test.vty
index db58830e..7df2a606 100644
--- a/tests/vty/vty_transcript_test.vty
+++ b/tests/vty/vty_transcript_test.vty
@@ -84,3 +84,126 @@ ok argc=1 one
vty_transcript_test> single0
ok argc=0
+
+vty_transcript_test> show vty-attributes
+ Global attributes:
+ ^ This command is hidden (check expert mode)
+ ! This command applies immediately
+ @ This command applies on VTY node exit
+ Library specific attributes:
+ A This command applies on ASP restart
+ I This command applies on IPA link establishment
+ L This command applies on E1 line update
+ 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-(hidden|deprecated)
+ foo-immediate
+ foo-node-exit
+ app-unbelievable
+ app-magnificent
+ app-wonderful
+ app-unbelievable-magnificent
+ app-unbelievable-wonderful
+... !app-hidden-*
+
+vty_transcript_test(config-attr-test)# list with-flags
+... !foo-(hidden|deprecated)
+ ! ... foo-immediate
+ @ ... foo-node-exit
+ . u.. app-unbelievable
+ . .m. app-magnificent
+ . ..w app-wonderful
+ . um. app-unbelievable-magnificent
+ . u.w app-unbelievable-wonderful
+... !app-hidden-*
+
+vty_transcript_test(config-attr-test)# foo-deprecated?
+% There is no matched command.
+vty_transcript_test(config-attr-test)# foo-hidden?
+% There is no matched command.
+vty_transcript_test(config-attr-test)# app-hidden-unbelievable?
+% There is no matched command.
+
+vty_transcript_test(config-attr-test)# end
+vty_transcript_test# disable
+
+vty_transcript_test> enable?
+ enable Turn on privileged mode command
+vty_transcript_test> enable ?
+ [expert-mode] Enable the expert mode (show hidden commands)
+
+vty_transcript_test> enable expert-mode
+vty_transcript_test# configure terminal
+vty_transcript_test(config)# attribute-test
+
+vty_transcript_test(config-attr-test)# list
+... !foo-deprected
+ foo-hidden [expert-mode]
+ foo-immediate
+ foo-node-exit
+ app-unbelievable
+ app-magnificent
+ app-wonderful
+ app-unbelievable-magnificent
+ app-unbelievable-wonderful
+ app-hidden-unbelievable
+
+vty_transcript_test(config-attr-test)# list with-flags
+... !foo-deprected
+ ^ ... foo-hidden [expert-mode]
+ ! ... foo-immediate
+ @ ... foo-node-exit
+ . u.. app-unbelievable
+ . .m. app-magnificent
+ . ..w app-wonderful
+ . um. app-unbelievable-magnificent
+ . u.w app-unbelievable-wonderful
+ ^ u.. app-hidden-unbelievable
+
+vty_transcript_test(config-attr-test)# foo-deprecated?
+% There is no matched command.
+vty_transcript_test(config-attr-test)# foo-hidden?
+ foo-hidden This command is hidden
+vty_transcript_test(config-attr-test)# foo-hidden ?
+ [expert-mode] But can be seen in the expert mode
+vty_transcript_test(config-attr-test)# app-hidden-unbelievable?
+ app-hidden-unbelievable Hidden, but still unbelievable help message
+
+vty_transcript_test(config-attr-test)# exit
+
+vty_transcript_test(config)# nest A
+vty_transcript_test(config-a)# state
+A
+vty_transcript_test(config-a)# nest B
+vty_transcript_test(config-b)# state
+B
+vty_transcript_test(config-b)# nest C
+vty_transcript_test(config-c)# state
+C
+vty_transcript_test(config-c)# exit
+vty_transcript_test(config-b)# state
+B
+vty_transcript_test(config-b)# exit
+vty_transcript_test(config-a)# state
+A
+vty_transcript_test(config-a)# nest B2
+vty_transcript_test(config-b)# state
+B2
+vty_transcript_test(config-b)# nest C2
+vty_transcript_test(config-c)# state
+C2
+vty_transcript_test(config-c)# exit
+vty_transcript_test(config-b)# state
+B2
+vty_transcript_test(config-b)# exit
+vty_transcript_test(config-a)# state
+A