-# Execute a shell command in the appropriate environment to have access to the
-# bt2 Python bindings.
-run_python_bt2() {
- local lib_asan
- local -x "BABELTRACE_PYTHON_BT2_NO_TRACEBACK=1"
- local -x "BABELTRACE_PLUGIN_PATH=${BT_TESTS_BABELTRACE_PLUGIN_PATH}"
- local -x "LIBBABELTRACE2_PLUGIN_PROVIDER_DIR=${BT_TESTS_PROVIDER_DIR}"
- local -x "BT_TESTS_DATADIR=${BT_TESTS_DATADIR}"
- local -x "BT_CTF_TRACES_PATH=${BT_CTF_TRACES_PATH}"
- local -x "BT_PLUGINS_PATH=${BT_PLUGINS_PATH}"
- local -x "PYTHONPATH=${BT_TESTS_PYTHONPATH}${PYTHONPATH:+:}${PYTHONPATH:-}"
-
- local main_lib_path="${BT_TESTS_BUILDDIR}/../src/lib/.libs"
-
- # Set the library search path so the python interpreter can load libbabeltrace2
- if [ "$BT_TESTS_OS_TYPE" = "mingw" ] || [ "$BT_TESTS_OS_TYPE" = "cygwin" ]; then
- local -x PATH="${main_lib_path}${PATH:+:}${PATH:-}"
- elif [ "$BT_TESTS_OS_TYPE" = "darwin" ]; then
- local -x DYLD_LIBRARY_PATH="${main_lib_path}${DYLD_LIBRARY_PATH:+:}${DYLD_LIBRARY_PATH:-}"
+# Executes a command within an environment which can import the testing
+# Python modules (in `tests/utils/python`) and the `bt2` Python package.
+bt_run_in_py_env() {
+ local -x BABELTRACE_PLUGIN_PATH=$BT_TESTS_BABELTRACE_PLUGIN_PATH
+ local -x LIBBABELTRACE2_PLUGIN_PROVIDER_DIR=$BT_TESTS_PROVIDER_DIR
+ local -x BT_TESTS_DATADIR=$BT_TESTS_DATADIR
+ local -x BT_CTF_TRACES_PATH=$BT_CTF_TRACES_PATH
+ local -x BT_PLUGINS_PATH=$_bt_tests_plugins_path
+ local -x PYTHONPATH=$BT_TESTS_PYTHONPATH${PYTHONPATH:+:}${PYTHONPATH:-}
+ local -r main_lib_path=$BT_TESTS_BUILDDIR/../src/lib/.libs
+
+ # Set the library search path so that the Python 3 interpreter can
+ # load `libbabeltrace2`.
+ if [[ $BT_TESTS_OS_TYPE == mingw || $BT_TESTS_OS_TYPE == cygwin ]]; then
+ local -x PATH=$main_lib_path${PATH:+:}${PATH:-}
+ elif [[ $BT_TESTS_OS_TYPE == darwin ]]; then
+ local -x DYLD_LIBRARY_PATH=$main_lib_path${DYLD_LIBRARY_PATH:+:}${DYLD_LIBRARY_PATH:-}