Author: Jonas Devlieghere Date: 2024-02-16T08:47:38-08:00 New Revision: 0da0966da4b813386a85cf70ae0d0efc7cb2eaea
URL: https://github.com/llvm/llvm-project/commit/0da0966da4b813386a85cf70ae0d0efc7cb2eaea DIFF: https://github.com/llvm/llvm-project/commit/0da0966da4b813386a85cf70ae0d0efc7cb2eaea.diff LOG: [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. Added: Modified: lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py lldb/test/API/api/multiple-targets/TestMultipleTargets.py lldb/test/API/api/multithreaded/TestMultithreaded.py Removed: ################################################################################ diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 018f2a06980a88..493152166094e8 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1594,21 +1594,6 @@ def invoke(self, obj, name, trace=False): print(str(method) + ":", result, file=sbuf) return result - def getLLDBLibraryEnvVal(self): - """Returns the path that the OS-specific library search environment variable - (self.dylibPath) should be set to in order for a program to find the LLDB - library. If an environment variable named self.dylibPath is already set, - the new path is appended to it and returned. - """ - existing_library_path = ( - os.environ[self.dylibPath] if self.dylibPath in os.environ else None - ) - if existing_library_path: - return "%s:%s" % (existing_library_path, configuration.lldb_libs_dir) - if sys.platform.startswith("darwin") and configuration.lldb_framework_path: - return configuration.lldb_framework_path - return configuration.lldb_libs_dir - def getLibcPlusPlusLibs(self): if self.getPlatform() in ("freebsd", "linux", "netbsd", "openbsd"): return ["libc++.so.1"] diff --git a/lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py b/lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py index f2cd2eaef604f9..60ca8557d60b97 100644 --- a/lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py +++ b/lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py @@ -39,14 +39,6 @@ def sanity_check_executable(self, exe_name): self.getBuildArtifact(self.source), "// Set breakpoint here." ) - env_cmd = "settings set target.env-vars %s=%s" % ( - self.dylibPath, - self.getLLDBLibraryEnvVal(), - ) - if self.TraceOn(): - print("Set environment to: ", env_cmd) - self.runCmd(env_cmd) - lldbutil.run_break_set_by_file_and_line( self, self.source, self.line_to_break, num_expected_locations=-1 ) diff --git a/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py b/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py index e992f62ba91441..f2dbbbd7b4d428 100644 --- a/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py +++ b/lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py @@ -1,5 +1,7 @@ """Test the lldb public C++ api for returning SBCommandReturnObject.""" +import subprocess + from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil @@ -14,20 +16,11 @@ class TestSBCommandReturnObject(TestBase): ) @skipIfHostIncompatibleWithTarget def test_sb_command_return_object(self): - env = {self.dylibPath: self.getLLDBLibraryEnvVal()} - self.driver_exe = self.getBuildArtifact("command-return-object") self.buildDriver("main.cpp", self.driver_exe) self.addTearDownHook(lambda: os.remove(self.driver_exe)) - if self.TraceOn(): - print("Running test %s" % self.driver_exe) - check_call([self.driver_exe, self.driver_exe], env=env) - else: - with open(os.devnull, "w") as fnull: - check_call( - [self.driver_exe, self.driver_exe], - env=env, - stdout=fnull, - stderr=fnull, - ) + # check_call will raise a CalledProcessError if the executable doesn't + # return exit code 0 to indicate success. We can let this exception go + # - the test harness will recognize it as a test failure. + subprocess.check_call([self.driver_exe, self.driver_exe]) diff --git a/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py b/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py index b818268f2efa80..4083c57aa5a3ac 100644 --- a/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py +++ b/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py @@ -1,6 +1,7 @@ """Test the lldb public C++ api when doing multiple debug sessions simultaneously.""" import os +import subprocess import lldb from lldbsuite.test.decorators import * @@ -15,13 +16,6 @@ class TestMultipleSimultaneousDebuggers(TestBase): @skipIfWindows @skipIfHostIncompatibleWithTarget def test_multiple_debuggers(self): - env = {self.dylibPath: self.getLLDBLibraryEnvVal()} - - # We need this in order to run under ASAN, in case only LLDB is ASANified. - asan_options = os.getenv("ASAN_OPTIONS", None) - if asan_options is not None: - env["ASAN_OPTIONS"] = asan_options - self.driver_exe = self.getBuildArtifact("multi-process-driver") self.buildDriver("multi-process-driver.cpp", self.driver_exe) self.addTearDownHook(lambda: os.remove(self.driver_exe)) @@ -30,18 +24,7 @@ def test_multiple_debuggers(self): self.buildDriver("testprog.cpp", self.inferior_exe) self.addTearDownHook(lambda: os.remove(self.inferior_exe)) - # check_call will raise a CalledProcessError if multi-process-driver - # doesn't return exit code 0 to indicate success. We can let this - # exception go - the test harness will recognize it as a test failure. - - if self.TraceOn(): - print("Running test %s" % self.driver_exe) - check_call([self.driver_exe, self.inferior_exe], env=env) - else: - with open(os.devnull, "w") as fnull: - check_call( - [self.driver_exe, self.inferior_exe], - env=env, - stdout=fnull, - stderr=fnull, - ) + # check_call will raise a CalledProcessError if the executable doesn't + # return exit code 0 to indicate success. We can let this exception go + # - the test harness will recognize it as a test failure. + subprocess.check_call([self.driver_exe, self.inferior_exe]) diff --git a/lldb/test/API/api/multiple-targets/TestMultipleTargets.py b/lldb/test/API/api/multiple-targets/TestMultipleTargets.py index a2e0f08d3b3bc7..5c45820af030c2 100644 --- a/lldb/test/API/api/multiple-targets/TestMultipleTargets.py +++ b/lldb/test/API/api/multiple-targets/TestMultipleTargets.py @@ -19,24 +19,11 @@ class TestMultipleTargets(TestBase): @expectedFlakeyNetBSD @skipIfHostIncompatibleWithTarget def test_multiple_targets(self): - env = {self.dylibPath: self.getLLDBLibraryEnvVal()} - self.driver_exe = self.getBuildArtifact("multi-target") self.buildDriver("main.cpp", self.driver_exe) self.addTearDownHook(lambda: os.remove(self.driver_exe)) - # check_call will raise a CalledProcessError if multi-process-driver doesn't return - # exit code 0 to indicate success. We can let this exception go - the test harness - # will recognize it as a test failure. - - if self.TraceOn(): - print("Running test %s" % self.driver_exe) - check_call([self.driver_exe, self.driver_exe], env=env) - else: - with open(os.devnull, "w") as fnull: - check_call( - [self.driver_exe, self.driver_exe], - env=env, - stdout=fnull, - stderr=fnull, - ) + # check_call will raise a CalledProcessError if the executable doesn't + # return exit code 0 to indicate success. We can let this exception go + # - the test harness will recognize it as a test failure. + subprocess.check_call([self.driver_exe, self.driver_exe]) diff --git a/lldb/test/API/api/multithreaded/TestMultithreaded.py b/lldb/test/API/api/multithreaded/TestMultithreaded.py index 9f2756fcd46fc9..07c9f5b9bbcca3 100644 --- a/lldb/test/API/api/multithreaded/TestMultithreaded.py +++ b/lldb/test/API/api/multithreaded/TestMultithreaded.py @@ -1,9 +1,8 @@ """Test the lldb public C++ api breakpoint callbacks.""" -# __package__ = "lldbsuite.test" - - import os +import subprocess + from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil @@ -114,18 +113,10 @@ def build_and_test(self, sources, test_name, args=None): test_exe = self.getBuildArtifact(test_name) exe = [test_exe, self.getBuildArtifact(self.inferior)] - env = {self.dylibPath: self.getLLDBLibraryEnvVal()} - if "LLDB_DEBUGSERVER_PATH" in os.environ: - env["LLDB_DEBUGSERVER_PATH"] = os.environ["LLDB_DEBUGSERVER_PATH"] - try: - if self.TraceOn(): - print("Running test %s" % " ".join(exe)) - check_call(exe, env=env) - else: - with open(os.devnull, "w") as fnull: - check_call(exe, env=env, stdout=fnull, stderr=fnull) - except subprocess.CalledProcessError as e: - self.fail(e) + # check_call will raise a CalledProcessError if the executable doesn't + # return exit code 0 to indicate success. We can let this exception go + # - the test harness will recognize it as a test failure. + subprocess.check_call(exe) def build_program(self, sources, program): return self.buildDriver(sources, program) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits