From e23e08c478a341565d48a1b37dd2ad554be6b84e Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 22 Jul 2019 17:36:02 -0400 Subject: [PATCH] tests: fix Python plugin provider tests on Windows On Windows, the embedded Python interpreter in the Python plugin provider can't automatically locate the path to it's own modules. Set the PYTHONHOME variable to the proper value in 'run_python_bt2()'. Signed-off-by: Michael Jeanson Change-Id: Ie30ac3212a208d77654add78604c534c05efe518 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1748 Reviewed-by: Philippe Proulx --- tests/Makefile.am | 1 + tests/utils/utils.sh | 43 ++++++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index d004b03f..7ed75415 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -116,6 +116,7 @@ LOG_DRIVER = env AM_TAP_AWK='$(AWK)' \ BT_TESTS_AWK_BIN="$(AWK)" \ BT_TESTS_GREP_BIN="$(GREP)" \ BT_TESTS_PYTHON_BIN="$(PYTHON)" \ + BT_TESTS_PYTHON_CONFIG_BIN="$(PYTHON_CONFIG)" \ BT_TESTS_SED_BIN="$(SED)" \ $(SHELL) $(srcdir)/utils/tap-driver.sh diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index baef441a..d6fcf303 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -120,6 +120,11 @@ if [ "x${BT_TESTS_PYTHON_BIN:-}" = "x" ]; then fi export BT_TESTS_PYTHON_BIN +if [ "x${BT_TESTS_PYTHON_CONFIG_BIN:-}" = "x" ]; then + BT_TESTS_PYTHON_CONFIG_BIN="python3-config" +fi +export BT_TESTS_PYTHON_BIN + if [ "x${BT_TESTS_SED_BIN:-}" = "x" ]; then BT_TESTS_SED_BIN="sed" fi @@ -247,32 +252,36 @@ check_coverage() { # 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 + local env_args + + env_args=( + "BABELTRACE_PYTHON_BT2_NO_TRACEBACK=1" \ + "BABELTRACE_PLUGIN_PATH=${BT_TESTS_BABELTRACE_PLUGIN_PATH}" \ + "LIBBABELTRACE2_PLUGIN_PROVIDER_DIR=${BT_TESTS_PROVIDER_DIR}" \ + "BT_CTF_TRACES_PATH=${BT_CTF_TRACES_PATH}" \ + "BT_PLUGINS_PATH=${BT_PLUGINS_PATH}" \ + "PYTHONPATH=${BT_TESTS_PYTHONPATH}:${BT_TESTS_SRCDIR}/utils/python" + ) local main_lib_path="${BT_TESTS_BUILDDIR}/../src/lib/.libs" # Set the library search path so the python interpreter can load libbabeltrace2 if [ "$BT_OS_TYPE" = "mingw" ] || [ "$BT_OS_TYPE" = "cygwin" ]; then - lib_search_var="PATH" - lib_search_path="${main_lib_path}:${PATH:-}" + env_args+=("PATH=${main_lib_path}:${PATH:-}") elif [ "$BT_OS_TYPE" = "darwin" ]; then - lib_search_var="DYLD_LIBRARY_PATH" - lib_search_path="${main_lib_path}:${DYLD_LIBRARY_PATH:-}" + env_args+=("DYLD_LIBRARY_PATH=${main_lib_path}:${DYLD_LIBRARY_PATH:-}") else - lib_search_var="LD_LIBRARY_PATH" - lib_search_path="${main_lib_path}:${LD_LIBRARY_PATH:-}" + env_args+=("LD_LIBRARY_PATH=${main_lib_path}:${LD_LIBRARY_PATH:-}") + fi + + # On Windows, an embedded Python interpreter needs a way to locate the path + # to it's internal modules, set the prefix from python-config to the + # PYTHONHOME variable. + if [ "$BT_OS_TYPE" = "mingw" ]; then + env_args+=("PYTHONHOME=$($BT_TESTS_PYTHON_CONFIG_BIN --prefix)") fi - env \ - BABELTRACE_PYTHON_BT2_NO_TRACEBACK=1 \ - BABELTRACE_PLUGIN_PATH="${BT_TESTS_BABELTRACE_PLUGIN_PATH}" \ - LIBBABELTRACE2_PLUGIN_PROVIDER_DIR=${BT_TESTS_PROVIDER_DIR} \ - 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}" \ - "$@" + env "${env_args[@]}" "$@" } # Set the environment and run python tests in the directory. -- 2.34.1