From: Michael Jeanson Date: Wed, 16 Aug 2017 19:06:19 +0000 (-0400) Subject: Test: rework shell test scripts X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=03f007c88338aad6a1d1f30a757401e0093fa23f Test: rework shell test scripts Moved common code to common.sh and lots of shellcheck syntax fixes and cleanup. Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- diff --git a/.gitignore b/.gitignore index bd7be883..0b781cac 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ /tests/plugins/test_bin_info /tests/plugins/test_dwarf_complete /tests/plugins/test_dwarf +/tests/utils/common.sh *.o *.a *.la diff --git a/configure.ac b/configure.ac index d5b2075f..ba95ac15 100644 --- a/configure.ac +++ b/configure.ac @@ -683,6 +683,7 @@ AC_CONFIG_FILES([ tests/lib/Makefile tests/lib/writer/Makefile tests/lib/test-plugin-plugins/Makefile + tests/utils/common.sh tests/utils/Makefile tests/utils/tap/Makefile tests/bindings/Makefile @@ -734,7 +735,7 @@ AC_CONFIG_FILES([tests/plugins/test_dwarf_complete], [chmod +x tests/plugins/tes AC_CONFIG_FILES([tests/plugins/test_bin_info_complete], [chmod +x tests/plugins/test_bin_info_complete]) AS_IF([test "x$enable_python_bindings_tests" = xyes], - [AC_CONFIG_FILES([tests/bindings/python/bt2/testall.sh], [chmod +x tests/bindings/python/bt2/testall.sh])] + [AC_CONFIG_FILES([tests/bindings/python/bt2/test_python_bt2], [chmod +x tests/bindings/python/bt2/test_python_bt2])] ) AS_IF([test "x$enable_python_plugins" = "xyes"], diff --git a/tests/bindings/python/bt2/.gitignore b/tests/bindings/python/bt2/.gitignore index e86dc596..d9d5f8ec 100644 --- a/tests/bindings/python/bt2/.gitignore +++ b/tests/bindings/python/bt2/.gitignore @@ -1,3 +1,3 @@ htmlcov .coverage -testall.sh +test_python_bt2 diff --git a/tests/bindings/python/bt2/Makefile.am b/tests/bindings/python/bt2/Makefile.am index a31d9be8..aad80c0c 100644 --- a/tests/bindings/python/bt2/Makefile.am +++ b/tests/bindings/python/bt2/Makefile.am @@ -1,6 +1,4 @@ -check_SCRIPTS = testall.sh EXTRA_DIST = \ - $(check_SCRIPTS) \ test_clock_class.py \ test_clock_class_priority_map.py \ test_component.py \ @@ -27,5 +25,5 @@ LOG_DRIVER_FLAGS='--merge' LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/config/tap-driver.sh if ENABLE_PYTHON_BINDINGS -TESTS = testall.sh +TESTS = test_python_bt2 endif diff --git a/tests/bindings/python/bt2/test_python_bt2.in b/tests/bindings/python/bt2/test_python_bt2.in new file mode 100644 index 00000000..d32cb01d --- /dev/null +++ b/tests/bindings/python/bt2/test_python_bt2.in @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Copyright (C) 2017 - Philippe Proulx +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; only version 2 +# of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +NO_SH_TAP=1 +. "@abs_top_builddir@/tests/utils/common.sh" + +check_coverage() { + coverage run "$@" +} + +export BABELTRACE_PYTHON_BT2_NO_TRACEBACK=1 +export TEST_PLUGIN_PLUGINS_PATH="${BT_BUILD_PATH}/plugins" +export BABELTRACE_PLUGIN_PATH="${BT_BUILD_PATH}/plugins/ctf:${BT_BUILD_PATH}/plugins/utils:${BT_BUILD_PATH}/plugins/text" +PYTHON_BUILD_DIR="${BT_BUILD_PATH}/bindings/python" +BT2_NATIVE_LIBS_DIR="${BT_BUILD_PATH}/bindings/python/bt2/.libs" +TESTS_UTILS_PYTHON_DIR="${BT_SRC_PATH}/tests/utils/python" +TESTRUNNER_PY="${BT_SRC_PATH}/tests/utils/python/testrunner.py" +THIS_DIR="${BT_SRC_PATH}/tests/bindings/python/bt2" + +if test "x$TESTALL_COVERAGE" = "x1"; then + EXEC=check_coverage +else + EXEC="@PYTHON@" + +fi + +PYTHONPATH="$PYTHON_BUILD_DIR:$BT2_NATIVE_LIBS_DIR:$TESTS_UTILS_PYTHON_DIR" \ + "$EXEC" "$TESTRUNNER_PY" "$THIS_DIR" +res=$? + +if test "x$TESTALL_COVERAGE_REPORT" = "x1"; then + coverage report -m +fi + +if test "x$TESTALL_COVERAGE_HTML" = "x1"; then + coverage html +fi + +exit $res diff --git a/tests/bindings/python/bt2/testall.sh.in b/tests/bindings/python/bt2/testall.sh.in deleted file mode 100644 index d682e4c8..00000000 --- a/tests/bindings/python/bt2/testall.sh.in +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -check_coverage() { - coverage run $@ -} - -export BABELTRACE_PYTHON_BT2_NO_TRACEBACK=1 -export TEST_PLUGIN_PLUGINS_PATH="@abs_top_builddir@/plugins" -export BABELTRACE_PLUGIN_PATH="@abs_top_builddir@/plugins/ctf:@abs_top_builddir@/plugins/utils:@abs_top_builddir@/plugins/text" -PYTHON_BUILD_DIR="@abs_top_builddir@/bindings/python" -BT2_NATIVE_LIBS_DIR="@abs_top_builddir@/bindings/python/bt2/.libs" -TESTS_UTILS_PYTHON_DIR="@abs_top_srcdir@/tests/utils/python" -TESTRUNNER_PY="@abs_top_srcdir@/tests/utils/python/testrunner.py" -THIS_DIR="@abs_top_srcdir@/tests/bindings/python/bt2" - -if test "x$TESTALL_COVERAGE" = "x1"; then - EXEC=check_coverage -else - EXEC="@PYTHON@" - -fi - -PYTHONPATH="$PYTHON_BUILD_DIR:$BT2_NATIVE_LIBS_DIR:$TESTS_UTILS_PYTHON_DIR" \ - "$EXEC" "$TESTRUNNER_PY" "$THIS_DIR" -res=$? - -if test "x$TESTALL_COVERAGE_REPORT" = "x1"; then - coverage report -m -fi - -if test "x$TESTALL_COVERAGE_HTML" = "x1"; then - coverage html -fi - -exit $res diff --git a/tests/cli/intersection/test_intersection.in b/tests/cli/intersection/test_intersection.in index d70367f2..07a267fe 100644 --- a/tests/cli/intersection/test_intersection.in +++ b/tests/cli/intersection/test_intersection.in @@ -15,41 +15,36 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -TESTDIR=@abs_top_srcdir@/tests - -BABELTRACE_BIN=@abs_top_builddir@/cli/babeltrace -CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces - -source $TESTDIR/utils/tap/tap.sh +. "@abs_top_builddir@/tests/utils/common.sh" NUM_TESTS=10 plan_tests $NUM_TESTS test_intersect() { - trace=$1 - totalevents=$2 - intersect=$3 + trace="$1" + totalevents="$2" + intersect="$3" - test $($BABELTRACE_BIN $trace | wc -l) = $totalevents + test "$("${BT_BIN}" "$trace" | wc -l)" = "$totalevents" ok $? "$totalevents events in the whole trace" - test $($BABELTRACE_BIN --stream-intersection $trace 2>/dev/null| wc -l) = $intersect + test "$("${BT_BIN}" --stream-intersection "$trace" 2>/dev/null| wc -l)" = "$intersect" ok $? "$intersect events in packets intersecting" } diag "Test the stream intersection feature" diag "2 streams offsetted with 3 packets intersecting" -test_intersect ${CTF_TRACES}/intersection/3eventsintersect 8 3 +test_intersect "${BT_CTF_TRACES}/intersection/3eventsintersect" 8 3 diag "2 streams offsetted with 3 packets intersecting (exchanged file names)" -test_intersect ${CTF_TRACES}/intersection/3eventsintersectreverse 8 3 +test_intersect "${BT_CTF_TRACES}/intersection/3eventsintersectreverse" 8 3 diag "No intersection between 2 streams" -test_intersect ${CTF_TRACES}/intersection/nointersect 6 0 +test_intersect "${BT_CTF_TRACES}/intersection/nointersect" 6 0 diag "Only 1 stream" -test_intersect ${CTF_TRACES}/intersection/onestream 3 3 +test_intersect "${BT_CTF_TRACES}/intersection/onestream" 3 3 diag "No stream at all" -test_intersect ${CTF_TRACES}/intersection/nostream 0 0 +test_intersect "${BT_CTF_TRACES}/intersection/nostream" 0 0 diff --git a/tests/cli/test_convert_args.in b/tests/cli/test_convert_args.in index 875f10e6..123d1a49 100644 --- a/tests/cli/test_convert_args.in +++ b/tests/cli/test_convert_args.in @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # # Copyright (C) - 2017 Philippe Proulx # @@ -15,11 +15,7 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -curdir="$(dirname $0)" -testdir="$curdir/.." -babeltrace_bin="$curdir/../../cli/babeltrace" - -source $testdir/utils/tap/tap.sh +. "@abs_top_builddir@/tests/utils/common.sh" test_bt_convert_run_args() { local what="$1" @@ -27,14 +23,14 @@ test_bt_convert_run_args() { local expected_run_args="$3" # execute convert command - local run_args="$("$babeltrace_bin" convert --run-args $convert_args)" + local run_args="$("$BT_BIN" convert --run-args $convert_args)" # check result if [ "$test_head_comment" = 1 ]; then comment "convert args: $convert_args" fi - if [ "$run_args" == "$expected_run_args" ]; then + if [ "$run_args" = "$expected_run_args" ]; then pass "ARGS: $what" else fail "ARGS: $what" @@ -49,7 +45,7 @@ test_bt_convert_fails() { local convert_args="$2" # execute convert command - "$babeltrace_bin" convert --run-args $convert_args &> /dev/null + "$BT_BIN" convert --run-args $convert_args >/dev/null 2>&1 local status=$? @@ -58,7 +54,7 @@ test_bt_convert_fails() { comment "convert args: $convert_args" fi - if [ $status == 0 ]; then + if [ "$status" = 0 ]; then fail "SUCCEEDS (should fail): $what" diag "ARGS: $convert_args" else diff --git a/tests/cli/test_debug_info.in b/tests/cli/test_debug_info.in index 0d34e14d..e0c9204c 100644 --- a/tests/cli/test_debug_info.in +++ b/tests/cli/test_debug_info.in @@ -15,20 +15,14 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -CURDIR=$(dirname $0) -TESTDIR=$CURDIR/.. +. "@abs_top_builddir@/tests/utils/common.sh" -BABELTRACE_BIN=@abs_top_builddir@/cli/babeltrace - -BT_TREE_PATH=@abs_top_srcdir@/ -DEBUG_INFO_TRACE=${BT_TREE_PATH}/tests/debug-info-data/trace/ - -source $TESTDIR/utils/tap/tap.sh +DEBUG_INFO_TRACE="${BT_SRC_PATH}/tests/debug-info-data/trace/" NUM_TESTS=1 plan_tests $NUM_TESTS -$BABELTRACE_BIN --debug-info-target-prefix ${BT_TREE_PATH} ${DEBUG_INFO_TRACE} 2>/dev/null \ +"${BT_BIN}" --debug-info-target-prefix "${BT_SRC_PATH}" "${DEBUG_INFO_TRACE}" 2>/dev/null \ | @GREP@ 'debug_info = { bin = "libhello_so+0x15a6", func = "bar+0xa9", src = "libhello.c:13" }' >/dev/null ok $? "Extract debug information" diff --git a/tests/cli/test_formats.in b/tests/cli/test_formats.in deleted file mode 100644 index 4bd32ea0..00000000 --- a/tests/cli/test_formats.in +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2016 Nathan Lynch -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License, version 2 only, as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -CURDIR=$(dirname $0) -TESTDIR=$CURDIR/.. - -BABELTRACE_BIN=$CURDIR/../../cli/babeltrace - -source $TESTDIR/utils/tap/tap.sh - -expected_formats=(text lttng-live dummy ctf-metadata ctf) - -plan_tests ${#expected_formats[*]} - -for format in "${expected_formats[@]}"; do - "$BABELTRACE_BIN" --list | @GREP@ -qw "$format" - ok $? "Detect support for format \"$format\"" -done diff --git a/tests/cli/test_packet_seq_num.in b/tests/cli/test_packet_seq_num.in index b9e62057..9210abf7 100644 --- a/tests/cli/test_packet_seq_num.in +++ b/tests/cli/test_packet_seq_num.in @@ -15,13 +15,7 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -CURDIR=$(dirname $0) -TESTDIR=$CURDIR/.. - -BABELTRACE_BIN=$CURDIR/../../cli/babeltrace -CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces - -source $TESTDIR/utils/tap/tap.sh +. "@abs_top_builddir@/tests/utils/common.sh" NUM_TESTS=10 @@ -30,9 +24,9 @@ plan_tests $NUM_TESTS test_no_lost() { trace=$1 - $BABELTRACE_BIN $trace >/dev/null 2>&1 + "${BT_BIN}" "$trace" >/dev/null 2>&1 ok $? "Trace parses" - $BABELTRACE_BIN $trace 2>&1 >/dev/null | @GREP@ "\[warning\] Tracer lost" + "${BT_BIN}" "$trace" 2>&1 >/dev/null | @GREP@ "\[warning\] Tracer lost" if test $? = 0; then fail 1 "Should not find any lost events" else @@ -44,14 +38,14 @@ test_lost() { trace=$1 expectedcountstr=$2 - $BABELTRACE_BIN $trace >/dev/null 2>&1 + "${BT_BIN}" "$trace" >/dev/null 2>&1 ok $? "Trace parses" # Convert warnings like: # WARNING: Tracer discarded 2 trace packets between .... # WARNING: Tracer discarded 3 trace packets between .... # into "2,3" and make sure it matches the expected result - $BABELTRACE_BIN $trace 2>&1 >/dev/null | @GREP@ "WARNING: Tracer discarded" \ + "${BT_BIN}" "$trace" 2>&1 >/dev/null | @GREP@ "WARNING: Tracer discarded" \ | cut -d" " -f4 | tr "\n" "," | @SED@ "s/.$//" | \ @GREP@ "$expectedcountstr" >/dev/null ok $? "Lost events string matches $expectedcountstr" @@ -61,16 +55,16 @@ test_lost() { diag "Test the packet_seq_num validation" diag "No packet lost" -test_no_lost ${CTF_TRACES}/packet_seq_num/no_lost +test_no_lost "${BT_CTF_TRACES}/packet_seq_num/no_lost" diag "No packet lost, packet_seq_num not starting at 0" -test_no_lost ${CTF_TRACES}/packet_seq_num/no_lost_not_starting_at_0 +test_no_lost "${BT_CTF_TRACES}/packet_seq_num/no_lost_not_starting_at_0" diag "1 stream, 2 packets lost before the last packet" -test_lost ${CTF_TRACES}/packet_seq_num/2_lost_before_last "2" +test_lost "${BT_CTF_TRACES}/packet_seq_num/2_lost_before_last" "2" diag "2 streams, packets lost in one of them" -test_lost ${CTF_TRACES}/packet_seq_num/2_streams_lost_in_1 "2" +test_lost "${BT_CTF_TRACES}/packet_seq_num/2_streams_lost_in_1" "2" diag "2 streams, packets lost in both" -test_lost ${CTF_TRACES}/packet_seq_num/2_streams_lost_in_2 "3,2,1" +test_lost "${BT_CTF_TRACES}/packet_seq_num/2_streams_lost_in_2" "3,2,1" diff --git a/tests/cli/test_trace_copy.in b/tests/cli/test_trace_copy.in index 36297bfc..48ccf79e 100644 --- a/tests/cli/test_trace_copy.in +++ b/tests/cli/test_trace_copy.in @@ -15,47 +15,43 @@ # 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" -CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces - -source @abs_top_srcdir@/tests/utils/tap/tap.sh - -SUCCESS_TRACES=(${CTF_TRACES}/succeed/*) -FAIL_TRACES=(${CTF_TRACES}/fail/*) +SUCCESS_TRACES=(${BT_CTF_TRACES}/succeed/*) # -2 because there is an empty trace that we skip NUM_TESTS=$((${#SUCCESS_TRACES[@]} * 3 - 2)) plan_tests $NUM_TESTS -for path in ${SUCCESS_TRACES[@]}; do - out_path=$(mktemp -d) - text_output1=$(mktemp) - text_output2=$(mktemp) - trace=$(basename ${path}) - - $BABELTRACE_BIN ${path} 2>/dev/null >${text_output1} - cnt=$(cat ${text_output1} | wc -l) - if test $cnt == 0; then - ok 0 "Empty trace, nothing to copy" +for path in "${SUCCESS_TRACES[@]}"; do + out_path="$(mktemp -d)" + text_output1="$(mktemp)" + text_output2="$(mktemp)" + trace="$(basename "${path}")" + + "${BT_BIN}" "${path}" 2>/dev/null >"${text_output1}" + ret=$? + cnt="$(wc -l < "${text_output1}")" + if test "$ret" == 0 && test "$cnt" == 0; then + pass "Empty trace, nothing to copy" continue fi - $BABELTRACE_BIN ${path} --component sink.ctf.fs --path ${out_path} >/dev/null 2>&1 + "${BT_BIN}" "${path}" --component sink.ctf.fs --path "${out_path}" >/dev/null 2>&1 ok $? "Copy trace ${trace} with ctf-fs sink" - $BABELTRACE_BIN ${out_path} >/dev/null 2>&1 + "${BT_BIN}" "${out_path}" >/dev/null 2>&1 if test $? != 0; then fail "Read the new trace in ${out_path}" continue fi - ok 0 "Read the new trace in ${out_path}" + pass "Read the new trace in ${out_path}" - $BABELTRACE_BIN ${out_path} 2>/dev/null >${text_output2} - cnt=$(diff ${text_output1} ${text_output2} | wc -l) - test $? == 0 + "${BT_BIN}" "${out_path}" 2>/dev/null >"${text_output2}" + cnt=$(diff "${text_output1}" "${text_output2}" | wc -l) + test "$cnt" == 0 ok $? "Exact same content between the two traces" - rm -rf ${out_path} ${text_output} ${text_output2} + rm -rf "${out_path}" "${text_output1}" "${text_output2}" done diff --git a/tests/cli/test_trace_read.in b/tests/cli/test_trace_read.in index 1325eb39..464dffa0 100644 --- a/tests/cli/test_trace_read.in +++ b/tests/cli/test_trace_read.in @@ -15,31 +15,24 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -CURDIR=$(dirname $0) -TESTDIR=$CURDIR/.. +. "@abs_top_builddir@/tests/utils/common.sh" -BABELTRACE_BIN=$CURDIR/../../cli/babeltrace - -CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces - -source $TESTDIR/utils/tap/tap.sh - -SUCCESS_TRACES=(${CTF_TRACES}/succeed/*) -FAIL_TRACES=(${CTF_TRACES}/fail/*) +SUCCESS_TRACES=(${BT_CTF_TRACES}/succeed/*) +FAIL_TRACES=(${BT_CTF_TRACES}/fail/*) NUM_TESTS=$((${#SUCCESS_TRACES[@]} + ${#FAIL_TRACES[@]})) plan_tests $NUM_TESTS -for path in ${SUCCESS_TRACES[@]}; do - trace=$(basename ${path}) - $BABELTRACE_BIN ${path} > /dev/null 2>&1 +for path in "${SUCCESS_TRACES[@]}"; do + trace=$(basename "${path}") + "${BT_BIN}" "${path}" > /dev/null 2>&1 ok $? "Run babeltrace with trace ${trace}" done -for path in ${FAIL_TRACES[@]}; do - trace=$(basename ${path}) - $BABELTRACE_BIN ${path} > /dev/null 2>&1 +for path in "${FAIL_TRACES[@]}"; do + trace=$(basename "${path}") + "${BT_BIN}" "${path}" > /dev/null 2>&1 if [ $? -eq 0 ]; then fail "Run babeltrace with invalid trace ${trace}" else diff --git a/tests/cli/test_trimmer.in b/tests/cli/test_trimmer.in index 43184630..9303cdf7 100644 --- a/tests/cli/test_trimmer.in +++ b/tests/cli/test_trimmer.in @@ -15,11 +15,9 @@ # 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}" diff --git a/tests/lib/test_ctf_writer_complete.in b/tests/lib/test_ctf_writer_complete.in old mode 100755 new mode 100644 index 0911e09b..4502d444 --- a/tests/lib/test_ctf_writer_complete.in +++ b/tests/lib/test_ctf_writer_complete.in @@ -17,6 +17,10 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -BTBIN="@abs_top_builddir@/cli/babeltrace" +NO_SH_TAP=1 +. "@abs_top_builddir@/tests/utils/common.sh" -"@abs_top_builddir@/tests/lib/test_ctf_writer" "$BTBIN" +script="$(readlink -f "$0")" +curdir="$(dirname "$script")" + +"${curdir}/test_ctf_writer" "$BT_BIN" diff --git a/tests/lib/test_plugin_complete.in b/tests/lib/test_plugin_complete.in index 4936fee7..24bea07c 100644 --- a/tests/lib/test_plugin_complete.in +++ b/tests/lib/test_plugin_complete.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (C) 2017 Philippe Proulx # @@ -17,6 +17,12 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -PLUGIN_DIR="@abs_top_builddir@/tests/lib/test-plugin-plugins/.libs" +NO_SH_TAP=1 +. "@abs_top_builddir@/tests/utils/common.sh" -"@abs_top_builddir@/tests/lib/test_plugin" "$PLUGIN_DIR" +script="$(readlink -f "$0")" +curdir="$(dirname "$script")" + +plugin_dir="${curdir}/test-plugin-plugins/.libs" + +"${curdir}/test_plugin" "$plugin_dir" diff --git a/tests/plugins/test-utils-muxer-complete.in b/tests/plugins/test-utils-muxer-complete.in index bd709f6f..85b51dd5 100644 --- a/tests/plugins/test-utils-muxer-complete.in +++ b/tests/plugins/test-utils-muxer-complete.in @@ -17,6 +17,12 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -PLUGIN_DIR="@abs_top_builddir@/plugins/utils" +NO_SH_TAP=1 +. "@abs_top_builddir@/tests/utils/common.sh" -BABELTRACE_PLUGIN_PATH="$PLUGIN_DIR" '@abs_top_builddir@/tests/plugins/test-utils-muxer' +script="$(readlink -f "$0")" +curdir="$(dirname "$script")" + +plugin_dir="${BT_BUILD_PATH}/plugins/utils" + +BABELTRACE_PLUGIN_PATH="$plugin_dir" "${curdir}/test-utils-muxer" diff --git a/tests/plugins/test_bin_info_complete.in b/tests/plugins/test_bin_info_complete.in old mode 100755 new mode 100644 index 3ca7ca23..09ab708e --- a/tests/plugins/test_bin_info_complete.in +++ b/tests/plugins/test_bin_info_complete.in @@ -17,6 +17,12 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -DEBUG_INFO_DATA="@abs_top_srcdir@/tests/debug-info-data" +NO_SH_TAP=1 +. "@abs_top_builddir@/tests/utils/common.sh" -"@abs_top_builddir@/tests/lib/test_bin_info" "$DEBUG_INFO_DATA" +script="$(readlink -f "$0")" +curdir="$(dirname "$script")" + +debug_info_data="${BT_SRC_PATH}/tests/debug-info-data" + +"${curdir}/test_bin_info" "$debug_info_data" diff --git a/tests/plugins/test_dwarf_complete.in b/tests/plugins/test_dwarf_complete.in old mode 100755 new mode 100644 index a3f026d6..a0ae51b5 --- a/tests/plugins/test_dwarf_complete.in +++ b/tests/plugins/test_dwarf_complete.in @@ -17,6 +17,12 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -DEBUG_INFO_DATA="@abs_top_srcdir@/tests/debug-info-data" +NO_SH_TAP=1 +. "@abs_top_builddir@/tests/utils/common.sh" -"@abs_top_builddir@/tests/lib/test_dwarf" "$DEBUG_INFO_DATA" +script="$(readlink -f "$0")" +curdir="$(dirname "$script")" + +debug_info_data="${BT_SRC_PATH}/tests/debug-info-data" + +"${curdir}/test_dwarf" "$debug_info_data" diff --git a/tests/utils/common.sh.in b/tests/utils/common.sh.in new file mode 100644 index 00000000..08243f5f --- /dev/null +++ b/tests/utils/common.sh.in @@ -0,0 +1,11 @@ +#!/bin/sh + +BT_SRC_PATH="@abs_top_srcdir@" +BT_BUILD_PATH="@abs_top_builddir@" + +BT_BIN="${BT_BUILD_PATH}/cli/babeltrace@EXEEXT@" +BT_CTF_TRACES="${BT_SRC_PATH}/tests/ctf-traces" + +if [ "x${NO_SH_TAP}" = x ]; then + . "${BT_SRC_PATH}/tests/utils/tap/tap.sh" +fi