diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2019-11-21 00:19:36 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2019-11-21 10:48:02 +0700 |
commit | 4abda9ea26403e24b2d91b83a1e4c81f5fb4b003 (patch) | |
tree | 8a62e78b7a99b884f1b9ffeaf5f52375a2fa0bdb /tests/vty | |
parent | 75c242e6a265b00e48fd3224e0af90025106caa7 (diff) |
logging/vty: fix: actually ignore deprecated logging commands
We shall not prevent programs from starting if their configuration
files contain deprecated 'logging level ...' commands. Just print
a warning and return CMD_SUCCESS instead of CMD_WARNING.
While writing a unit test, another funny bug has been uncovered.
Parsing of a deprecated command indeed triggers a deprecation
warning, originated from libosmovty's log_deprecated_func().
This function simply calls vty_out(), but...
Since the invocation of the vty_out() happens _before_ the VTY
is initialized, the process is actually writing that warning
to its own stdin! Most likely, because we use talloc_zero()
to allocate a new instance of struct 'vty'.
As a side effect, the evil warning magically appears in the output
of 'make check', breaking the test statistics. Let's work around
this bug for now by redirecting stdin to /dev/null.
Change-Id: Ia934581410cd41594791d4e14ee74c16abe1009a
Fixes: Ic9c1b566ec4a459f03e6319cf369691903cf9d00
Diffstat (limited to 'tests/vty')
-rw-r--r-- | tests/vty/ok_deprecated_logging.cfg | 3 | ||||
-rw-r--r-- | tests/vty/vty_test.c | 4 | ||||
-rw-r--r-- | tests/vty/vty_test.ok | 2 |
3 files changed, 9 insertions, 0 deletions
diff --git a/tests/vty/ok_deprecated_logging.cfg b/tests/vty/ok_deprecated_logging.cfg new file mode 100644 index 00000000..2699719e --- /dev/null +++ b/tests/vty/ok_deprecated_logging.cfg @@ -0,0 +1,3 @@ +log stderr + logging filter all 1 + logging level depr debug diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c index 0d68a6c0..1139638d 100644 --- a/tests/vty/vty_test.c +++ b/tests/vty/vty_test.c @@ -29,6 +29,7 @@ #include <osmocom/core/application.h> #include <osmocom/core/talloc.h> +#include <osmocom/core/logging_internal.h> #include <osmocom/core/logging.h> #include <osmocom/core/stats.h> #include <osmocom/core/utils.h> @@ -442,6 +443,8 @@ void test_vty_add_cmds() install_element(CONFIG_NODE, &cfg_ret_warning_cmd); install_element(CONFIG_NODE, &cfg_ret_success_cmd); + logging_vty_add_deprecated_subsys(tall_log_ctx, "depr"); + install_element(CONFIG_NODE, &cfg_level1_cmd); install_node(&level1_node, NULL); install_element(LEVEL1_NODE, &cfg_level1_child_cmd); @@ -544,6 +547,7 @@ int main(int argc, char **argv) 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_exit_by_indent("ok_deprecated_logging.cfg", 0); test_is_cmd_ambiguous(); diff --git a/tests/vty/vty_test.ok b/tests/vty/vty_test.ok index 0b5ac9c0..d2c96111 100644 --- a/tests/vty/vty_test.ok +++ b/tests/vty/vty_test.ok @@ -290,6 +290,8 @@ reading file fail_cmd_ret_warning.cfg, expecting rc=-22 Called: 'return-success' Called: 'return-warning' got rc=-22 +reading file ok_deprecated_logging.cfg, expecting rc=0 +got rc=0 Going to test is_cmd_ambiguous() Going to execute 'ambiguous_nr' Called: 'ambiguous_nr [<0-23>]' (argc=0) |