diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py index 860a755dff100..480cebc5f0926 100644 --- a/lldb/test/Shell/lit.cfg.py +++ b/lldb/test/Shell/lit.cfg.py @@ -219,3 +219,8 @@ def calculate_arch_features(arch_string): config.available_features.add("ld_new-bug") except: pass + +# Some shell tests dynamically link with python.dll and need to know the +# location of the Python libraries. This ensures that we use the same +# version of Python that was used to build lldb to run our tests. +config.environment["PYTHONHOME"] = config.python_root_dir diff --git a/lldb/test/Shell/lit.site.cfg.py.in b/lldb/test/Shell/lit.site.cfg.py.in index 330de00fec3e1..30b8fa46af78d 100644 --- a/lldb/test/Shell/lit.site.cfg.py.in +++ b/lldb/test/Shell/lit.site.cfg.py.in @@ -19,6 +19,7 @@ config.python_executable = "@Python3_EXECUTABLE@" config.swiftc = "@LLDB_SWIFTC@" config.swift_libs_dir = '@LLDB_SWIFT_LIBS@' config.lldb_enable_swift = @LLDB_ENABLE_SWIFT_SUPPORT@ +config.python_root_dir = "@Python3_ROOT_DIR@" config.have_zlib = @LLVM_ENABLE_ZLIB@ config.objc_gnustep_dir = "@LLDB_TEST_OBJC_GNUSTEP_DIR@" config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@ diff --git a/lldb/test/Unit/lit.cfg.py b/lldb/test/Unit/lit.cfg.py index 916a82b2ae6d4..baabfa9c9c6ef 100644 --- a/lldb/test/Unit/lit.cfg.py +++ b/lldb/test/Unit/lit.cfg.py @@ -33,6 +33,7 @@ ] ) llvm_config.with_environment("PATH", os.path.dirname(sys.executable), append_path=True) +config.environment["PYTHONHOME"] = config.python_root_dir # Enable sanitizer runtime flags. config.environment["ASAN_OPTIONS"] = "detect_stack_use_after_return=1" diff --git a/lldb/test/Unit/lit.site.cfg.py.in b/lldb/test/Unit/lit.site.cfg.py.in index b22af0f381439..a4b16765644d1 100644 --- a/lldb/test/Unit/lit.site.cfg.py.in +++ b/lldb/test/Unit/lit.site.cfg.py.in @@ -10,6 +10,7 @@ config.lldb_obj_root = "@LLDB_BINARY_DIR@" config.lldb_src_root = "@LLDB_SOURCE_DIR@" config.target_triple = "@LLVM_TARGET_TRIPLE@" config.python_executable = "@Python3_EXECUTABLE@" +config.python_root_dir = "@Python3_ROOT_DIR@" import lit.llvm lit.llvm.initialize(lit_config, config)