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)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 5 Jun 2019 17:47:34 +0000 (13:47 -0400)
commitb4c499ed5193e3cb2ef1fcd290e90a3667c6230a
tree3d9ec6e77ba0ae524f6ab79093c82744fb75fac3
parent907f2b70dce96396c5b5b0e2111539664d1a2c44
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.024896 seconds and 4 git commands to generate.