Test: rework shell test scripts
[babeltrace.git] / tests / cli / test_trimmer.in
index 43184630f9018a5c5d1aece03c768e575dd0a206..9303cdf76049ac00ffa9e9ea50e42a7e025cb90b 100644 (file)
 # this program; if not, write to the Free Software Foundation, Inc., 51
 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-BABELTRACE_BIN=@abs_top_builddir@/cli/babeltrace
+. "@abs_top_srcdir@/tests/utils/common.sh"
 
-TRACE_PATH=@abs_top_srcdir@/tests/ctf-traces/succeed/wk-heartbeat-u/
-
-source @abs_top_srcdir@/tests/utils/tap/tap.sh
+TRACE_PATH="${BT_CTF_TRACES}/succeed/wk-heartbeat-u/"
 
 NUM_TESTS=10
 
@@ -27,42 +25,42 @@ plan_tests $NUM_TESTS
 
 tmp_out=$(mktemp)
 
-$BABELTRACE_BIN --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018 \
-       ${TRACE_PATH} >/dev/null 2>&1
+"${BT_BIN}" --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018 \
+       "${TRACE_PATH}" >/dev/null 2>&1
 ok $? "Read the trace with the trimmer enabled"
 
-$BABELTRACE_BIN --clock-gmt --begin 17:48:17.587029529 ${TRACE_PATH} \
-       2>/dev/null >${tmp_out}
+"${BT_BIN}" --clock-gmt --begin 17:48:17.587029529 "${TRACE_PATH}" \
+       2>/dev/null >"${tmp_out}"
 ok $? "Running with --begin"
-cnt=$(cat ${tmp_out} | wc -l)
-test $cnt == 18
+cnt=$(wc -l < "${tmp_out}")
+test "$cnt" == 18
 ok $? "Expected number of events after trimming begin and end"
 
-$BABELTRACE_BIN --clock-gmt --end 17:48:17.588680018 ${TRACE_PATH} \
-       2>/dev/null >${tmp_out}
+"${BT_BIN}" --clock-gmt --end 17:48:17.588680018 "${TRACE_PATH}" \
+       2>/dev/null >"${tmp_out}"
 ok $? "Running with --end"
-cnt=$(cat ${tmp_out} | wc -l)
-test $cnt == 9
+cnt=$(wc -l < "${tmp_out}")
+test "$cnt" == 9
 ok $? "Expected number of events after trimming end"
 
-$BABELTRACE_BIN --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018 \
-       ${TRACE_PATH} 2>/dev/null >${tmp_out}
+"${BT_BIN}" --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018 \
+       "${TRACE_PATH}" 2>/dev/null >"${tmp_out}"
 ok $? "Running with --begin and --end"
-cnt=$(cat ${tmp_out} | wc -l)
-test $cnt == 7
+cnt=$(wc -l < "${tmp_out}")
+test "$cnt" == 7
 ok $? "Expected number of events after trimming begin and end"
 
-$BABELTRACE_BIN --clock-gmt --begin 18:48:17.587029529 ${TRACE_PATH} \
-       2>/dev/null >${tmp_out}
+"${BT_BIN}" --clock-gmt --begin 18:48:17.587029529 "${TRACE_PATH}" \
+       2>/dev/null >"${tmp_out}"
 ok $? "Running with --begin out of range"
-cnt=$(cat ${tmp_out} | wc -l)
-test $cnt == 0
+cnt=$(wc -l < "${tmp_out}")
+test "$cnt" == 0
 ok $? "No event output when begin is after the end of the trace"
 
-$BABELTRACE_BIN --clock-gmt --end 16:48:17.588680018 ${TRACE_PATH} \
-       2>/dev/null >${tmp_out}
-cnt=$(cat ${tmp_out} | wc -l)
-test $cnt == 0
+"${BT_BIN}" --clock-gmt --end 16:48:17.588680018 "${TRACE_PATH}" \
+       2>/dev/null >"${tmp_out}"
+cnt=$(wc -l < "${tmp_out}")
+test "$cnt" == 0
 ok $? "No event output when end is before the beginning of the trace"
 
-rm ${tmp_out}
+rm "${tmp_out}"
This page took 0.025398 seconds and 4 git commands to generate.