- 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}" \
- "$@"
+ # On Windows, an embedded Python interpreter needs a way to locate the path
+ # to its internal modules, set the prefix from python-config to the
+ # PYTHONHOME variable.
+ if [ "$BT_TESTS_OS_TYPE" = "mingw" ]; then
+ local -x PYTHONHOME
+
+ PYTHONHOME=$($BT_TESTS_PYTHON_CONFIG_BIN --prefix)
+ fi
+
+ # If AddressSanitizer is used, we must preload libasan.so so that
+ # libasan doesn't complain about not being the first loaded library.
+ #
+ # Python and sed (executed as part of the libtool wrapper) produce some
+ # leaks, so we must unfortunately disable leak detection. Append it to
+ # existing ASAN_OPTIONS, such that we override the user's value if it
+ # contains detect_leaks=1.
+ if [ "${BT_TESTS_ENABLE_ASAN:-}" = "1" ]; then
+ if ${BT_TESTS_CC_BIN} --version | head -n 1 | grep -q '^gcc'; then
+ lib_asan="$(${BT_TESTS_CC_BIN} -print-file-name=libasan.so)"
+ local -x LD_PRELOAD="${lib_asan}${LD_PRELOAD:+:}${LD_PRELOAD:-}"
+ fi
+
+ local -x "ASAN_OPTIONS=${ASAN_OPTIONS:-}${ASAN_OPTIONS:+,}detect_leaks=0"
+ fi
+
+ run_python "$@"