Skip to content

Commit 7cabcdb

Browse files
authored
[debuginfo-tests] Use built lldb for testing if available (#131681)
The cross-project-tests's debuginfo-tests don't rely on lldb being built to run. While this is a good, a bug in the system lldb can cause a test to fail with no way of fixing it. This patch makes it so the tests use the built lldb instead if it's available.
1 parent 02744c5 commit 7cabcdb

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

cross-project-tests/debuginfo-tests/llgdb-tests/llgdb.py

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
# Auto-detect lldb python module.
99
import subprocess, platform, os, sys
1010

11+
# Set the path to look first for the built lldb (in case it exists).
12+
lldb_python_path = os.environ["LLDB_PYTHON_PATH"]
13+
if len(lldb_python_path) > 0:
14+
sys.path.insert(0, lldb_python_path)
15+
1116
try:
1217
# Just try for LLDB in case PYTHONPATH is already correctly setup.
1318
import lldb

cross-project-tests/debuginfo-tests/llgdb-tests/test_debuginfo.pl

+5-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@
5656
if (!$my_debugger) {
5757
if ($use_lldb) {
5858
my $path = dirname(Cwd::abs_path($0));
59-
$my_debugger = "/usr/bin/xcrun python3 $path/llgdb.py";
59+
my $python_exec_path = $ENV{'PYTHON_EXEC_PATH'};
60+
if (!$python_exec_path) {
61+
$python_exec_path = 'python3';
62+
}
63+
$my_debugger = "LLDB_PYTHON_PATH=$ENV{'LLDB_PYTHON_PATH'} /usr/bin/xcrun $python_exec_path $path/llgdb.py";
6064
} else {
6165
$my_debugger = "gdb";
6266
}

cross-project-tests/lit.cfg.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,21 @@
3434

3535
llvm_config.use_default_substitutions()
3636

37+
lldb_python_path = os.path.join(
38+
config.llvm_libs_dir,
39+
f"python{sys.version_info.major}.{sys.version_info.minor}",
40+
"site-packages",
41+
)
42+
python_exec_path = sys.executable
3743
tools = [
3844
ToolSubst(
3945
"%test_debuginfo",
40-
command=os.path.join(
46+
command="PYTHON_EXEC_PATH="
47+
+ python_exec_path
48+
+ " LLDB_PYTHON_PATH="
49+
+ lldb_python_path
50+
+ " "
51+
+ os.path.join(
4152
config.cross_project_tests_src_root,
4253
"debuginfo-tests",
4354
"llgdb-tests",

0 commit comments

Comments
 (0)