cli: Fix exit code of ctf-metadata output
When the command
babeltrace -o ctf-metadata <trace>
is successful, it exits with exit code 1. On success, we would expect
it to return 0.
The issue is that when cmd_print_ctf_metadata exits, ret is filled with
the number of bytes returned with fprintf, which is non-zero. This is then translated to a 1 in main.
If the fprintf is successful, we should set ret to 0 to indicate that
the function has completed successfully.
If the fprintf fails, we should go the the end and avoid setting ret to
0 (the fprintf return value will be passed to the caller).
Add a test to verify the exit code and output of babeltrace when using
-o ctf-metadata.
Change-Id: I64372bce66822ba570a85cd69a32d582ebd3c727
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1332
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
This page took 0.030621 seconds and 4 git commands to generate.