Test: rework shell test scripts
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 16 Aug 2017 19:06:19 +0000 (15:06 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 21 Aug 2017 19:23:39 +0000 (15:23 -0400)
Moved common code to common.sh and lots of shellcheck syntax fixes and
cleanup.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20 files changed:
.gitignore
configure.ac
tests/bindings/python/bt2/.gitignore
tests/bindings/python/bt2/Makefile.am
tests/bindings/python/bt2/test_python_bt2.in [new file with mode: 0644]
tests/bindings/python/bt2/testall.sh.in [deleted file]
tests/cli/intersection/test_intersection.in
tests/cli/test_convert_args.in
tests/cli/test_debug_info.in
tests/cli/test_formats.in [deleted file]
tests/cli/test_packet_seq_num.in
tests/cli/test_trace_copy.in
tests/cli/test_trace_read.in
tests/cli/test_trimmer.in
tests/lib/test_ctf_writer_complete.in [changed mode: 0755->0644]
tests/lib/test_plugin_complete.in
tests/plugins/test-utils-muxer-complete.in
tests/plugins/test_bin_info_complete.in [changed mode: 0755->0644]
tests/plugins/test_dwarf_complete.in [changed mode: 0755->0644]
tests/utils/common.sh.in [new file with mode: 0644]

index bd7be8830ff94166e2393c943578feab55286fc7..0b781cacf0aa9e512ea7a27e526cfe83b61d841f 100644 (file)
@@ -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
index d5b2075fcfada89cbad9d0f2d7b5cbd441777761..ba95ac1536d50cabd2bbaddaeba8c7cbcb87774b 100644 (file)
@@ -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"],
index e86dc59602c6b29478736a8dce616fe9f804a4da..d9d5f8ec28c2b4a62873b8ea1339497df6494cc6 100644 (file)
@@ -1,3 +1,3 @@
 htmlcov
 .coverage
-testall.sh
+test_python_bt2
index a31d9be8b459cb903a1681bbc752e0c162f280d6..aad80c0c55b858913912e3fae1593b61dbafe501 100644 (file)
@@ -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 (file)
index 0000000..d32cb01
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# Copyright (C) 2017 - Philippe Proulx <pproulx@efficios.com>
+#
+# 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 (file)
index d682e4c..0000000
+++ /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
index d70367f2ffadf381c679b42d47ac0908e6fb3c1d..07a267fe85c796faa3767c0a4bdec48abd3dd43f 100644 (file)
 # 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
index 875f10e6f623b4b9514802d17fcdb9ee8c2ba11a..123d1a49c58bdb5bb81d7aef971acae3ef29b799 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/bash
 #
 # Copyright (C) - 2017 Philippe Proulx <pproulx@efficios.com>
 #
 # 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
index 0d34e14d2001932e961732be3bdf340c00573c8c..e0c9204c223e620ce74006f6523112beba2e1ee6 100644 (file)
 # 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 (file)
index 4bd32ea..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) - 2016 Nathan Lynch <nathan_lynch@mentor.com>
-#
-# 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
index b9e620576bd7913f7a800371036b616c46fb51bc..9210abf79d2aa9d3ec4845ff62d14993a7ccdbd1 100644 (file)
 # 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"
index 36297bfc60d5b526755e66cd918fc01314bc5ea9..48ccf79ebb0fd9b4371d17d29211ef44534ae1c5 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"
 
-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
index 1325eb3904be80f6902fb4fb58739dc56f59ddcd..464dffa023bde2aedc2938d69e92c4c977340a3f 100644 (file)
 # 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
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}"
old mode 100755 (executable)
new mode 100644 (file)
index 0911e09..4502d44
 # 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"
index 4936fee76cefba2ff21a7731dac756a5b83431b2..24bea07cb8d297dae71145cc60c0b48a2d0a4d03 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
 #
 # 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"
index bd709f6fb989125571d338f545b8e02f9c64c39f..85b51dd51f55979716f678eafd9c5e1bcf8de1ca 100644 (file)
 # 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"
old mode 100755 (executable)
new mode 100644 (file)
index 3ca7ca2..09ab708
 # 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"
old mode 100755 (executable)
new mode 100644 (file)
index a3f026d..a0ae51b
 # 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 (file)
index 0000000..08243f5
--- /dev/null
@@ -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
This page took 0.039085 seconds and 4 git commands to generate.