X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Futils%2Futils.sh;h=8bf9df896509c3a6a7998174ed9da8f4b1d56fe2;hb=717a01a712b427130c6ebb23940e65addb6ed65a;hp=d40011a127398e50c8fff84628b25e579111887d;hpb=1e14ec653e366e2781f59e03ac619748f345d6d1;p=babeltrace.git diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index d40011a1..8bf9df89 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -111,6 +111,8 @@ if [ -z "${BT_TESTS_PYTHON_BIN:-}" ]; then fi export BT_TESTS_PYTHON_BIN +BT_TESTS_PYTHON_VERSION=$($BT_TESTS_PYTHON_BIN -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))') + if [ -z "${BT_TESTS_PYTHON_CONFIG_BIN:-}" ]; then BT_TESTS_PYTHON_CONFIG_BIN="python3-config" fi @@ -151,7 +153,7 @@ fi # Remove CR characters in file "$1". bt_remove_cr() { - "$BT_TESTS_SED_BIN" -i 's/\r//g' "$1" + "$BT_TESTS_SED_BIN" -i'' -e 's/\r//g' "$1" } # Run the Babeltrace CLI, redirecting stdout and stderr to specified files. @@ -305,7 +307,15 @@ check_coverage() { # Execute a shell command in the appropriate environment to access the Python # test utility modules in `tests/utils/python`. run_python() { - PYTHONPATH="${BT_TESTS_SRCDIR}/utils/python${PYTHONPATH:+:}${PYTHONPATH:-}" "$@" + local our_pythonpath="${BT_TESTS_SRCDIR}/utils/python" + + if [[ $BT_TESTS_PYTHON_VERSION = 3.4 ]]; then + # Add a local directory containing a `typing.py` to `PYTHONPATH` for + # Python 3.4 which doesn't offer the `typing` module. + our_pythonpath="$our_pythonpath:${BT_TESTS_SRCDIR}/utils/python/typing" + fi + + PYTHONPATH="${our_pythonpath}${PYTHONPATH:+:}${PYTHONPATH:-}" "$@" } # Execute a shell command in the appropriate environment to have access to the @@ -399,3 +409,16 @@ run_python_bt2_test() { return $ret } + +# Generate a CTF trace using `mctf.py`. +# +# $1: Input filename +# $2: Base directory path for output files +gen_mctf_trace() { + local input_file="$1" + local base_dir="$2" + + diag "Running: ${BT_TESTS_PYTHON_BIN} ${BT_TESTS_SRCDIR}/utils/python/mctf.py --base-dir ${base_dir} ${input_file}" + "${BT_TESTS_PYTHON_BIN}" "${BT_TESTS_SRCDIR}/utils/python/mctf.py" \ + --base-dir "${base_dir}" "${input_file}" +}