Fix validate_trace_empty test check
authorJulien Desfossez <jdesfossez@efficios.com>
Thu, 21 Dec 2017 20:28:56 +0000 (15:28 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 3 Apr 2018 16:12:28 +0000 (12:12 -0400)
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 <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/utils/utils.sh

index ab04979827529a85bcd0864718866eeccc2c3b86..9980e8538a124006a035403ef423fbe9c9c453ae 100644 (file)
@@ -1511,7 +1511,14 @@ function validate_trace_empty()
            skip 0 "Babeltrace binary not found. Skipping trace validation"
        fi
 
            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
        if [ "$traced" -eq 0 ]; then
                pass "Validate empty trace"
        else
This page took 0.02874 seconds and 5 git commands to generate.