Skip to content

Commit 0da0966

Browse files
committed
[lldb] Don't overwrite the dynamic loader library path for "driver tests"
We have a handful of tests that build a driver which links against LLDB. When running those binaries, we overwrite the dynamic loader library path to point to the build directory's libs dir, presumably to make sure we load LLDB from there. This above becomes an issue when you have libc++ enabled and the driver is linked against the system's libc++, but the dynamic loader flag forces it to pick up libc++ from the libs dir. We could try to make the logic for building the driver smarter and have it pick up the just-built libc++ like we do for our test binaries, but I don't think we need to overwrite the library path in the first place. The build logic to build these drivers already takes care to set the correct RPATH in the linker. This patch removes the logic and simplifies the tests.
1 parent ea226d6 commit 0da0966

File tree

6 files changed

+21
-90
lines changed

6 files changed

+21
-90
lines changed

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,21 +1594,6 @@ def invoke(self, obj, name, trace=False):
15941594
print(str(method) + ":", result, file=sbuf)
15951595
return result
15961596

1597-
def getLLDBLibraryEnvVal(self):
1598-
"""Returns the path that the OS-specific library search environment variable
1599-
(self.dylibPath) should be set to in order for a program to find the LLDB
1600-
library. If an environment variable named self.dylibPath is already set,
1601-
the new path is appended to it and returned.
1602-
"""
1603-
existing_library_path = (
1604-
os.environ[self.dylibPath] if self.dylibPath in os.environ else None
1605-
)
1606-
if existing_library_path:
1607-
return "%s:%s" % (existing_library_path, configuration.lldb_libs_dir)
1608-
if sys.platform.startswith("darwin") and configuration.lldb_framework_path:
1609-
return configuration.lldb_framework_path
1610-
return configuration.lldb_libs_dir
1611-
16121597
def getLibcPlusPlusLibs(self):
16131598
if self.getPlatform() in ("freebsd", "linux", "netbsd", "openbsd"):
16141599
return ["libc++.so.1"]

lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ def sanity_check_executable(self, exe_name):
3939
self.getBuildArtifact(self.source), "// Set breakpoint here."
4040
)
4141

42-
env_cmd = "settings set target.env-vars %s=%s" % (
43-
self.dylibPath,
44-
self.getLLDBLibraryEnvVal(),
45-
)
46-
if self.TraceOn():
47-
print("Set environment to: ", env_cmd)
48-
self.runCmd(env_cmd)
49-
5042
lldbutil.run_break_set_by_file_and_line(
5143
self, self.source, self.line_to_break, num_expected_locations=-1
5244
)
Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Test the lldb public C++ api for returning SBCommandReturnObject."""
22

3+
import subprocess
4+
35
from lldbsuite.test.decorators import *
46
from lldbsuite.test.lldbtest import *
57
from lldbsuite.test import lldbutil
@@ -14,20 +16,11 @@ class TestSBCommandReturnObject(TestBase):
1416
)
1517
@skipIfHostIncompatibleWithTarget
1618
def test_sb_command_return_object(self):
17-
env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
18-
1919
self.driver_exe = self.getBuildArtifact("command-return-object")
2020
self.buildDriver("main.cpp", self.driver_exe)
2121
self.addTearDownHook(lambda: os.remove(self.driver_exe))
2222

23-
if self.TraceOn():
24-
print("Running test %s" % self.driver_exe)
25-
check_call([self.driver_exe, self.driver_exe], env=env)
26-
else:
27-
with open(os.devnull, "w") as fnull:
28-
check_call(
29-
[self.driver_exe, self.driver_exe],
30-
env=env,
31-
stdout=fnull,
32-
stderr=fnull,
33-
)
23+
# check_call will raise a CalledProcessError if the executable doesn't
24+
# return exit code 0 to indicate success. We can let this exception go
25+
# - the test harness will recognize it as a test failure.
26+
subprocess.check_call([self.driver_exe, self.driver_exe])
Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Test the lldb public C++ api when doing multiple debug sessions simultaneously."""
22

33
import os
4+
import subprocess
45

56
import lldb
67
from lldbsuite.test.decorators import *
@@ -15,13 +16,6 @@ class TestMultipleSimultaneousDebuggers(TestBase):
1516
@skipIfWindows
1617
@skipIfHostIncompatibleWithTarget
1718
def test_multiple_debuggers(self):
18-
env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
19-
20-
# We need this in order to run under ASAN, in case only LLDB is ASANified.
21-
asan_options = os.getenv("ASAN_OPTIONS", None)
22-
if asan_options is not None:
23-
env["ASAN_OPTIONS"] = asan_options
24-
2519
self.driver_exe = self.getBuildArtifact("multi-process-driver")
2620
self.buildDriver("multi-process-driver.cpp", self.driver_exe)
2721
self.addTearDownHook(lambda: os.remove(self.driver_exe))
@@ -30,18 +24,7 @@ def test_multiple_debuggers(self):
3024
self.buildDriver("testprog.cpp", self.inferior_exe)
3125
self.addTearDownHook(lambda: os.remove(self.inferior_exe))
3226

33-
# check_call will raise a CalledProcessError if multi-process-driver
34-
# doesn't return exit code 0 to indicate success. We can let this
35-
# exception go - the test harness will recognize it as a test failure.
36-
37-
if self.TraceOn():
38-
print("Running test %s" % self.driver_exe)
39-
check_call([self.driver_exe, self.inferior_exe], env=env)
40-
else:
41-
with open(os.devnull, "w") as fnull:
42-
check_call(
43-
[self.driver_exe, self.inferior_exe],
44-
env=env,
45-
stdout=fnull,
46-
stderr=fnull,
47-
)
27+
# check_call will raise a CalledProcessError if the executable doesn't
28+
# return exit code 0 to indicate success. We can let this exception go
29+
# - the test harness will recognize it as a test failure.
30+
subprocess.check_call([self.driver_exe, self.inferior_exe])

lldb/test/API/api/multiple-targets/TestMultipleTargets.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,11 @@ class TestMultipleTargets(TestBase):
1919
@expectedFlakeyNetBSD
2020
@skipIfHostIncompatibleWithTarget
2121
def test_multiple_targets(self):
22-
env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
23-
2422
self.driver_exe = self.getBuildArtifact("multi-target")
2523
self.buildDriver("main.cpp", self.driver_exe)
2624
self.addTearDownHook(lambda: os.remove(self.driver_exe))
2725

28-
# check_call will raise a CalledProcessError if multi-process-driver doesn't return
29-
# exit code 0 to indicate success. We can let this exception go - the test harness
30-
# will recognize it as a test failure.
31-
32-
if self.TraceOn():
33-
print("Running test %s" % self.driver_exe)
34-
check_call([self.driver_exe, self.driver_exe], env=env)
35-
else:
36-
with open(os.devnull, "w") as fnull:
37-
check_call(
38-
[self.driver_exe, self.driver_exe],
39-
env=env,
40-
stdout=fnull,
41-
stderr=fnull,
42-
)
26+
# check_call will raise a CalledProcessError if the executable doesn't
27+
# return exit code 0 to indicate success. We can let this exception go
28+
# - the test harness will recognize it as a test failure.
29+
subprocess.check_call([self.driver_exe, self.driver_exe])

lldb/test/API/api/multithreaded/TestMultithreaded.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""Test the lldb public C++ api breakpoint callbacks."""
22

3-
# __package__ = "lldbsuite.test"
4-
5-
63
import os
4+
import subprocess
5+
76
from lldbsuite.test.decorators import *
87
from lldbsuite.test.lldbtest import *
98
from lldbsuite.test import lldbutil
@@ -114,18 +113,10 @@ def build_and_test(self, sources, test_name, args=None):
114113
test_exe = self.getBuildArtifact(test_name)
115114
exe = [test_exe, self.getBuildArtifact(self.inferior)]
116115

117-
env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
118-
if "LLDB_DEBUGSERVER_PATH" in os.environ:
119-
env["LLDB_DEBUGSERVER_PATH"] = os.environ["LLDB_DEBUGSERVER_PATH"]
120-
try:
121-
if self.TraceOn():
122-
print("Running test %s" % " ".join(exe))
123-
check_call(exe, env=env)
124-
else:
125-
with open(os.devnull, "w") as fnull:
126-
check_call(exe, env=env, stdout=fnull, stderr=fnull)
127-
except subprocess.CalledProcessError as e:
128-
self.fail(e)
116+
# check_call will raise a CalledProcessError if the executable doesn't
117+
# return exit code 0 to indicate success. We can let this exception go
118+
# - the test harness will recognize it as a test failure.
119+
subprocess.check_call(exe)
129120

130121
def build_program(self, sources, program):
131122
return self.buildDriver(sources, program)

0 commit comments

Comments
 (0)