Fix: cli: don't log error when using help command with a plugin name
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 26 Sep 2019 15:28:51 +0000 (11:28 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 3 Oct 2019 14:45:11 +0000 (10:45 -0400)
commit810e5642d562b9da8e0dddac303850eee0ae317d
tree3717ad2dc5ebae8fdbc82bec84c74fc486c5169d
parentb24c604a47b13a1367a5a0e8571e120ad1290052
Fix: cli: don't log error when using help command with a plugin name

When using the help command with a plugin name, it works, but Babeltrace
logs an error:

    09-26 16:37:03.782 10054 10054 E CLI/CFG-CLI-ARGS plugin_comp_cls_names@babeltrace2-cfg-cli-args.c:189 Missing component class type (`source`, `filter`, or `sink`).

This is problematic, because this is a valid use of the command.
Logging an error is unnecessarily alarming.

The current code takes the argument (in our case, a plugin name such as
"ctf") and passes it through plugin_comp_cls_names.  The function can't
parse the string as a component class name, so logs the error mentioned
above.  The caller, bt_config_help_from_args, sees that the function has
failed, so falls back to assuming the string is a plugin name, which
then works correctly.

To avoid this, the sophisticated solution I chose was to look for an
unescaped dot in the argument.  If there's one, we treat it as a
component class name, if there isn't, we treat is as a plugin name.

Change-Id: I76b791e5d44436fdc5b10a3c10e3579a0783b04d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2101
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/cli/babeltrace2-cfg-cli-args.c
tests/Makefile.am
tests/cli/test_help [new file with mode: 0755]
This page took 0.024689 seconds and 4 git commands to generate.