From: Julien Desfossez Date: Thu, 21 Dec 2017 20:28:56 +0000 (-0500) Subject: Fix validate_trace_empty test check X-Git-Tag: v2.9.9~8 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ef2117d4b988197f140083fafd95c84ff2c3f23f;p=lttng-tools.git Fix validate_trace_empty test check Since the output of babeltrace was directly piped into wc, the return code was never an error even if the trace was invalid. We now split the commands in two parts: process the trace with babeltrace and check the error code, and then count the number of lines. Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 9db0640b7..89aca4640 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -1401,7 +1401,14 @@ function validate_trace_empty() skip 0 "Babeltrace binary not found. Skipping trace validation" fi - traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | wc -l) + events=$($BABELTRACE_BIN $trace_path 2>/dev/null) + ret=$? + if [ $ret -ne 0 ]; then + fail "Failed to parse trace" + return $ret + fi + + traced=$(echo -n "$events" | wc -l) if [ "$traced" -eq 0 ]; then pass "Validate empty trace" else