From b98a9439f9095e18fd38db466f1e89fb64e7aca0 Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Thu, 21 Dec 2017 15:28:56 -0500 Subject: [PATCH] Fix validate_trace_empty test check MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- tests/utils/utils.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index e8dfcda3c..d8c8a1fed 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -1498,7 +1498,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 -- 2.34.1