Fix xpasses on the gcc buildbots using compiler versions to qualify the xfail.

- Note that this is not correct, as the failure is associated with build options of libc.so, however it's failing on a Debian buildbot that uses gcc 4.6.2 (and the real goal is a complete backtrace even with -fomit-frame-pointer).

- Adds helpers to lldbtest.py to check the expectedCompiler and expectedVersion, with an eventual goal of reducing the number of test decorators.
--- Currently allows a comparison operator and a compiler version to be specified.
--- Can be extended to support ranges of compiler versions.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@182155 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/lldbtest.py b/test/lldbtest.py
index 73344d5..ae81189 100644
--- a/test/lldbtest.py
+++ b/test/lldbtest.py
@@ -370,7 +370,7 @@
     wrapper.__dwarf_test__ = True
     return wrapper
 
-def expectedFailureGcc(bugnumber=None):
+def expectedFailureGcc(bugnumber=None, compiler_version=["=", None]):
      if callable(bugnumber):
         @wraps(bugnumber)
         def expectedFailureGcc_easy_wrapper(*args, **kwargs):
@@ -380,7 +380,7 @@
             try:
                 bugnumber(*args, **kwargs)
             except Exception:
-                if "gcc" in test_compiler:
+                if "gcc" in test_compiler and self.expectedVersion(compiler_version):
                     raise case._ExpectedFailure(sys.exc_info(),None)
                 else:
                     raise
@@ -397,7 +397,7 @@
                 try:
                     func(*args, **kwargs)
                 except Exception:
-                    if "gcc" in test_compiler:
+                    if "gcc" in test_compiler and self.expectedVersion(compiler_version):
                         raise case._ExpectedFailure(sys.exc_info(),bugnumber)
                     else:
                         raise
@@ -515,7 +515,7 @@
               return wrapper
         return expectedFailurei386_impl
 
-def expectedFailureLinux(bugnumber=None):
+def expectedFailureLinux(bugnumber=None, compilers=None):
      if callable(bugnumber):
         @wraps(bugnumber)
         def expectedFailureLinux_easy_wrapper(*args, **kwargs):
@@ -525,11 +525,11 @@
             try:
                 bugnumber(*args, **kwargs)
             except Exception:
-                if "linux" in platform:
+                if "linux" in platform and self.expectedCompiler(compilers):
                     raise case._ExpectedFailure(sys.exc_info(),None)
                 else:
                     raise
-            if "linux" in platform:
+            if "linux" in platform and self.expectedCompiler(compilers):
                 raise case._UnexpectedSuccess(sys.exc_info(),None)
         return expectedFailureLinux_easy_wrapper
      else:
@@ -542,11 +542,11 @@
                 try:
                     func(*args, **kwargs)
                 except Exception:
-                    if "linux" in platform:
+                    if "linux" in platform and self.expectedCompiler(compilers):
                         raise case._ExpectedFailure(sys.exc_info(),bugnumber)
                     else:
                         raise
-                if "linux" in platform:
+                if "linux" in platform and self.expectedCompiler(compilers):
                     raise case._UnexpectedSuccess(sys.exc_info(),bugnumber)
               return wrapper
         return expectedFailureLinux_impl
@@ -1151,6 +1151,32 @@
                 version = m.group(1)
         return version
 
+    def expectedVersion(self, compiler_version):
+        """Determines if compiler_version matches the current tool chain."""
+        if (compiler_version == None):
+            return True
+        operator = str(compiler_version[0])
+        version = compiler_version[1]
+
+        if (version == None):
+            return True
+        if (operator == '>'):
+            return self.getCompilerVersion() > version
+        if (operator == '>=' or operator == '=>'): 
+            return self.getCompilerVersion() >= version
+        if (operator == '<'):
+            return self.getCompilerVersion() < version
+        if (operator == '<=' or operator == '=<'):
+            return self.getCompilerVersion() <= version
+        if (operator == '!=' or operator == '!' or operator == 'not'):
+            return str(version) not in str(self.getCompilerVersion())
+        return str(version) in str(self.getCompilerVersion())
+
+    def expectedCompiler(self, compilers):
+        if (compilers == None):
+            return True
+        return self.getCompiler() in compilers
+
     def getRunOptions(self):
         """Command line option for -A and -C to run this test again, called from
         self.dumpSessionInfo()."""