tests: update test_trimming to remove the wrapper
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 9 Jul 2019 16:27:49 +0000 (12:27 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 18 Jul 2019 15:53:35 +0000 (11:53 -0400)
Run babeltrace with the python environment set in bt_diff_cli instead
of wrapping the test script in another script. Also fix some related
shellcheck errors in test_trimming.

Change-Id: Ie465dfd65c15a0e51f9474e7d3ebe693a2308488
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1657
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
tests/Makefile.am
tests/plugins/flt.utils.trimmer/Makefile.am
tests/plugins/flt.utils.trimmer/test_trimming
tests/plugins/flt.utils.trimmer/test_trimming_wrapper [deleted file]
tests/utils/utils.sh

index aef19a60054e92b919c0f2bbd40003551fdaedcd..86fad69faba51db876cd8df52b36c6a414b51651 100644 (file)
@@ -98,7 +98,7 @@ endif
 
 if ENABLE_PYTHON_PLUGINS
 if ENABLE_PYTHON_BINDINGS
-TESTS_PLUGINS += plugins/flt.utils.trimmer/test_trimming_wrapper
+TESTS_PLUGINS += plugins/flt.utils.trimmer/test_trimming
 endif
 endif
 
index 92ca5fb63da7e5bac72a88696755b5e9c939be2a..2847a904bb3c7ddbc3301da205f39751b2c60d83 100644 (file)
@@ -1,7 +1,6 @@
 if HAVE_PYTHON
 
 dist_check_SCRIPTS = \
-       test_trimming \
-       test_trimming_wrapper
+       test_trimming
 
 endif # ENABLE_DEBUG_INFO
index 1dbb72e7229183b058b5e04cf643dd90344a64b8..3ec05a4115ecbb976201259c56c39a3fa45970ba 100755 (executable)
@@ -27,10 +27,10 @@ else
        UTILSSH="$(dirname "$0")/../../utils/utils.sh"
 fi
 
-# shellcheck source=../../../utils/utils.sh
+# shellcheck source=../../utils/utils.sh
 source "$UTILSSH"
 
-data_dir="$BT_TESTS_SRCDIR/data/plugins/flt.utils.trimmer"
+data_dir="$BT_TESTS_DATADIR/plugins/flt.utils.trimmer"
 temp_expected=$(mktemp)
 
 plan_tests 32
@@ -39,26 +39,31 @@ function run_test
 {
        local begin_time="$1"
        local end_time="$2"
+       local local_args=(
+               "-c" "src.test-trimmer.TheSourceOfAllEvil"
+               "-p" "with-stream-msgs-cs=$with_stream_msgs_cs"
+               "-c" "sink.text.details"
+               "--params=compact=true,with-metadata=false"
+               "--plugin-path=$data_dir"
+       )
 
        if [ -n "$begin_time" ]; then
-               begin="--begin=$begin_time"
-               test_name="with $begin"
+               local_args+=("--begin=$begin_time")
+               test_name="with --begin=$begin_time"
        else
-               begin=""
                test_name="without --begin"
        fi
 
        if [ -n "$end_time" ]; then
-               end="--end=$end_time"
-               test_name="$test_name, with $end"
+               local_args+=("--end=$end_time")
+               test_name="$test_name, with --end=$end_time"
        else
-               end=""
                test_name="$test_name, without --end"
        fi
 
        # with_stream_msgs_cs is set to "true" or "false" by the tests.
 
-       bt_diff_cli "$temp_expected" -c src.test-trimmer.TheSourceOfAllEvil -p with-stream-msgs-cs=$with_stream_msgs_cs -c sink.text.details --params=compact=true,with-metadata=false --plugin-path=$data_dir $begin $end
+       bt_diff_cli "$temp_expected" "${local_args[@]}"
        ok $? "$test_name"
 }
 
@@ -66,7 +71,7 @@ function test_with_stream_msg_cs {
        with_stream_msgs_cs="true"
 
        # Baseline (without trimming)
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [100 10,100,000,000,000] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -77,7 +82,7 @@ function test_with_stream_msg_cs {
        run_test "" ""
 
        # Trim begin at a time before what the clock class can represent
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [100 10,100,000,000,000] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -88,7 +93,7 @@ function test_with_stream_msg_cs {
        run_test 50 ""
 
        # Trim begin before stream beginning
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [100 10,100,000,000,000] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -99,7 +104,7 @@ function test_with_stream_msg_cs {
        run_test 10050 ""
 
        # Trim begin before packet beginning
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [150 10,150,000,000,000] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -110,7 +115,7 @@ function test_with_stream_msg_cs {
        run_test 10150 ""
 
        # Trim begin before first event
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [250 10,250,000,000,000] {0 0 0} Stream beginning
        [250 10,250,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -121,7 +126,7 @@ function test_with_stream_msg_cs {
        run_test 10250 ""
 
        # Trim begin before second event
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [350 10,350,000,000,000] {0 0 0} Stream beginning
        [350 10,350,000,000,000] {0 0 0} Packet beginning
        [400 10,400,000,000,000] {0 0 0} Event `event 2` (1)
@@ -132,7 +137,7 @@ function test_with_stream_msg_cs {
        run_test 10350 ""
 
        # Trim begin before packet end
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [850 10,850,000,000,000] {0 0 0} Stream beginning
        [850 10,850,000,000,000] {0 0 0} Packet beginning
        [900 10,900,000,000,000] {0 0 0} Packet end
@@ -142,13 +147,13 @@ function test_with_stream_msg_cs {
        run_test 10850 ""
 
        # Trim begin after everything
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        END
 
        run_test 11050 ""
 
        # Trim end after stream end
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [100 10,100,000,000,000] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -160,7 +165,7 @@ function test_with_stream_msg_cs {
        run_test "" 11050
 
        # Trim end after packet end
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [100 10,100,000,000,000] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -172,7 +177,7 @@ function test_with_stream_msg_cs {
        run_test "" 10950
 
        # Trim end after second event
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [100 10,100,000,000,000] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -184,7 +189,7 @@ function test_with_stream_msg_cs {
        run_test "" 10450
 
        # Trim end after first event
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [100 10,100,000,000,000] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -195,7 +200,7 @@ function test_with_stream_msg_cs {
        run_test "" 10350
 
        # Trim end after packet beginning
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [100 10,100,000,000,000] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [250 10,250,000,000,000] {0 0 0} Packet end
@@ -205,7 +210,7 @@ function test_with_stream_msg_cs {
        run_test "" 10250
 
        # Trim end after stream beginning
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [100 10,100,000,000,000] {0 0 0} Stream beginning
        [150 10,150,000,000,000] {0 0 0} Stream end
        END
@@ -213,13 +218,13 @@ function test_with_stream_msg_cs {
        run_test "" 10150
 
        # Trim end before everything
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        END
 
        run_test "" 10050
 
        # Trim end at a time before what the clock class can represent
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        END
 
        run_test "" 50
@@ -229,7 +234,7 @@ function test_without_stream_msg_cs {
        with_stream_msgs_cs="false"
 
        # Baseline (without trimming)
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [Unknown] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -240,7 +245,7 @@ function test_without_stream_msg_cs {
        run_test "" ""
 
        # Trim begin at a time before what the clock class can represent
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [Unknown] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -251,7 +256,7 @@ function test_without_stream_msg_cs {
        run_test 50 ""
 
        # Trim begin before stream beginning
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [Unknown] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -262,7 +267,7 @@ function test_without_stream_msg_cs {
        run_test 10050 ""
 
        # Trim begin before packet beginning
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [Unknown] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -273,7 +278,7 @@ function test_without_stream_msg_cs {
        run_test 10150 ""
 
        # Trim begin before first event
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [250 10,250,000,000,000] {0 0 0} Stream beginning
        [250 10,250,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -284,7 +289,7 @@ function test_without_stream_msg_cs {
        run_test 10250 ""
 
        # Trim begin before second event
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [350 10,350,000,000,000] {0 0 0} Stream beginning
        [350 10,350,000,000,000] {0 0 0} Packet beginning
        [400 10,400,000,000,000] {0 0 0} Event `event 2` (1)
@@ -295,7 +300,7 @@ function test_without_stream_msg_cs {
        run_test 10350 ""
 
        # Trim begin before packet end
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [850 10,850,000,000,000] {0 0 0} Stream beginning
        [850 10,850,000,000,000] {0 0 0} Packet beginning
        [900 10,900,000,000,000] {0 0 0} Packet end
@@ -305,13 +310,13 @@ function test_without_stream_msg_cs {
        run_test 10850 ""
 
        # Trim begin after everything
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        END
 
        run_test 11050 ""
 
        # Trim end after stream end
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [Unknown] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -323,7 +328,7 @@ function test_without_stream_msg_cs {
        run_test "" 11050
 
        # Trim end after packet end
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [Unknown] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -335,7 +340,7 @@ function test_without_stream_msg_cs {
        run_test "" 10950
 
        # Trim end after second event
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [Unknown] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -347,7 +352,7 @@ function test_without_stream_msg_cs {
        run_test "" 10450
 
        # Trim end after first event
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [Unknown] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [300 10,300,000,000,000] {0 0 0} Event `event 1` (0)
@@ -358,7 +363,7 @@ function test_without_stream_msg_cs {
        run_test "" 10350
 
        # Trim end after packet beginning
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [Unknown] {0 0 0} Stream beginning
        [200 10,200,000,000,000] {0 0 0} Packet beginning
        [250 10,250,000,000,000] {0 0 0} Packet end
@@ -368,7 +373,7 @@ function test_without_stream_msg_cs {
        run_test "" 10250
 
        # Trim end after stream beginning
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [Unknown] {0 0 0} Stream beginning
        [Unknown] {0 0 0} Stream end
        END
@@ -376,7 +381,7 @@ function test_without_stream_msg_cs {
        run_test "" 10150
 
        # Trim end before everything
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [Unknown] {0 0 0} Stream beginning
        [Unknown] {0 0 0} Stream end
        END
@@ -384,7 +389,7 @@ function test_without_stream_msg_cs {
        run_test "" 10050
 
        # Trim end at a time before what the clock class can represent
-       cat <<- 'END' > $temp_expected
+       cat <<- 'END' > "$temp_expected"
        [Unknown] {0 0 0} Stream beginning
        [Unknown] {0 0 0} Stream end
        END
diff --git a/tests/plugins/flt.utils.trimmer/test_trimming_wrapper b/tests/plugins/flt.utils.trimmer/test_trimming_wrapper
deleted file mode 100755 (executable)
index 0981784..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2019 Simon Marchi <simon.marchi@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.
-
-# This test validates that a `src.ctf.fs` component successfully reads
-# specific CTF traces and creates the expected messages.
-#
-# Such CTF traces to open either exist (in `tests/ctf-traces/succeed`)
-# or are generated by this test using local trace generators.
-
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
-       UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
-else
-       UTILSSH="$(dirname "$0")/../../utils/utils.sh"
-fi
-
-# shellcheck source=../../../utils/utils.sh
-source "$UTILSSH"
-
-run_python_bt2 "$BT_TESTS_SRCDIR/plugins/flt.utils.trimmer/test_trimming"
index 17137c98b23ab274e33a926ce7450afd85b4874e..f7384c2562595e41eb68b62caf7645e4741faf38 100644 (file)
@@ -62,6 +62,7 @@ export BT_TESTS_BUILDDIR
 # the test script, define the 'SH_TAP' variable to '1' before sourcing this
 # script.
 if [ "x${SH_TAP:-}" = x1 ]; then
+       # shellcheck source=./tap/tap.sh
        . "${BT_TESTS_SRCDIR}/utils/tap/tap.sh"
 fi
 
@@ -147,7 +148,7 @@ bt_diff_cli() {
        # Run the CLI to get a detailed file. Strip any \r present due to
        # Windows (\n -> \r\n). "diff --string-trailing-cr" is not used since it
        # is not present on Solaris.
-       "$BT_TESTS_BT2_BIN" "${args[@]}" | tr -d "\r" > "$temp_output_file"
+       run_python_bt2 "$BT_TESTS_BT2_BIN" "${args[@]}" | tr -d "\r" > "$temp_output_file"
 
        # Compare output with expected output
        if ! diff -u "$temp_output_file" "$expected_file" 2>/dev/null >"$temp_diff"; then
This page took 0.03198 seconds and 4 git commands to generate.