From 0aea016b064ea5e209f0ed1fb5bb575bb093a8a4 Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Wed, 27 Feb 2013 17:29:46 +0000 Subject: [PATCH] Cleanup TestUniqueTypes.py and add getCompilerVersion() to test harness - pull up logic to get compiler version from TestUniqueTypes.py into lldbtest.py - work around an GCC 4.6.3 issue llvm-svn: 176190 --- lldb/test/lang/cpp/unique-types/TestUniqueTypes.py | 21 +++++++-------------- lldb/test/lldbtest.py | 22 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py b/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py index 712c2bc..a1716b9 100644 --- a/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py +++ b/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py @@ -33,10 +33,16 @@ class UniqueTypesTestCase(TestBase): def unique_types(self): """Test for unique types of std::vector and std::vector.""" + + if "clang" in self.getCompiler() and int(self.getCompilerVersion().split('.')[0]) < 3: + self.skipTest("rdar://problem/9173060 lldb hangs while running unique-types for clang version < 3") + exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + # GCC 4.6.3 (but not 4.4, 4.6.5 or 4.7) encodes two locations for the 'return 0' statement in main.cpp + locs = 2 if "gcc" in self.getCompiler() and "4.6.3" in self.getCompilerVersion() else 1 + lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=locs, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) @@ -45,19 +51,6 @@ class UniqueTypesTestCase(TestBase): substrs = ['stopped', 'stop reason = breakpoint']) - if self.getCompiler().endswith('clang'): - import re - clang_version_output = system([lldbutil.which(self.getCompiler()), "-v"])[1] - #print "my output:", clang_version_output - for line in clang_version_output.split(os.linesep): - m = re.search('clang version ([0-9]+)\.', line) - #print "line:", line - if m: - clang_version = int(m.group(1)) - #print "clang version:", clang_version - if clang_version < 3: - self.skipTest("rdar://problem/9173060 lldb hangs while running unique-types for clang version < 3") - # Do a "frame variable --show-types longs" and verify "long" is in each line of output. self.runCmd("frame variable --show-types longs") output = self.res.GetOutput() diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index 766502a..d74299f 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -531,7 +531,7 @@ def skipOnLinux(func): def skipIfGcc(func): """Decorate the item to skip tests that should be skipped if building with gcc .""" if isinstance(func, type) and issubclass(func, unittest2.TestCase): - raise Exception("@skipOnLinux can only be used to decorate a test method") + raise Exception("@skipIfGcc can only be used to decorate a test method") @wraps(func) def wrapper(*args, **kwargs): from unittest2 import case @@ -543,7 +543,6 @@ def skipIfGcc(func): func(*args, **kwargs) return wrapper - class Base(unittest2.TestCase): """ Abstract base for performing lldb (see TestBase) or other generic tests (see @@ -1015,6 +1014,25 @@ class Base(unittest2.TestCase): module = builder_module() return module.getCompiler() + def getCompilerVersion(self): + """ Returns a string that represents the compiler version. + Supports: llvm, clang. + """ + from lldbutil import which + version = 'unknown' + + compiler = self.getCompiler() + version_output = system([which(compiler), "-v"])[1] + for line in version_output.split(os.linesep): + compiler_shortname = 'invalid' + for c in ["clang", "gcc"]: + if c in compiler: + compiler_shortname = c + m = re.search('%s version ([0-9\.]+)' % compiler_shortname, line) + if m: + version = m.group(1) + return version + def getRunOptions(self): """Command line option for -A and -C to run this test again, called from self.dumpSessionInfo().""" -- 2.7.4