From: Michael Jeanson Date: Tue, 9 Jul 2019 16:27:49 +0000 (-0400) Subject: tests: update test_trimming to remove the wrapper X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=1d970e04c756fa6e2145eff386884b10c30eb6be tests: update test_trimming to remove the wrapper 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 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1657 Reviewed-by: Philippe Proulx Tested-by: jenkins --- diff --git a/tests/Makefile.am b/tests/Makefile.am index aef19a60..86fad69f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 diff --git a/tests/plugins/flt.utils.trimmer/Makefile.am b/tests/plugins/flt.utils.trimmer/Makefile.am index 92ca5fb6..2847a904 100644 --- a/tests/plugins/flt.utils.trimmer/Makefile.am +++ b/tests/plugins/flt.utils.trimmer/Makefile.am @@ -1,7 +1,6 @@ if HAVE_PYTHON dist_check_SCRIPTS = \ - test_trimming \ - test_trimming_wrapper + test_trimming endif # ENABLE_DEBUG_INFO diff --git a/tests/plugins/flt.utils.trimmer/test_trimming b/tests/plugins/flt.utils.trimmer/test_trimming index 1dbb72e7..3ec05a41 100755 --- a/tests/plugins/flt.utils.trimmer/test_trimming +++ b/tests/plugins/flt.utils.trimmer/test_trimming @@ -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 index 09817847..00000000 --- a/tests/plugins/flt.utils.trimmer/test_trimming_wrapper +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2019 Simon Marchi -# -# 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" diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 17137c98..f7384c25 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -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