diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-10-22 18:38:01 +0200 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2019-10-28 19:15:29 +0000 |
commit | a0c8195ad37292ab800a6c777fc28383995b4b64 (patch) | |
tree | 039f73a1546dfd238af4f89aef66789e0742eaf5 /tests/vty/vty_test.c | |
parent | ea2afb21d69f5227263f6b227edcb1e9cc5b0e54 (diff) |
vty: Return error if cmd returns CMD_WARNING while reading cfg file
Otherwise bad configurations can easily sneak in and produce unexpected
behavior.
Change-Id: Ic9c1b566ec4a459f03e6319cf369691903cf9d00
Diffstat (limited to 'tests/vty/vty_test.c')
-rw-r--r-- | tests/vty/vty_test.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c index 30efb9af..0d68a6c0 100644 --- a/tests/vty/vty_test.c +++ b/tests/vty/vty_test.c @@ -421,8 +421,27 @@ DEFUN(cfg_ambiguous_str_2, cfg_ambiguous_str_2_cmd, return CMD_SUCCESS; } +DEFUN(cfg_ret_success, cfg_ret_success_cmd, + "return-success", + "testing return success\n") +{ + printf("Called: 'return-success'\n"); + return CMD_SUCCESS; +} + +DEFUN(cfg_ret_warning, cfg_ret_warning_cmd, + "return-warning", + "testing return warning\n") +{ + printf("Called: 'return-warning'\n"); + return CMD_WARNING; +} + void test_vty_add_cmds() { + install_element(CONFIG_NODE, &cfg_ret_warning_cmd); + install_element(CONFIG_NODE, &cfg_ret_success_cmd); + install_element(CONFIG_NODE, &cfg_level1_cmd); install_node(&level1_node, NULL); install_element(LEVEL1_NODE, &cfg_level1_child_cmd); @@ -524,6 +543,7 @@ int main(int argc, char **argv) test_exit_by_indent("fail_tabs_and_spaces.cfg", -EINVAL); test_exit_by_indent("ok_indented_root.cfg", 0); test_exit_by_indent("ok_empty_parent.cfg", 0); + test_exit_by_indent("fail_cmd_ret_warning.cfg", -EINVAL); test_is_cmd_ambiguous(); |