From 644e036445497ef69ccf946f0700da20a5bae84f Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 17 Jun 2019 16:48:02 -0400 Subject: [PATCH] tests: Rework test suite * Test script are not generated by autoconf anymore, instead the parameters are passed trought a set of environment variable prefixed with BT_TESTS_. This will enable the test suite to be used against a system installed version of babeltrace with minimal configuration. * Move all duplicated shell script code to 'utils.sh'. * Add 'set -u' to common.sh to catch undefined variables in test scripts. Variables that are expected to be undefined must be used as '${var:-}'. * All shell script is shellcheck tested. * Removed unused test 'test_trace_ir' * The python test runner now returns an error when no python test scripts are found. Signed-off-by: Michael Jeanson Change-Id: I15dcda1d147c8c72c6e4ee00052591eb6f9e30bd Reviewed-on: https://review.lttng.org/c/babeltrace/+/1429 Tested-by: jenkins Reviewed-by: Simon Marchi Reviewed-by: Philippe Proulx --- .gitignore | 46 +--- configure.ac | 36 --- tests/Makefile.am | 26 +- tests/bindings/python/bt2/.gitignore | 1 - tests/bindings/python/bt2/test_plugin.py | 2 +- .../python/bt2/test_python_bt2} | 16 +- tests/bindings/python/bt2/test_python_bt2.in | 62 ----- ...test_convert_args.in => test_convert_args} | 30 +- ...test_intersection.in => test_intersection} | 28 +- ...f_metadata.in => test_output_ctf_metadata} | 20 +- ..._packet_seq_num.in => test_packet_seq_num} | 31 ++- .../{test_trace_copy.in => test_trace_copy} | 29 +- .../{test_trace_read.in => test_trace_read} | 18 +- tests/cli/{test_trimmer.in => test_trimmer} | 15 +- tests/ctf-writer/Makefile.am | 2 + .../{test_ctf_writer.in => test_ctf_writer} | 12 +- tests/lib/Makefile.am | 8 +- tests/lib/{test_plugin.c => plugin.c} | 0 tests/lib/test_plugin | 29 ++ ...lugin_complete.in => test_plugin_complete} | 2 +- .../{test_trace_ir.in => test_trace_ir} | 4 +- .../flt.lttng-utils.debug-info/Makefile.am | 9 + ...ux-gnu.in => test_bin_info_i386-linux-gnu} | 12 +- ...gnu.in => test_bin_info_powerpc-linux-gnu} | 12 +- ...in => test_bin_info_powerpc64le-linux-gnu} | 12 +- ...-gnu.in => test_bin_info_x86_64-linux-gnu} | 12 +- ...linux-gnu.in => test_dwarf_i386-linux-gnu} | 14 +- ...ux-gnu.in => test_dwarf_powerpc-linux-gnu} | 14 +- .../test_dwarf_powerpc64le-linux-gnu | 30 ++ ...nux-gnu.in => test_dwarf_x86_64-linux-gnu} | 14 +- .../test_lttng_utils_debug_info | 31 +++ .../test_lttng_utils_debug_info.in | 38 --- tests/plugins/src.ctf.fs/Makefile.am | 2 + .../query/{test_query.in => test_query} | 13 +- .../succeed/{test_succeed.in => test_succeed} | 21 +- tests/python-plugin-provider/.gitignore | 2 - .../test_python_plugin_provider | 34 +++ .../test_python_plugin_provider.in | 38 --- .../test_python_plugin_provider_env.in | 34 --- tests/utils/.gitignore | 1 - tests/utils/Makefile.am | 4 + tests/utils/common.sh.in | 12 - tests/utils/diff.sh.in | 103 ------- tests/utils/python/testrunner.py | 5 + tests/utils/run_python_bt2 | 50 ++++ tests/utils/test_python_bt2_env.in | 45 --- tests/utils/utils.sh | 258 ++++++++++++++++++ 47 files changed, 704 insertions(+), 533 deletions(-) rename tests/{plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu.in => bindings/python/bt2/test_python_bt2} (67%) mode change 100644 => 100755 delete mode 100644 tests/bindings/python/bt2/test_python_bt2.in rename tests/cli/{test_convert_args.in => test_convert_args} (97%) mode change 100644 => 100755 rename tests/cli/{test_intersection.in => test_intersection} (72%) mode change 100644 => 100755 rename tests/cli/{test_output_ctf_metadata.in => test_output_ctf_metadata} (65%) mode change 100644 => 100755 rename tests/cli/{test_packet_seq_num.in => test_packet_seq_num} (70%) mode change 100644 => 100755 rename tests/cli/{test_trace_copy.in => test_trace_copy} (71%) mode change 100644 => 100755 rename tests/cli/{test_trace_read.in => test_trace_read} (74%) mode change 100644 => 100755 rename tests/cli/{test_trimmer.in => test_trimmer} (91%) mode change 100644 => 100755 rename tests/ctf-writer/{test_ctf_writer.in => test_ctf_writer} (74%) mode change 100644 => 100755 rename tests/lib/{test_plugin.c => plugin.c} (100%) create mode 100755 tests/lib/test_plugin rename tests/lib/{test_plugin_complete.in => test_plugin_complete} (92%) mode change 100644 => 100755 rename tests/lib/trace-ir/{test_trace_ir.in => test_trace_ir} (91%) mode change 100644 => 100755 rename tests/plugins/flt.lttng-utils.debug-info/{test_bin_info_i386-linux-gnu.in => test_bin_info_i386-linux-gnu} (79%) mode change 100644 => 100755 rename tests/plugins/flt.lttng-utils.debug-info/{test_bin_info_powerpc-linux-gnu.in => test_bin_info_powerpc-linux-gnu} (79%) mode change 100644 => 100755 rename tests/plugins/flt.lttng-utils.debug-info/{test_bin_info_powerpc64le-linux-gnu.in => test_bin_info_powerpc64le-linux-gnu} (79%) mode change 100644 => 100755 rename tests/plugins/flt.lttng-utils.debug-info/{test_bin_info_x86_64-linux-gnu.in => test_bin_info_x86_64-linux-gnu} (79%) mode change 100644 => 100755 rename tests/plugins/flt.lttng-utils.debug-info/{test_dwarf_powerpc-linux-gnu.in => test_dwarf_i386-linux-gnu} (72%) mode change 100644 => 100755 rename tests/plugins/flt.lttng-utils.debug-info/{test_dwarf_powerpc64le-linux-gnu.in => test_dwarf_powerpc-linux-gnu} (71%) mode change 100644 => 100755 create mode 100755 tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu rename tests/plugins/flt.lttng-utils.debug-info/{test_dwarf_i386-linux-gnu.in => test_dwarf_x86_64-linux-gnu} (71%) mode change 100644 => 100755 create mode 100755 tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info delete mode 100644 tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info.in rename tests/plugins/src.ctf.fs/query/{test_query.in => test_query} (73%) mode change 100644 => 100755 rename tests/plugins/src.ctf.fs/succeed/{test_succeed.in => test_succeed} (76%) mode change 100644 => 100755 create mode 100755 tests/python-plugin-provider/test_python_plugin_provider delete mode 100644 tests/python-plugin-provider/test_python_plugin_provider.in delete mode 100644 tests/python-plugin-provider/test_python_plugin_provider_env.in delete mode 100644 tests/utils/.gitignore delete mode 100644 tests/utils/common.sh.in delete mode 100644 tests/utils/diff.sh.in create mode 100755 tests/utils/run_python_bt2 delete mode 100644 tests/utils/test_python_bt2_env.in create mode 100644 tests/utils/utils.sh diff --git a/.gitignore b/.gitignore index ed858915..e302428e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,51 +1,13 @@ -*~ -/tests/cli/test_convert_args -/tests/cli/test_debug_info -/tests/cli/test_intersection -/tests/cli/test_output_ctf_metadata -/tests/cli/test_packet_seq_num -/tests/cli/test_trace_copy -/tests/cli/test_trace_read -/tests/cli/test_trimmer -/tests/bin/intersection/bt_python_helper.py -/tests/bin/intersection/test_intersection -/tests/bin/test_packet_seq_num -/tests/bin/test_trace_read /tests/ctf-writer/ctf_writer -/tests/ctf-writer/test_ctf_writer +/tests/lib/plugin /tests/lib/test_bitfield -/tests/lib/test_bt_ctf_field_type_validation -/tests/lib/test_bt_objects /tests/lib/test_bt_values -/tests/lib/test_trace_ir_ref -/tests/lib/test_ir_visit -/tests/lib/test_trace_listener -/tests/lib/test_plugin -/tests/lib/test_plugin_complete -/tests/lib/writer/bt_python_helper.py -/tests/lib/writer/test_ctf_writer_empty_packet.py -/tests/lib/writer/test_ctf_writer_no_packet_context.py -/tests/lib/test_bt_message_iterator -/tests/lib/test_cc_prio_map /tests/lib/test_graph_topo -/tests/lib/trace-ir/test_trace_ir -/tests/lib/ctf-writer/test_ctf_writer -/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info -/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu -/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu -/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu -/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu +/tests/lib/test_trace_ir_ref /tests/plugins/flt.lttng-utils.debug-info/test_bin_info -/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu -/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu -/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu -/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu /tests/plugins/flt.lttng-utils.debug-info/test_dwarf -/tests/plugins/src.ctf.fs/query/test_query -/tests/plugins/src.ctf.fs/succeed/test_succeed -/tests/plugins/src.ctf.fs/succeed/gen-trace-* -/tests/utils/common.sh -/tests/utils/diff.sh +/tests/plugins/src.ctf.fs/succeed/gen-trace-simple +*~ *.o *.a *.la diff --git a/configure.ac b/configure.ac index 4d150fe9..b0434771 100644 --- a/configure.ac +++ b/configure.ac @@ -782,46 +782,10 @@ AC_CONFIG_FILES([ tests/plugins/src.ctf.fs/Makefile tests/plugins/src.ctf.fs/succeed/Makefile tests/plugins/flt.lttng-utils.debug-info/Makefile - tests/utils/common.sh - tests/utils/diff.sh tests/utils/Makefile tests/utils/tap/Makefile ]) -AC_CONFIG_FILES([tests/cli/test_intersection], [chmod +x tests/cli/test_intersection]) -AC_CONFIG_FILES([tests/cli/test_convert_args], [chmod +x tests/cli/test_convert_args]) -AC_CONFIG_FILES([tests/cli/test_output_ctf_metadata], [chmod +x tests/cli/test_output_ctf_metadata]) -AC_CONFIG_FILES([tests/cli/test_packet_seq_num], [chmod +x tests/cli/test_packet_seq_num]) -AC_CONFIG_FILES([tests/cli/test_trace_copy], [chmod +x tests/cli/test_trace_copy]) -AC_CONFIG_FILES([tests/cli/test_trace_read], [chmod +x tests/cli/test_trace_read]) -AC_CONFIG_FILES([tests/cli/test_trimmer], [chmod +x tests/cli/test_trimmer]) -AC_CONFIG_FILES([tests/ctf-writer/test_ctf_writer], [chmod +x tests/ctf-writer/test_ctf_writer]) -AC_CONFIG_FILES([tests/lib/test_plugin_complete], [chmod +x tests/lib/test_plugin_complete]) -AC_CONFIG_FILES([tests/lib/trace-ir/test_trace_ir], [chmod +x tests/lib/trace-ir/test_trace_ir]) -AC_CONFIG_FILES([tests/plugins/src.ctf.fs/query/test_query], [chmod +x tests/plugins/src.ctf.fs/query/test_query]) -AC_CONFIG_FILES([tests/plugins/src.ctf.fs/succeed/test_succeed], [chmod +x tests/plugins/src.ctf.fs/succeed/test_succeed]) -AC_CONFIG_FILES([tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info], [chmod +x tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info]) -AC_CONFIG_FILES([tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu], [chmod +x tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu]) -AC_CONFIG_FILES([tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu], [chmod +x tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu]) -AC_CONFIG_FILES([tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu], [chmod +x tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu]) -AC_CONFIG_FILES([tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu], [chmod +x tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu]) -AC_CONFIG_FILES([tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu], [chmod +x tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu]) -AC_CONFIG_FILES([tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu], [chmod +x tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu]) -AC_CONFIG_FILES([tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu], [chmod +x tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu]) -AC_CONFIG_FILES([tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu], [chmod +x tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu]) - -AS_IF([test "x$enable_python_bindings" = xyes], - [ - AC_CONFIG_FILES([tests/bindings/python/bt2/test_python_bt2], [chmod +x tests/bindings/python/bt2/test_python_bt2]) - AC_CONFIG_FILES([tests/utils/test_python_bt2_env], [chmod +x tests/utils/test_python_bt2_env]) - ] -) - -AS_IF([test "x$enable_python_plugins" = "xyes"], - [AC_CONFIG_FILES([tests/python-plugin-provider/test_python_plugin_provider], [chmod +x tests/python-plugin-provider/test_python_plugin_provider])] - [AC_CONFIG_FILES([tests/python-plugin-provider/test_python_plugin_provider_env], [chmod +x tests/python-plugin-provider/test_python_plugin_provider_env])] -) - AC_OUTPUT # diff --git a/tests/Makefile.am b/tests/Makefile.am index 92472785..5ffd0e0c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -21,6 +21,7 @@ dist_check_SCRIPTS = \ bindings/python/bt2/test_packet.py \ bindings/python/bt2/test_plugin.py \ bindings/python/bt2/test_port.py \ + bindings/python/bt2/test_python_bt2 \ bindings/python/bt2/test_query_executor.py \ bindings/python/bt2/test_stream_class.py \ bindings/python/bt2/test_stream.py \ @@ -28,7 +29,15 @@ dist_check_SCRIPTS = \ bindings/python/bt2/test_trace.py \ bindings/python/bt2/test_value.py \ bindings/python/bt2/utils.py \ + cli/test_convert_args \ + cli/test_intersection \ + cli/test_output_ctf_metadata \ + cli/test_packet_seq_num \ + cli/test_trace_copy \ + cli/test_trace_read \ + cli/test_trimmer \ python-plugin-provider/bt_plugin_test_python_plugin_provider.py \ + python-plugin-provider/test_python_plugin_provider \ python-plugin-provider/test_python_plugin_provider.py TESTS_BINDINGS = @@ -55,11 +64,7 @@ TESTS_CTF_WRITER = \ ctf-writer/test_ctf_writer if !ENABLE_BUILT_IN_PLUGINS -TESTS_LIB += lib/test_plugin_complete -endif - -if ENABLE_PYTHON_BINDINGS -TESTS_LIB += lib/trace-ir/test_trace_ir +TESTS_LIB += lib/test_plugin endif TESTS_PLUGINS = \ @@ -93,8 +98,15 @@ if ENABLE_PYTHON_PLUGINS TESTS_PYTHON_PLUGIN_PROVIDER += python-plugin-provider/test_python_plugin_provider endif -LOG_DRIVER_FLAGS = '--merge' -LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/config/tap-driver.sh +LOG_DRIVER_FLAGS = --merge --comments +LOG_DRIVER = env AM_TAP_AWK='$(AWK)' \ + BT_TESTS_SRCDIR='$(abs_top_srcdir)/tests' \ + BT_TESTS_BUILDDIR='$(abs_top_builddir)/tests' \ + BT_TESTS_AWK_BIN="$(AWK)" \ + BT_TESTS_GREP_BIN="$(GREP)" \ + BT_TESTS_PYTHON_BIN="$(PYTHON)" \ + BT_TESTS_SED_BIN="$(SED)" \ + $(SHELL) $(top_srcdir)/config/tap-driver.sh TESTS = $(TESTS_BINDINGS) $(TESTS_CLI) $(TESTS_CTF_WRITER) $(TESTS_LIB) \ $(TESTS_PLUGINS) $(TESTS_PYTHON_PLUGIN_PROVIDER) diff --git a/tests/bindings/python/bt2/.gitignore b/tests/bindings/python/bt2/.gitignore index d9d5f8ec..7446a35d 100644 --- a/tests/bindings/python/bt2/.gitignore +++ b/tests/bindings/python/bt2/.gitignore @@ -1,3 +1,2 @@ htmlcov .coverage -test_python_bt2 diff --git a/tests/bindings/python/bt2/test_plugin.py b/tests/bindings/python/bt2/test_plugin.py index 8384cf31..d9b0523b 100644 --- a/tests/bindings/python/bt2/test_plugin.py +++ b/tests/bindings/python/bt2/test_plugin.py @@ -22,7 +22,7 @@ import bt2.plugin import os -_TEST_PLUGIN_PLUGINS_PATH = os.environ['TEST_PLUGIN_PLUGINS_PATH'] +_TEST_PLUGIN_PLUGINS_PATH = os.environ['BT_PLUGINS_PATH'] class PluginSetTestCase(unittest.TestCase): diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu.in b/tests/bindings/python/bt2/test_python_bt2 old mode 100644 new mode 100755 similarity index 67% rename from tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu.in rename to tests/bindings/python/bt2/test_python_bt2 index 7b350898..ba39c2d9 --- a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu.in +++ b/tests/bindings/python/bt2/test_python_bt2 @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2015 - Antoine Busque +# 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 @@ -17,11 +17,13 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -NO_SH_TAP=1 -. "@abs_top_builddir@/tests/utils/common.sh" +if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../../utils/utils.sh" +fi -curdir="$(cd -P "$(dirname "$0")" >/dev/null && pwd)" +# shellcheck source=../../../utils/utils.sh +source "$UTILSSH" -debug_info_data="${BT_DEBUG_INFO_PATH}/x86_64-linux-gnu" - -"${curdir}/test_dwarf" "$debug_info_data" +run_python_bt2_test "${BT_TESTS_SRCDIR}/bindings/python/bt2" diff --git a/tests/bindings/python/bt2/test_python_bt2.in b/tests/bindings/python/bt2/test_python_bt2.in deleted file mode 100644 index a067f7fb..00000000 --- a/tests/bindings/python/bt2/test_python_bt2.in +++ /dev/null @@ -1,62 +0,0 @@ -#!/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}/src/plugins" -export BABELTRACE_PLUGIN_PATH="${BT_BUILD_PATH}/src/plugins/ctf:${BT_BUILD_PATH}/src/plugins/utils:${BT_BUILD_PATH}/src/plugins/text" -export BT_CTF_TRACES_PATH - -PYTHON_BUILD_DIR="${BT_BUILD_PATH}/src/bindings/python/bt2/build/build_lib" -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 [ "x${MSYSTEM}" != "x" ]; then - export PATH="${BT_BUILD_PATH}/src/lib/.libs:${PATH}" -else - export LD_LIBRARY_PATH="${BT_BUILD_PATH}/src/lib/.libs:${LD_LIBRARY_PATH}" -fi - -if test "x${TESTALL_COVERAGE}" = "x1"; then - EXEC=check_coverage -else - EXEC="@PYTHON@" - -fi - -PYTHONPATH="${PYTHON_BUILD_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/test_convert_args.in b/tests/cli/test_convert_args old mode 100644 new mode 100755 similarity index 97% rename from tests/cli/test_convert_args.in rename to tests/cli/test_convert_args index baa19462..d5bd7623 --- a/tests/cli/test_convert_args.in +++ b/tests/cli/test_convert_args @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) - 2017 Philippe Proulx +# 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, version 2 only, as @@ -15,7 +15,18 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -. "@abs_top_builddir@/tests/utils/common.sh" +SH_TAP=1 + +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" + +test_head_comment=0 test_bt_convert_run_args() { local what="$1" @@ -23,7 +34,7 @@ test_bt_convert_run_args() { local expected_run_args="$3" # execute convert command - local run_args="$("$BT_BIN" convert --run-args $convert_args)" + local run_args="$("$BT_TESTS_BT2_BIN" convert --run-args $convert_args)" # check result if [ "$test_head_comment" = 1 ]; then @@ -45,7 +56,7 @@ test_bt_convert_fails() { local convert_args="$2" # execute convert command - "$BT_BIN" convert --run-args $convert_args >/dev/null 2>&1 + "$BT_TESTS_BT2_BIN" convert --run-args $convert_args >/dev/null 2>&1 local status=$? @@ -66,10 +77,13 @@ comment() { echo "### $1 ###" } -@BABELTRACE_BUILD_WITH_MINGW_TRUE@path_to_trace="C://path/to/trace" -@BABELTRACE_BUILD_WITH_MINGW_FALSE@path_to_trace="/path/to/trace" -@BABELTRACE_BUILD_WITH_MINGW_TRUE@output_path="C://output/path" -@BABELTRACE_BUILD_WITH_MINGW_FALSE@output_path="/output/path" +if [ "x${MSYSTEM:-}" != "x" ]; then + path_to_trace="C://path/to/trace" + output_path="C://output/path" +else + path_to_trace="/path/to/trace" + output_path="/output/path" +fi plan_tests 77 diff --git a/tests/cli/test_intersection.in b/tests/cli/test_intersection old mode 100644 new mode 100755 similarity index 72% rename from tests/cli/test_intersection.in rename to tests/cli/test_intersection index b84ec8ab..1f8d20cf --- a/tests/cli/test_intersection.in +++ b/tests/cli/test_intersection @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) - 2015 Julien Desfossez +# Copyright (C) 2015 Julien Desfossez # # 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 @@ -15,20 +15,34 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -. "@abs_top_builddir@/tests/utils/common.sh" +SH_TAP=1 + +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" NUM_TESTS=10 plan_tests $NUM_TESTS test_intersect() { - trace="$1" - totalevents="$2" - intersect="$3" + local trace="$1" + local totalevents="$2" + local intersect="$3" - test $("${BT_BIN}" "$trace" | wc -l) = "$totalevents" + local cnt + + cnt=$("${BT_TESTS_BT2_BIN}" "$trace" | wc -l) + test "${cnt// /}" = "$totalevents" ok $? "$totalevents events in the whole trace" - test $("${BT_BIN}" --stream-intersection "$trace" 2>/dev/null| wc -l) = "$intersect" + + cnt=$("${BT_TESTS_BT2_BIN}" --stream-intersection "$trace" 2>/dev/null| wc -l) + test "${cnt// /}" = "$intersect" ok $? "$intersect events in packets intersecting" } diff --git a/tests/cli/test_output_ctf_metadata.in b/tests/cli/test_output_ctf_metadata old mode 100644 new mode 100755 similarity index 65% rename from tests/cli/test_output_ctf_metadata.in rename to tests/cli/test_output_ctf_metadata index e39bbc49..20719388 --- a/tests/cli/test_output_ctf_metadata.in +++ b/tests/cli/test_output_ctf_metadata @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) - 2019 Simon Marchi +# 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, version 2 only, as @@ -15,8 +15,16 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -. "@abs_top_builddir@/tests/utils/common.sh" +SH_TAP=1 +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" NUM_TESTS=3 @@ -25,12 +33,14 @@ plan_tests $NUM_TESTS tmp_metadata=$(mktemp) # Test a valid trace directory. -"${BT_BIN}" -o ctf-metadata "${BT_CTF_TRACES_PATH}/succeed/wk-heartbeat-u" > "$tmp_metadata" +"${BT_TESTS_BT2_BIN}" -o ctf-metadata "${BT_CTF_TRACES_PATH}/succeed/wk-heartbeat-u" > "$tmp_metadata" ok $? "Run babeltrace -o ctf-metadata with a valid trace directory, correct exit status" -cmp -s "$tmp_metadata" "${BT_SRC_PATH}/tests/data/cli/test_output_ctf_metadata.ref" +cmp -s "$tmp_metadata" "${BT_TESTS_DATADIR}/cli/test_output_ctf_metadata.ref" ok $? "Run babeltrace -o ctf-metadata with a valid trace directory, correct output" # Test an invalid trace directory. -"${BT_BIN}" -o ctf-metadata "${BT_CTF_TRACES_PATH}" &> /dev/null +"${BT_TESTS_BT2_BIN}" -o ctf-metadata "${BT_CTF_TRACES_PATH}" >/dev/null 2>&1 isnt $? 0 "Run babeltrace -o ctf-metadata with an invalid trace directory, expecting failure" + +rm -f "$tmp_metadata" diff --git a/tests/cli/test_packet_seq_num.in b/tests/cli/test_packet_seq_num old mode 100644 new mode 100755 similarity index 70% rename from tests/cli/test_packet_seq_num.in rename to tests/cli/test_packet_seq_num index 3a42f8f9..71ec8684 --- a/tests/cli/test_packet_seq_num.in +++ b/tests/cli/test_packet_seq_num @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) - 2015 Julien Desfossez +# Copyright (C) 2015 Julien Desfossez # # 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 @@ -15,18 +15,27 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -. "@abs_top_builddir@/tests/utils/common.sh" +SH_TAP=1 + +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" NUM_TESTS=10 plan_tests $NUM_TESTS test_no_lost() { - trace=$1 + local trace=$1 - "${BT_BIN}" "$trace" >/dev/null 2>&1 + "${BT_TESTS_BT2_BIN}" "$trace" >/dev/null 2>&1 ok $? "Trace parses" - "${BT_BIN}" "$trace" 2>&1 >/dev/null | @GREP@ "\[warning\] Tracer lost" + "${BT_TESTS_BT2_BIN}" "$trace" 2>&1 >/dev/null | "${BT_TESTS_GREP_BIN}" "\[warning\] Tracer lost" if test $? = 0; then fail 1 "Should not find any lost events" else @@ -35,19 +44,19 @@ test_no_lost() { } test_lost() { - trace=$1 - expectedcountstr=$2 + local trace=$1 + local expectedcountstr=$2 - "${BT_BIN}" "$trace" >/dev/null 2>&1 + "${BT_TESTS_BT2_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 - "${BT_BIN}" "$trace" 2>&1 >/dev/null | @GREP@ "WARNING: Tracer discarded" \ - | cut -d" " -f4 | tr "\n" "," | @SED@ "s/.$//" | \ - @GREP@ "$expectedcountstr" >/dev/null + "${BT_TESTS_BT2_BIN}" "$trace" 2>&1 >/dev/null | "${BT_TESTS_GREP_BIN}" "WARNING: Tracer discarded" \ + | cut -d" " -f4 | tr "\n" "," | "${BT_TESTS_SED_BIN}" "s/.$//" | \ + "${BT_TESTS_GREP_BIN}" "$expectedcountstr" >/dev/null ok $? "Lost events string matches $expectedcountstr" } diff --git a/tests/cli/test_trace_copy.in b/tests/cli/test_trace_copy old mode 100644 new mode 100755 similarity index 71% rename from tests/cli/test_trace_copy.in rename to tests/cli/test_trace_copy index c9047460..8b4a46d4 --- a/tests/cli/test_trace_copy.in +++ b/tests/cli/test_trace_copy @@ -15,7 +15,16 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -. "@abs_top_builddir@/tests/utils/common.sh" +SH_TAP=1 + +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" clean_tmp() { rm -rf "${out_path}" "${text_output1}" "${text_output2}" @@ -35,10 +44,10 @@ for path in "${SUCCESS_TRACES[@]}"; do trace="$(basename "${path}")" sort_cmd="cat" # by default do not sort the trace - "${BT_BIN}" --no-delta "${path}" 2>/dev/null >"${text_output1}" + "${BT_TESTS_BT2_BIN}" --no-delta "${path}" 2>/dev/null >"${text_output1}" ret=$? cnt="$(wc -l < "${text_output1}")" - if test "$ret" == 0 && test $cnt == 0; then + if test "$ret" == 0 && test "${cnt// /}" == 0; then pass "Empty trace ${trace}, nothing to copy" clean_tmp continue @@ -48,13 +57,13 @@ for path in "${SUCCESS_TRACES[@]}"; do # duplicate timestamps in the output. # If there are, we have to sort the text output to make sure it is # always the same. - head -1 "${text_output1}" | @GREP@ "^\[" >/dev/null + head -1 "${text_output1}" | "${BT_TESTS_GREP_BIN}" "^\[" >/dev/null if test $? = 0; then - uniq_ts_cnt="$(@AWK@ '{ print $1 }' < "${text_output1}" | sort | uniq | wc -l)" + uniq_ts_cnt="$("${BT_TESTS_AWK_BIN}" '{ print $1 }' < "${text_output1}" | sort | uniq | wc -l)" # Extract only the timestamp columns and compare the number of # unique lines with the total number of lines to see if there # are duplicate timestamps. - if test $cnt != $uniq_ts_cnt; then + if test "${cnt// /}" != "${uniq_ts_cnt// /}"; then diag "Trace with non unique timestamps, sorting the output" sort_cmd="sort" tmp="$(mktemp)" @@ -64,15 +73,15 @@ for path in "${SUCCESS_TRACES[@]}"; do fi fi - "${BT_BIN}" "${path}" --component sink.ctf.fs --path "${out_path}" >/dev/null 2>&1 + "${BT_TESTS_BT2_BIN}" "${path}" --component sink.ctf.fs --path "${out_path}" >/dev/null 2>&1 ok $? "Copy trace ${trace} with ctf-fs sink" - "${BT_BIN}" "${out_path}" >/dev/null 2>&1 + "${BT_TESTS_BT2_BIN}" "${out_path}" >/dev/null 2>&1 ok $? "Read the new trace in ${out_path}" - "${BT_BIN}" --no-delta "${out_path}" 2>/dev/null | $sort_cmd >"${text_output2}" + "${BT_TESTS_BT2_BIN}" --no-delta "${out_path}" 2>/dev/null | $sort_cmd >"${text_output2}" cnt=$(diff "${text_output1}" "${text_output2}" | wc -l) - test $cnt == 0 + test "${cnt// /}" == 0 ok $? "Exact same content between the two traces" clean_tmp diff --git a/tests/cli/test_trace_read.in b/tests/cli/test_trace_read old mode 100644 new mode 100755 similarity index 74% rename from tests/cli/test_trace_read.in rename to tests/cli/test_trace_read index 5cd6344a..5dd9c3db --- a/tests/cli/test_trace_read.in +++ b/tests/cli/test_trace_read @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) - 2013 Christian Babeux +# Copyright (C) 2013 Christian Babeux # # 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 @@ -15,7 +15,16 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -. "@abs_top_builddir@/tests/utils/common.sh" +SH_TAP=1 + +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" SUCCESS_TRACES=(${BT_CTF_TRACES_PATH}/succeed/*) FAIL_TRACES=(${BT_CTF_TRACES_PATH}/fail/*) @@ -26,14 +35,13 @@ plan_tests $NUM_TESTS for path in "${SUCCESS_TRACES[@]}"; do trace=$(basename "${path}") - "${BT_BIN}" "${path}" > /dev/null 2>&1 + "${BT_TESTS_BT2_BIN}" "${path}" > /dev/null 2>&1 ok $? "Run babeltrace2 with trace ${trace}" done for path in "${FAIL_TRACES[@]}"; do trace=$(basename "${path}") - "${BT_BIN}" "${path}" > /dev/null 2>&1 - if [ $? -eq 0 ]; then + if "${BT_TESTS_BT2_BIN}" "${path}" > /dev/null 2>&1; then fail "Run babeltrace2 with invalid trace ${trace}" else pass "Run babeltrace2 with invalid trace ${trace}" diff --git a/tests/cli/test_trimmer.in b/tests/cli/test_trimmer old mode 100644 new mode 100755 similarity index 91% rename from tests/cli/test_trimmer.in rename to tests/cli/test_trimmer index f40ab444..c1525024 --- a/tests/cli/test_trimmer.in +++ b/tests/cli/test_trimmer @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) - 2017 Julien Desfossez +# Copyright (C) 2017 Julien Desfossez # # 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 @@ -15,7 +15,16 @@ # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -. "@abs_top_builddir@/tests/utils/common.sh" +SH_TAP=1 + +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" TRACE_PATH="${BT_CTF_TRACES_PATH}/succeed/wk-heartbeat-u/" @@ -41,7 +50,7 @@ function expect_success() local msg="$1" shift - "${BT_BIN}" "${TRACE_PATH}" "$@" 2>/dev/null > "${tmp_out}" + "${BT_TESTS_BT2_BIN}" "${TRACE_PATH}" "$@" 2>/dev/null > "${tmp_out}" ok $? "trimmer: ${msg}: exit status" num_events=$(wc -l < "${tmp_out}") # Use bash parameter expansion to strip spaces added by BSD 'wc' on macOs and Solaris diff --git a/tests/ctf-writer/Makefile.am b/tests/ctf-writer/Makefile.am index d047689d..a4f1f741 100644 --- a/tests/ctf-writer/Makefile.am +++ b/tests/ctf-writer/Makefile.am @@ -7,3 +7,5 @@ ctf_writer_LDADD = \ $(top_builddir)/tests/utils/tap/libtap.la \ $(top_builddir)/tests/utils/libtestcommon.la \ $(top_builddir)/src/ctf-writer/libbabeltrace2-ctf-writer.la + +dist_check_SCRIPTS = test_ctf_writer diff --git a/tests/ctf-writer/test_ctf_writer.in b/tests/ctf-writer/test_ctf_writer old mode 100644 new mode 100755 similarity index 74% rename from tests/ctf-writer/test_ctf_writer.in rename to tests/ctf-writer/test_ctf_writer index 897c3fee..31426804 --- a/tests/ctf-writer/test_ctf_writer.in +++ b/tests/ctf-writer/test_ctf_writer @@ -17,9 +17,13 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -NO_SH_TAP=1 -. "@abs_top_builddir@/tests/utils/common.sh" +if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../utils/utils.sh" +fi -curdir="$(cd -P "$(dirname "$0")" >/dev/null && pwd)" +# shellcheck source=../utils/utils.sh +source "$UTILSSH" -"${curdir}/ctf_writer" "$BT_BIN" +"${BT_TESTS_BUILDDIR}/ctf-writer/ctf_writer" "$BT_TESTS_BT2_BIN" diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am index 14912a17..efbb6c86 100644 --- a/tests/lib/Makefile.am +++ b/tests/lib/Makefile.am @@ -27,9 +27,11 @@ test_trace_ir_ref_SOURCES = test_trace_ir_ref.c test_graph_topo_SOURCES = test_graph_topo.c if !ENABLE_BUILT_IN_PLUGINS -noinst_PROGRAMS += test_plugin -test_plugin_LDADD = $(COMMON_TEST_LDADD) \ +noinst_PROGRAMS += plugin +plugin_LDADD = $(COMMON_TEST_LDADD) \ $(top_builddir)/src/lib/libbabeltrace2.la -test_plugin_SOURCES = test_plugin.c +plugin_SOURCES = plugin.c SUBDIRS += test-plugin-plugins endif + +dist_check_SCRIPTS = test_plugin diff --git a/tests/lib/test_plugin.c b/tests/lib/plugin.c similarity index 100% rename from tests/lib/test_plugin.c rename to tests/lib/plugin.c diff --git a/tests/lib/test_plugin b/tests/lib/test_plugin new file mode 100755 index 00000000..652c90cc --- /dev/null +++ b/tests/lib/test_plugin @@ -0,0 +1,29 @@ +#!/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. +# + +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" + +"${BT_TESTS_BUILDDIR}/lib/plugin" "${BT_TESTS_BUILDDIR}/lib/test-plugin-plugins/.libs" diff --git a/tests/lib/test_plugin_complete.in b/tests/lib/test_plugin_complete old mode 100644 new mode 100755 similarity index 92% rename from tests/lib/test_plugin_complete.in rename to tests/lib/test_plugin_complete index 4bcf2bf5..e3e730fd --- a/tests/lib/test_plugin_complete.in +++ b/tests/lib/test_plugin_complete @@ -18,7 +18,7 @@ # NO_SH_TAP=1 -. "@abs_top_builddir@/tests/utils/common.sh" +. "/home/mjeanson/Git/lttng/babeltrace/master/tests/utils/common.sh" curdir="$(cd -P "$(dirname "$0")" >/dev/null && pwd)" diff --git a/tests/lib/trace-ir/test_trace_ir.in b/tests/lib/trace-ir/test_trace_ir old mode 100644 new mode 100755 similarity index 91% rename from tests/lib/trace-ir/test_trace_ir.in rename to tests/lib/trace-ir/test_trace_ir index b4d49dc6..02f8455d --- a/tests/lib/trace-ir/test_trace_ir.in +++ b/tests/lib/trace-ir/test_trace_ir @@ -18,7 +18,7 @@ # NO_SH_TAP=1 -. "@abs_top_builddir@/tests/utils/common.sh" +. "/home/mjeanson/Git/lttng/babeltrace/master/tests/utils/common.sh" PYTHON_BUILD_DIR="${BT_BUILD_PATH}/src/bindings/python/bt2/build/build_lib" TESTS_UTILS_PYTHON_DIR="${BT_SRC_PATH}/tests/utils/python" @@ -32,5 +32,5 @@ else fi PYTHONPATH="${PYTHON_BUILD_DIR}:${TESTS_UTILS_PYTHON_DIR}" \ - "@PYTHON@" "${TESTRUNNER_PY}" "${THIS_DIR}" + "/usr/bin/python3" "${TESTRUNNER_PY}" "${THIS_DIR}" exit $? diff --git a/tests/plugins/flt.lttng-utils.debug-info/Makefile.am b/tests/plugins/flt.lttng-utils.debug-info/Makefile.am index 86287494..a076b3e8 100644 --- a/tests/plugins/flt.lttng-utils.debug-info/Makefile.am +++ b/tests/plugins/flt.lttng-utils.debug-info/Makefile.am @@ -3,6 +3,15 @@ AM_CPPFLAGS += -I$(top_srcdir)/tests/utils -I$(top_srcdir)/src/plugins LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la dist_check_SCRIPTS = \ + test_bin_info_i386-linux-gnu \ + test_bin_info_powerpc64le-linux-gnu \ + test_bin_info_powerpc-linux-gnu \ + test_bin_info_x86_64-linux-gnu \ + test_dwarf_i386-linux-gnu \ + test_dwarf_powerpc64le-linux-gnu \ + test_dwarf_powerpc-linux-gnu \ + test_dwarf_x86_64-linux-gnu \ + test_lttng_utils_debug_info \ test_lttng_utils_debug_info.py noinst_PROGRAMS = diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu.in b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu old mode 100644 new mode 100755 similarity index 79% rename from tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu.in rename to tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu index e36379c2..484f6380 --- a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu.in +++ b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_i386-linux-gnu @@ -18,14 +18,18 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -NO_SH_TAP=1 -. "@abs_top_builddir@/tests/utils/common.sh" +if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../utils/utils.sh" +fi -curdir="$(cd -P "$(dirname "$0")" >/dev/null && pwd)" +# shellcheck source=../../utils/utils.sh +source "$UTILSSH" debug_info_data="${BT_DEBUG_INFO_PATH}/i386-linux-gnu" -"${curdir}/test_bin_info" \ +"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_bin_info" \ --foo-addr=0x1c8d \ --printf-offset=0xda \ --printf-lineno=36 \ diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu.in b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu old mode 100644 new mode 100755 similarity index 79% rename from tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu.in rename to tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu index c37568c0..9a9ffbd3 --- a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu.in +++ b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc-linux-gnu @@ -18,14 +18,18 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -NO_SH_TAP=1 -. "@abs_top_builddir@/tests/utils/common.sh" +if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../utils/utils.sh" +fi -curdir="$(cd -P "$(dirname "$0")" >/dev/null && pwd)" +# shellcheck source=../../utils/utils.sh +source "$UTILSSH" debug_info_data="${BT_DEBUG_INFO_PATH}/powerpc-linux-gnu" -"${curdir}/test_bin_info" \ +"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_bin_info" \ --foo-addr=0x23bc \ --printf-offset=0x114 \ --printf-lineno=36 \ diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu.in b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu old mode 100644 new mode 100755 similarity index 79% rename from tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu.in rename to tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu index 70e5b2cf..061a27a4 --- a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu.in +++ b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_powerpc64le-linux-gnu @@ -18,14 +18,18 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -NO_SH_TAP=1 -. "@abs_top_builddir@/tests/utils/common.sh" +if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../utils/utils.sh" +fi -curdir="$(cd -P "$(dirname "$0")" >/dev/null && pwd)" +# shellcheck source=../../utils/utils.sh +source "$UTILSSH" debug_info_data="${BT_DEBUG_INFO_PATH}/powerpc64le-linux-gnu" -"${curdir}/test_bin_info" \ +"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_bin_info" \ --foo-addr=0x2e7c \ --printf-offset=0x190 \ --printf-lineno=36 \ diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu.in b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu old mode 100644 new mode 100755 similarity index 79% rename from tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu.in rename to tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu index 8a29f287..b50da5ce --- a/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu.in +++ b/tests/plugins/flt.lttng-utils.debug-info/test_bin_info_x86_64-linux-gnu @@ -18,14 +18,18 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -NO_SH_TAP=1 -. "@abs_top_builddir@/tests/utils/common.sh" +if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../utils/utils.sh" +fi -curdir="$(cd -P "$(dirname "$0")" >/dev/null && pwd)" +# shellcheck source=../../utils/utils.sh +source "$UTILSSH" debug_info_data="${BT_DEBUG_INFO_PATH}/x86_64-linux-gnu" -"${curdir}/test_bin_info" \ +"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_bin_info" \ --foo-addr=0x2277 \ --printf-offset=0xf0 \ --printf-lineno=36 \ diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu.in b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu old mode 100644 new mode 100755 similarity index 72% rename from tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu.in rename to tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu index 15d3a2f6..d02227f6 --- a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu.in +++ b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu @@ -18,11 +18,13 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -NO_SH_TAP=1 -. "@abs_top_builddir@/tests/utils/common.sh" +if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../utils/utils.sh" +fi -curdir="$(cd -P "$(dirname "$0")" >/dev/null && pwd)" +# shellcheck source=../../utils/utils.sh +source "$UTILSSH" -debug_info_data="${BT_DEBUG_INFO_PATH}/powerpc-linux-gnu" - -"${curdir}/test_dwarf" "$debug_info_data" +"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_dwarf" "${BT_DEBUG_INFO_PATH}/i386-linux-gnu" diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu.in b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu old mode 100644 new mode 100755 similarity index 71% rename from tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu.in rename to tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu index cbb36503..eb4c3b02 --- a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu.in +++ b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc-linux-gnu @@ -18,11 +18,13 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -NO_SH_TAP=1 -. "@abs_top_builddir@/tests/utils/common.sh" +if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../utils/utils.sh" +fi -curdir="$(cd -P "$(dirname "$0")" >/dev/null && pwd)" +# shellcheck source=../../utils/utils.sh +source "$UTILSSH" -debug_info_data="${BT_DEBUG_INFO_PATH}/powerpc64le-linux-gnu" - -"${curdir}/test_dwarf" "$debug_info_data" +"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_dwarf" "${BT_DEBUG_INFO_PATH}/powerpc-linux-gnu" diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu new file mode 100755 index 00000000..ee4ba4ad --- /dev/null +++ b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_powerpc64le-linux-gnu @@ -0,0 +1,30 @@ +#!/bin/bash +# +# Copyright (C) 2015 Antoine Busque +# Copyright (C) 2019 Michael Jeanson +# +# 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. +# + +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" + +"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_dwarf" "${BT_DEBUG_INFO_PATH}/powerpc64le-linux-gnu" diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu.in b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu old mode 100644 new mode 100755 similarity index 71% rename from tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu.in rename to tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu index 8794bfac..ef5416fd --- a/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_i386-linux-gnu.in +++ b/tests/plugins/flt.lttng-utils.debug-info/test_dwarf_x86_64-linux-gnu @@ -18,11 +18,13 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -NO_SH_TAP=1 -. "@abs_top_builddir@/tests/utils/common.sh" +if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../utils/utils.sh" +fi -curdir="$(cd -P "$(dirname "$0")" >/dev/null && pwd)" +# shellcheck source=../../utils/utils.sh +source "$UTILSSH" -debug_info_data="${BT_DEBUG_INFO_PATH}/i386-linux-gnu" - -"${curdir}/test_dwarf" "$debug_info_data" +"${BT_TESTS_BUILDDIR}/plugins/flt.lttng-utils.debug-info/test_dwarf" "${BT_DEBUG_INFO_PATH}/x86_64-linux-gnu" diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info b/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info new file mode 100755 index 00000000..e5eb8de8 --- /dev/null +++ b/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info @@ -0,0 +1,31 @@ +#!/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. +# + +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" + +export BT_DEBUG_INFO_PATH + +run_python_bt2_test "${BT_TESTS_SRCDIR}/plugins/flt.lttng-utils.debug-info" "test_lttng_utils_debug_info.py" diff --git a/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info.in b/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info.in deleted file mode 100644 index 210e01a7..00000000 --- a/tests/plugins/flt.lttng-utils.debug-info/test_lttng_utils_debug_info.in +++ /dev/null @@ -1,38 +0,0 @@ -#!/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" - -PYTHON_BUILD_DIR="${BT_BUILD_PATH}/src/bindings/python/bt2/build/build_lib" -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/plugins" -export BABELTRACE_PLUGIN_PATH="${BT_BUILD_PATH}/src/plugins/utils:${BT_BUILD_PATH}/src/plugins/ctf:${BT_BUILD_PATH}/src/plugins/lttng-utils" -export BT_DEBUG_INFO_PATH - -if [ "x${MSYSTEM}" != "x" ]; then - export PATH="${BT_BUILD_PATH}/src/lib/.libs:${PATH}" -else - export LD_LIBRARY_PATH="${BT_BUILD_PATH}/src/lib/.libs:${LD_LIBRARY_PATH}" -fi - -PYTHONPATH="${PYTHON_BUILD_DIR}:${TESTS_UTILS_PYTHON_DIR}" \ - "@PYTHON@" "${TESTRUNNER_PY}" "${THIS_DIR}" 'test_lttng_utils_debug_info.py' -exit $? diff --git a/tests/plugins/src.ctf.fs/Makefile.am b/tests/plugins/src.ctf.fs/Makefile.am index 4082addf..73571141 100644 --- a/tests/plugins/src.ctf.fs/Makefile.am +++ b/tests/plugins/src.ctf.fs/Makefile.am @@ -1,3 +1,5 @@ SUBDIRS = succeed + dist_check_SCRIPTS = \ + query/test_query \ query/test_query_trace_info.py diff --git a/tests/plugins/src.ctf.fs/query/test_query.in b/tests/plugins/src.ctf.fs/query/test_query old mode 100644 new mode 100755 similarity index 73% rename from tests/plugins/src.ctf.fs/query/test_query.in rename to tests/plugins/src.ctf.fs/query/test_query index 9c5d9848..27405735 --- a/tests/plugins/src.ctf.fs/query/test_query.in +++ b/tests/plugins/src.ctf.fs/query/test_query @@ -16,10 +16,13 @@ # 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" +if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../../utils/utils.sh" +fi -TESTRUNNER_PY="$BT_SRC_PATH/tests/utils/python/testrunner.py" -THIS_DIR="$BT_SRC_PATH/tests/plugins/src.ctf.fs/query" +# shellcheck source=../../../utils/utils.sh +source "$UTILSSH" -exec "$BT_BUILD_PATH/tests/utils/test_python_bt2_env" python3 "$TESTRUNNER_PY" "$THIS_DIR" +run_python_bt2_test "${BT_TESTS_SRCDIR}/plugins/src.ctf.fs/query" diff --git a/tests/plugins/src.ctf.fs/succeed/test_succeed.in b/tests/plugins/src.ctf.fs/succeed/test_succeed old mode 100644 new mode 100755 similarity index 76% rename from tests/plugins/src.ctf.fs/succeed/test_succeed.in rename to tests/plugins/src.ctf.fs/succeed/test_succeed index a84b80b7..9cd77ba9 --- a/tests/plugins/src.ctf.fs/succeed/test_succeed.in +++ b/tests/plugins/src.ctf.fs/succeed/test_succeed @@ -22,12 +22,21 @@ # Such CTF traces to open either exist (in `tests/ctf-traces/succeed`) # or are generated by this test using local trace generators. -. "@abs_top_builddir@/tests/utils/diff.sh" +SH_TAP=1 -this_dir_relative="tests/plugins/src.ctf.fs/succeed" -this_dir_src="$BT_SRC_PATH/tests/data/plugins/src.ctf.fs/succeed" -this_dir_build="$BT_BUILD_PATH/$this_dir_relative" +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" + +this_dir_relative="plugins/src.ctf.fs/succeed" +this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" succeed_trace_dir="$BT_CTF_TRACES_PATH/succeed" +expect_dir="$BT_TESTS_DATADIR/$this_dir_relative" test_ctf_common_details_args="-p with-trace-name=no,with-stream-name=no" @@ -36,7 +45,7 @@ test_ctf_gen_single() { diag "Generating trace '$name'" bt_diff_details_ctf_gen_single "$this_dir_build/gen-trace-$name" \ - "$this_dir_src/trace-$name.expect" \ + "$expect_dir/trace-$name.expect" \ "$test_ctf_common_details_args -p with-uuid=no" ok $? "Generated trace '$name' gives the expected output" } @@ -45,7 +54,7 @@ test_ctf_single() { name="$1" bt_diff_details_ctf_single "$succeed_trace_dir/$name" \ - "$this_dir_src/trace-$name.expect" "$test_ctf_common_details_args" + "$expect_dir/trace-$name.expect" "$test_ctf_common_details_args" ok $? "Trace '$name' gives the expected output" } diff --git a/tests/python-plugin-provider/.gitignore b/tests/python-plugin-provider/.gitignore index a0f0c488..7446a35d 100644 --- a/tests/python-plugin-provider/.gitignore +++ b/tests/python-plugin-provider/.gitignore @@ -1,4 +1,2 @@ htmlcov .coverage -test_python_plugin_provider -test_python_plugin_provider_env diff --git a/tests/python-plugin-provider/test_python_plugin_provider b/tests/python-plugin-provider/test_python_plugin_provider new file mode 100755 index 00000000..978fcbc6 --- /dev/null +++ b/tests/python-plugin-provider/test_python_plugin_provider @@ -0,0 +1,34 @@ +#!/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. +# + +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" + +export PYTHON_PLUGIN_PROVIDER_TEST_PLUGIN_PATH="${BT_TESTS_SRCDIR}/python-plugin-provider/bt_plugin_test_python_plugin_provider.py" + +run_python_bt2_test \ + "${BT_TESTS_SRCDIR}/python-plugin-provider" \ + test_python_plugin_provider.py \ + "${BT_TESTS_BUILDDIR}/../src/python-plugin-provider/.libs" diff --git a/tests/python-plugin-provider/test_python_plugin_provider.in b/tests/python-plugin-provider/test_python_plugin_provider.in deleted file mode 100644 index b6fc05a3..00000000 --- a/tests/python-plugin-provider/test_python_plugin_provider.in +++ /dev/null @@ -1,38 +0,0 @@ -#!/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" - -export PYTHON_PLUGIN_PROVIDER_TEST_PLUGIN_PATH="${BT_SRC_PATH}/tests/python-plugin-provider/bt_plugin_test_python_plugin_provider.py" - -PYTHON_BUILD_DIR="${BT_BUILD_PATH}/src/bindings/python/bt2/build/build_lib" -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/python-plugin-provider" - -if [ "x${MSYSTEM}" != "x" ]; then - export PATH="${BT_BUILD_PATH}/src/lib/.libs:${BT_BUILD_PATH}/src/python-plugin-provider/.libs:${PATH}" -else - export LD_LIBRARY_PATH="${BT_BUILD_PATH}/src/lib/.libs:${BT_BUILD_PATH}/src/python-plugin-provider/.libs:${LD_LIBRARY_PATH}" -fi - -PYTHONPATH="${PYTHON_BUILD_DIR}:${TESTS_UTILS_PYTHON_DIR}" \ - "@PYTHON@" "${TESTRUNNER_PY}" "${THIS_DIR}" -exit $? diff --git a/tests/python-plugin-provider/test_python_plugin_provider_env.in b/tests/python-plugin-provider/test_python_plugin_provider_env.in deleted file mode 100644 index 4d585f05..00000000 --- a/tests/python-plugin-provider/test_python_plugin_provider_env.in +++ /dev/null @@ -1,34 +0,0 @@ -#!/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. -# - -. "@abs_top_builddir@/tests/utils/common.sh" - -export PYTHON_PLUGIN_PROVIDER_TEST_PLUGIN_PATH="${BT_SRC_PATH}/tests/python-plugin-provider/bt_plugin_test_python_plugin_provider.py" - -PYTHON_BUILD_DIR="${BT_BUILD_PATH}/src/bindings/python/bt2/build/build_lib" -TESTS_UTILS_PYTHON_DIR="${BT_SRC_PATH}/tests/utils/python" -export PYTHONPATH="${PYTHON_BUILD_DIR}:${TESTS_UTILS_PYTHON_DIR}" - -if [ "x${MSYSTEM}" != "x" ]; then - export PATH="${BT_BUILD_PATH}/src/lib/.libs:${BT_BUILD_PATH}/src/python-plugin-provider/.libs:${PATH}" -else - export LD_LIBRARY_PATH="${BT_BUILD_PATH}/src/lib/.libs:${BT_BUILD_PATH}/src/python-plugin-provider/.libs:${LD_LIBRARY_PATH}" -fi - -exec "$*" diff --git a/tests/utils/.gitignore b/tests/utils/.gitignore deleted file mode 100644 index a8402501..00000000 --- a/tests/utils/.gitignore +++ /dev/null @@ -1 +0,0 @@ -test_python_bt2_env diff --git a/tests/utils/Makefile.am b/tests/utils/Makefile.am index d010e2b0..4ce62c91 100644 --- a/tests/utils/Makefile.am +++ b/tests/utils/Makefile.am @@ -5,3 +5,7 @@ libtestcommon_la_SOURCES = common.c common.h # Directories added to EXTRA_DIST will be recursively copied to the distribution. EXTRA_DIST = python + +dist_check_SCRIPTS = \ + run_python_bt2 \ + utils.sh diff --git a/tests/utils/common.sh.in b/tests/utils/common.sh.in deleted file mode 100644 index 3f7e2a31..00000000 --- a/tests/utils/common.sh.in +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -BT_SRC_PATH="@abs_top_srcdir@" -BT_BUILD_PATH="@abs_top_builddir@" - -BT_BIN="${BT_BUILD_PATH}/src/cli/babeltrace2@EXEEXT@" -BT_CTF_TRACES_PATH="${BT_SRC_PATH}/tests/data/ctf-traces" -BT_DEBUG_INFO_PATH="${BT_SRC_PATH}/tests/data/debug-info" - -if [ "x${NO_SH_TAP}" = x ]; then - . "${BT_SRC_PATH}/tests/utils/tap/tap.sh" -fi diff --git a/tests/utils/diff.sh.in b/tests/utils/diff.sh.in deleted file mode 100644 index 7a38c7a4..00000000 --- a/tests/utils/diff.sh.in +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2019 - 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. - -. "@abs_top_builddir@/tests/utils/common.sh" - -# Checks the difference between: -# -# 1. What the CLI outputs when given the arguments "$1" (passed to -# `xargs`, so they can include quoted arguments). -# 2. The file with path "$2". -# -# Returns 0 if there's no difference, and 1 if there is, also printing -# said difference to the standard error. -bt_diff_cli() { - args="$1" - expected_file="$2" - temp_output_file="$(mktemp)" - temp_diff="$(mktemp)" - - # 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. - echo "$args" | xargs "$BT_BIN" 2>/dev/null | tr -d "\r" > "$temp_output_file" - - # Compare output with expected output - if ! diff "$temp_output_file" "$expected_file" 2>/dev/null >"$temp_diff"; then - echo "ERROR: for '$args': actual and expected outputs differ:" >&2 - cat "$temp_diff" >&2 - rm -rf "$temp_output_file" "$temp_diff" - return 1 - fi - - rm -f "$temp_output_file" "$temp_diff" -} - -# Checks the difference between: -# -# 1. What the CLI outputs when given the arguments: -# -# "$1" -c sink.text.details $3 -# -# 2. The file with path "$2". -# -# Parameter 3 is optional. -# -# Returns 0 if there's no difference, and 1 if there is, also printing -# said difference to the standard error. -bt_diff_details_ctf_single() { - trace_dir="$1" - expected_file="$2" - extra_details_args="" - - if [ $# -ge 3 ]; then - extra_details_args="$3" - fi - - # Compare using the CLI with `sink.text.details` - bt_diff_cli "\"$trace_dir\" -c sink.text.details $extra_details_args" "$expected_file" -} - -# Calls bt_diff_details_ctf_single(), except that "$1" is the path to a -# program which generates the CTF trace to compare to. The program "$1" -# receives the path to a temporary, empty directory where to write the -# CTF trace as its first argument. -bt_diff_details_ctf_gen_single() { - ctf_gen_prog_path="$1" - expected_file="$2" - extra_details_args="" - - if [ $# -ge 3 ]; then - extra_details_args="$3" - fi - - temp_trace_dir="$(mktemp -d)" - - # Run the CTF trace generator program to get a CTF trace - if ! "$ctf_gen_prog_path" "$temp_trace_dir" 2>/dev/null; then - echo "ERROR: \"$ctf_gen_prog_path\" \"$temp_trace_dir\" failed" >&2 - rm -rf "$temp_trace_dir" - return 1 - fi - - # Compare using the CLI with `sink.text.details` - bt_diff_details_ctf_single "$temp_trace_dir" "$expected_file" "$extra_details_args" - ret=$? - rm -rf "$temp_trace_dir" - return $ret -} diff --git a/tests/utils/python/testrunner.py b/tests/utils/python/testrunner.py index 6a3dbaba..cb1bdcda 100644 --- a/tests/utils/python/testrunner.py +++ b/tests/utils/python/testrunner.py @@ -49,6 +49,11 @@ if __name__ == '__main__': failfast = args.failfast tests = loader.discover(start_dir, pattern) + + if tests.countTestCases() < 1: + print("No tests matching '%s' found in '%s'" % (pattern, start_dir)) + sys.exit(1) + runner = TAPTestRunner(failfast=failfast) runner.set_stream(True) runner.set_format('{method_name}') diff --git a/tests/utils/run_python_bt2 b/tests/utils/run_python_bt2 new file mode 100755 index 00000000..bd9f05f9 --- /dev/null +++ b/tests/utils/run_python_bt2 @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Copyright (C) 2017 Philippe Proulx +# 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. +# + +# Execute a shell command in the appropriate environment to have access to the +# bt2 Python bindings. For example, one could use it to run a specific Python +# binding test case with: +# +# $ ./run_python_bt2 python3 -m unittest test_values.MapValueTestCase.test_deepcopy + +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" + +usage() { + echo "Usage: run_python_bt2 [PYTHON_BIN] ..." + echo "" + echo "Run a binary with the python environment set to use the 'bt2' module" + echo "from the build system prior to installation." + echo "" + echo "When building out of tree export the BT_TESTS_BUILDDIR variable with" + echo "the path to the built 'tests' directory." +} + +if [ "x$*" = "x" ]; then + usage +else + run_python_bt2 "${@}" +fi diff --git a/tests/utils/test_python_bt2_env.in b/tests/utils/test_python_bt2_env.in deleted file mode 100644 index b4ea36b5..00000000 --- a/tests/utils/test_python_bt2_env.in +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 - Philippe Proulx -# 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. -# - -# Execute a shell command in the appropriate environment to have access to the -# bt2 Python bindings. For example, one could use it to run a specific Python -# binding test case with: -# -# $ ./test_python_bt2_env python3 -m unittest test_values.MapValueTestCase.test_deepcopy - -NO_SH_TAP=1 -. "@abs_top_builddir@/tests/utils/common.sh" - -export BABELTRACE_PYTHON_BT2_NO_TRACEBACK=1 -export TEST_PLUGIN_PLUGINS_PATH="${BT_BUILD_PATH}/src/plugins" -export BABELTRACE_PLUGIN_PATH="${BT_BUILD_PATH}/src/plugins/ctf:${BT_BUILD_PATH}/src/plugins/utils:${BT_BUILD_PATH}/src/plugins/text" -export BT_CTF_TRACES_PATH - -PYTHON_BUILD_DIR="${BT_BUILD_PATH}/src/bindings/python/bt2/build/build_lib" -TESTS_UTILS_PYTHON_DIR="${BT_SRC_PATH}/tests/utils/python" -export PYTHONPATH="${PYTHON_BUILD_DIR}:${TESTS_UTILS_PYTHON_DIR}" - -if [ "x${MSYSTEM}" != "x" ]; then - export PATH="${BT_BUILD_PATH}/src/lib/.libs:${PATH}" -else - export LD_LIBRARY_PATH="${BT_BUILD_PATH}/src/lib/.libs:${LD_LIBRARY_PATH}" -fi - -exec "$@" diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh new file mode 100644 index 00000000..4557e8c8 --- /dev/null +++ b/tests/utils/utils.sh @@ -0,0 +1,258 @@ +#!/bin/bash + +# Copyright (c) 2019 Michael Jeanson +# Copyright (C) 2019 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; under 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# This file is meant to be sourced at the start of shell script-based tests. + + +# Error out when encountering an undefined variable +set -u + +scriptdir="$(dirname "${BASH_SOURCE[0]}")" + +# Allow overriding the source and build directories +if [ "x${BT_TESTS_SRCDIR:-}" = "x" ]; then + BT_TESTS_SRCDIR=$(realpath -s "$scriptdir/..") +fi +export BT_TESTS_SRCDIR + +if [ "x${BT_TESTS_BUILDDIR:-}" = "x" ]; then + BT_TESTS_BUILDDIR=$(realpath -s "$scriptdir/..") +fi +export BT_TESTS_BUILDDIR + +# By default, it will not source tap.sh. If you to tap output directly from +# the test script, define the 'SH_TAP' variable to '1' before sourcing this +# script. +if [ "x${SH_TAP:-}" = x1 ]; then + . "${BT_TESTS_SRCDIR}/utils/tap/tap.sh" +fi + +# Allow overriding the babeltrace2 executables +if [ "x${BT_TESTS_BT2_BIN:-}" = "x" ]; then + BT_TESTS_BT2_BIN=$(realpath -s "$BT_TESTS_BUILDDIR/../src/cli/babeltrace2") +fi +export BT_TESTS_BT2_BIN + +if [ "x${BT_TESTS_BT2LOG_BIN:-}" = "x" ]; then + BT_TESTS_BT2LOG_BIN=$(realpath -s "$BT_TESTS_BUILDDIR/../src/cli/babeltrace2-log") +fi +export BT_TESTS_BT2LOG_BIN + +# TODO: Remove when bindings/python/bt2/test_plugin.py is fixed +BT_PLUGINS_PATH="${BT_TESTS_BUILDDIR}/../src/plugins" + +# Allow overriding the babeltrace2 plugin path +if [ "x${BT_TESTS_BABELTRACE_PLUGIN_PATH:-}" = "x" ]; then + BT_TESTS_BABELTRACE_PLUGIN_PATH="${BT_PLUGINS_PATH}/ctf:${BT_PLUGINS_PATH}/utils:${BT_PLUGINS_PATH}/text" +fi + +# Allow overriding the babeltrace2 executables +if [ "x${BT_TESTS_PYTHONPATH:-}" = "x" ]; then + BT_TESTS_PYTHONPATH="${BT_TESTS_BUILDDIR}/../src/bindings/python/bt2/build/build_lib" +fi + + +### External Tools ### +if [ "x${BT_TESTS_AWK_BIN:-}" = "x" ]; then + BT_TESTS_AWK_BIN="awk" +fi +export BT_TESTS_AWK_BIN + +if [ "x${BT_TESTS_GREP_BIN:-}" = "x" ]; then + BT_TESTS_GREP_BIN="grep" +fi +export BT_TESTS_GREP_BIN + +if [ "x${BT_TESTS_PYTHON_BIN:-}" = "x" ]; then + BT_TESTS_PYTHON_BIN="python3" +fi +export BT_TESTS_PYTHON_BIN + +if [ "x${BT_TESTS_SED_BIN:-}" = "x" ]; then + BT_TESTS_SED_BIN="sed" +fi +export BT_TESTS_SED_BIN + + +# Data files path +BT_TESTS_DATADIR="${BT_TESTS_SRCDIR}/data" +BT_CTF_TRACES_PATH="${BT_TESTS_DATADIR}/ctf-traces" +BT_DEBUG_INFO_PATH="${BT_TESTS_DATADIR}/debug-info" + + +### Diff Functions ### + +# Checks the difference between: +# +# 1. What the CLI outputs when given the arguments "$1" (passed to +# `xargs`, so they can include quoted arguments). +# 2. The file with path "$2". +# +# Returns 0 if there's no difference, and 1 if there is, also printing +# said difference to the standard error. +bt_diff_cli() { + local args="$1" + local expected_file="$2" + local temp_output_file + local temp_diff + local ret=0 + + temp_output_file="$(mktemp)" + temp_diff="$(mktemp)" + + # 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. + echo "$args" | xargs "$BT_TESTS_BT2_BIN" 2>/dev/null | tr -d "\r" > "$temp_output_file" + + # Compare output with expected output + if ! diff "$temp_output_file" "$expected_file" 2>/dev/null >"$temp_diff"; then + echo "ERROR: for '$args': actual and expected outputs differ:" >&2 + cat "$temp_diff" >&2 + ret=1 + fi + + rm -f "$temp_output_file" "$temp_diff" + + return $ret +} + +# Checks the difference between: +# +# 1. What the CLI outputs when given the arguments: +# +# "$1" -c sink.text.details $3 +# +# 2. The file with path "$2". +# +# Parameter 3 is optional. +# +# Returns 0 if there's no difference, and 1 if there is, also printing +# said difference to the standard error. +bt_diff_details_ctf_single() { + local trace_dir="$1" + local expected_file="$2" + local extra_details_args="${3:-}" + + # Compare using the CLI with `sink.text.details` + bt_diff_cli "\"$trace_dir\" -c sink.text.details $extra_details_args" "$expected_file" +} + +# Calls bt_diff_details_ctf_single(), except that "$1" is the path to a +# program which generates the CTF trace to compare to. The program "$1" +# receives the path to a temporary, empty directory where to write the +# CTF trace as its first argument. +bt_diff_details_ctf_gen_single() { + local ctf_gen_prog_path="$1" + local expected_file="$2" + local extra_details_args="${3:-}" + + local temp_trace_dir + local ret + + temp_trace_dir="$(mktemp -d)" + + # Run the CTF trace generator program to get a CTF trace + if ! "$ctf_gen_prog_path" "$temp_trace_dir" 2>/dev/null; then + echo "ERROR: \"$ctf_gen_prog_path\" \"$temp_trace_dir\" failed" >&2 + rm -rf "$temp_trace_dir" + return 1 + fi + + # Compare using the CLI with `sink.text.details` + bt_diff_details_ctf_single "$temp_trace_dir" "$expected_file" "$extra_details_args" + ret=$? + rm -rf "$temp_trace_dir" + return $ret +} + + +### Functions ### + +check_coverage() { + coverage run "$@" +} + +# Execute a shell command in the appropriate environment to have access to the +# bt2 Python bindings. +run_python_bt2() { + local lib_search_var + local lib_search_path + + # Set the library search path so the python interpreter can load libbabeltrace2 + if [ "x${MSYSTEM:-}" != "x" ]; then + lib_search_var="PATH" + lib_search_path="${BT_TESTS_BUILDDIR}/../src/lib/.libs:${PATH:-}" + else + lib_search_var="LD_LIBRARY_PATH" + lib_search_path="${BT_TESTS_BUILDDIR}/../src/lib/.libs:${LD_LIBRARY_PATH:-}" + fi + if [ "x${test_lib_search_path:-}" != "x" ]; then + lib_search_path+=":${test_lib_search_path}" + fi + + env \ + BABELTRACE_PYTHON_BT2_NO_TRACEBACK=1 \ + BABELTRACE_PLUGIN_PATH="${BT_TESTS_BABELTRACE_PLUGIN_PATH}" \ + BT_CTF_TRACES_PATH="${BT_CTF_TRACES_PATH}" \ + BT_PLUGINS_PATH="${BT_PLUGINS_PATH}" \ + PYTHONPATH="${BT_TESTS_PYTHONPATH}:${BT_TESTS_SRCDIR}/utils/python" \ + "${lib_search_var}"="${lib_search_path}" \ + "$@" +} + +# Set the environment and run python tests in the directory. +# +# $1 : The directory containing the python test scripts +# $2 : The pattern to match python test script names (optional) +# $3 : Additionnal library search path (optional) +run_python_bt2_test() { + local test_dir="$1" + local test_pattern="${2:-}" # optional + local test_lib_search_path="${3:-}" # optional + + local ret + local test_runner_args=() + + test_runner_args+=("$test_dir") + if [ "x${test_pattern}" != "x" ]; then + test_runner_args+=("${test_pattern}") + fi + + if test "x${BT_TESTS_COVERAGE:-}" = "x1"; then + python_exec="check_coverage" + else + python_exec="${BT_TESTS_PYTHON_BIN}" + fi + + run_python_bt2 \ + "${python_exec}" \ + "${BT_TESTS_SRCDIR}/utils/python/testrunner.py" \ + "${test_runner_args[@]}" + ret=$? + + if test "x${BT_TESTS_COVERAGE_REPORT:-}" = "x1"; then + coverage report -m + fi + + if test "x${BT_TESTS_COVERAGE_HTML:-}" = "x1"; then + coverage html + fi + + return $ret +} -- 2.34.1