From dc4067c852b6eb1aea1c9298e7867d83f0820151 Mon Sep 17 00:00:00 2001 From: Oleksiy Vyalov Date: Wed, 26 Nov 2014 18:30:04 +0000 Subject: [PATCH] Fix several test failures on Linux/FreeBSD caused by compiler configuration and invalid environment. http://reviews.llvm.org/D6392 llvm-svn: 222845 --- lldb/test/lang/c/shared_lib/TestSharedLib.py | 16 ++++++++-------- .../TestSharedLibStrippedSymbols.py | 16 ++++++++-------- lldb/test/lldbtest.py | 6 +++++- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/lldb/test/lang/c/shared_lib/TestSharedLib.py b/lldb/test/lang/c/shared_lib/TestSharedLib.py index 5300182..1dcbaa4 100644 --- a/lldb/test/lang/c/shared_lib/TestSharedLib.py +++ b/lldb/test/lang/c/shared_lib/TestSharedLib.py @@ -40,12 +40,6 @@ class SharedLibTestCase(TestBase): # Find the line number to break inside main(). self.source = 'main.c' self.line = line_number(self.source, '// Set breakpoint 0 here.') - if sys.platform.startswith("freebsd") or sys.platform.startswith("linux"): - if "LD_LIBRARY_PATH" in os.environ: - self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.environ["LD_LIBRARY_PATH"] + ":" + os.getcwd()) - else: - self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.getcwd()) - self.addTearDownHook(lambda: self.runCmd("settings remove target.env-vars " + self.dylibPath)) self.shlib_names = ["foo"] def common_setup(self): @@ -59,8 +53,14 @@ class SharedLibTestCase(TestBase): # Break inside the foo function which takes a bar_ptr argument. lldbutil.run_break_set_by_file_and_line (self, self.source, self.line, num_expected_locations=1, loc_exact=True) - # Register our shared libraries for remote targets so they get automatically uploaded - environment = self.registerSharedLibrariesWithTarget(target, self.shlib_names) + if sys.platform.startswith("freebsd") or sys.platform.startswith("linux"): + if self.dylibPath in os.environ: + environment = [self.dylibPath + "=" + os.environ[self.dylibPath] + ":" + os.getcwd()] + else: + environment = [self.dylibPath + "=" + os.getcwd()] + else: + # Register our shared libraries for remote targets so they get automatically uploaded + environment = self.registerSharedLibrariesWithTarget(target, self.shlib_names) # Now launch the process, and do not stop at entry point. process = target.LaunchSimple (None, environment, self.get_process_working_directory()) diff --git a/lldb/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py b/lldb/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py index f940b11..aeaada2 100644 --- a/lldb/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py +++ b/lldb/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py @@ -40,12 +40,6 @@ class SharedLibStrippedTestCase(TestBase): # Find the line number to break inside main(). self.source = 'main.c' self.line = line_number(self.source, '// Set breakpoint 0 here.') - if sys.platform.startswith("freebsd") or sys.platform.startswith("linux"): - if "LD_LIBRARY_PATH" in os.environ: - self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.environ["LD_LIBRARY_PATH"] + ":" + os.getcwd()) - else: - self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.getcwd()) - self.addTearDownHook(lambda: self.runCmd("settings remove target.env-vars " + self.dylibPath)) self.shlib_names = ["foo"] def common_setup(self): @@ -59,8 +53,14 @@ class SharedLibStrippedTestCase(TestBase): # Break inside the foo function which takes a bar_ptr argument. lldbutil.run_break_set_by_file_and_line (self, self.source, self.line, num_expected_locations=1, loc_exact=True) - # Register our shared libraries for remote targets so they get automatically uploaded - environment = self.registerSharedLibrariesWithTarget(target, self.shlib_names) + if sys.platform.startswith("freebsd") or sys.platform.startswith("linux"): + if self.dylibPath in os.environ: + environment = [self.dylibPath + "=" + os.environ[self.dylibPath] + ":" + os.getcwd()] + else: + environment = [self.dylibPath + "=" + os.getcwd()] + else: + # Register our shared libraries for remote targets so they get automatically uploaded + environment = self.registerSharedLibrariesWithTarget(target, self.shlib_names) # Now launch the process, and do not stop at entry point. process = target.LaunchSimple (None, environment, self.get_process_working_directory()) diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index c926db4..7719a22 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -1231,6 +1231,10 @@ class Base(unittest2.TestCase): module = builder_module() return module.getCompiler() + def getCompilerBinary(self): + """Returns the compiler binary the test suite is running with.""" + return self.getCompiler().split()[0] + def getCompilerVersion(self): """ Returns a string that represents the compiler version. Supports: llvm, clang. @@ -1238,7 +1242,7 @@ class Base(unittest2.TestCase): from lldbutil import which version = 'unknown' - compiler = self.getCompiler() + compiler = self.getCompilerBinary() version_output = system([[which(compiler), "-v"]])[1] for line in version_output.split(os.linesep): m = re.search('version ([0-9\.]+)', line) -- 2.7.4