cli: Fix exit code of ctf-metadata output
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 23 May 2019 22:16:21 +0000 (18:16 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 13 Jun 2019 21:24:21 +0000 (17:24 -0400)
commit1ec75dfadc5f83114aa3eb9938555d30d09b9175
treecdea2fcb42637ded484a1e4484356e4542c7de2e
parentda35796cbd9965974905a87d0abf15452be39781
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>
cli/babeltrace.c
configure.ac
tests/cli/test_output_ctf_metadata.in [new file with mode: 0644]
tests/cli/test_output_ctf_metadata.ref [new file with mode: 0644]
This page took 0.02547 seconds and 4 git commands to generate.