[Lldb-commits] [lldb] r128162 - in /lldb/trunk/test: cpp/virtual/TestVirtual.py lldbtest.py lldbutil.py types/AbstractBase.py unique-types/TestUniqueTypes.py

Johnny Chen johnny.chen at apple.com
Wed Mar 23 13:28:59 PDT 2011


Author: johnny
Date: Wed Mar 23 15:28:59 2011
New Revision: 128162

URL: http://llvm.org/viewvc/llvm-project?rev=128162&view=rev
Log:
Turns out that the test failure wrt:

    rdar://problem/9173060 lldb hangs while running unique-types

disappears if running with clang version >= 3.  Modify the TestUniqueTypes.py
to detect if we are running with clang version < 3 and, if true, skip the test.

Update the lldbtest.system() function to return a tuple of (stdoutdata, stderrdata)
since we need the stderr data from "clang -v" command.  Modify existing clients of
lldbtest.system() to now use, for example:

         # First, capture the golden output emitted by the oracle, i.e., the
         # series of printf statements.
-        go = system("./a.out", sender=self)
+        go = system("./a.out", sender=self)[0]
         # This golden list contains a list of (variable, value) pairs extracted
         # from the golden output.
         gl = []

And add two utility functions to lldbutil.py.

Modified:
    lldb/trunk/test/cpp/virtual/TestVirtual.py
    lldb/trunk/test/lldbtest.py
    lldb/trunk/test/lldbutil.py
    lldb/trunk/test/types/AbstractBase.py
    lldb/trunk/test/unique-types/TestUniqueTypes.py

Modified: lldb/trunk/test/cpp/virtual/TestVirtual.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/virtual/TestVirtual.py?rev=128162&r1=128161&r2=128162&view=diff
==============================================================================
--- lldb/trunk/test/cpp/virtual/TestVirtual.py (original)
+++ lldb/trunk/test/cpp/virtual/TestVirtual.py Wed Mar 23 15:28:59 2011
@@ -43,7 +43,7 @@
 
         # First, capture the golden output emitted by the oracle, i.e., the
         # series of printf statements.
-        go = system("./a.out", sender=self)
+        go = system("./a.out", sender=self)[0]
         # This golden list contains a list of "my_expr = 'value' pairs extracted
         # from the golden output.
         gl = []

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=128162&r1=128161&r2=128162&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Wed Mar 23 15:28:59 2011
@@ -278,6 +278,7 @@
         self.close()
 
 # From 2.7's subprocess.check_output() convenience function.
+# Return a tuple (stdoutdata, stderrdata).
 def system(*popenargs, **kwargs):
     r"""Run command with arguments and return its output as a byte string.
 
@@ -304,7 +305,7 @@
 
     if 'stdout' in kwargs:
         raise ValueError('stdout argument not allowed, it will be overridden.')
-    process = Popen(stdout=PIPE, *popenargs, **kwargs)
+    process = Popen(stdout=PIPE, stderr=PIPE, *popenargs, **kwargs)
     output, error = process.communicate()
     retcode = process.poll()
 
@@ -325,7 +326,7 @@
         if cmd is None:
             cmd = popenargs[0]
         raise CalledProcessError(retcode, cmd)
-    return output
+    return (output, error)
 
 def getsource_if_available(obj):
     """

Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=128162&r1=128161&r2=128162&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Wed Mar 23 15:28:59 2011
@@ -3,9 +3,25 @@
 """
 
 import lldb
-import sys
+import os, sys
 import StringIO
 
+def is_exe(fpath):
+    return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
+
+# Find the full path to a program, or return None.
+def which(program):
+    fpath, fname = os.path.split(program)
+    if fpath:
+        if is_exe(program):
+            return program
+    else:
+        for path in os.environ["PATH"].split(os.pathsep):
+            exe_file = os.path.join(path, program)
+            if is_exe(exe_file):
+                return exe_file
+    return None
+
 # ===========================================
 # Iterator for lldb aggregate data structures
 # ===========================================

Modified: lldb/trunk/test/types/AbstractBase.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=128162&r1=128161&r2=128162&view=diff
==============================================================================
--- lldb/trunk/test/types/AbstractBase.py (original)
+++ lldb/trunk/test/types/AbstractBase.py Wed Mar 23 15:28:59 2011
@@ -25,7 +25,7 @@
 
         # First, capture the golden output emitted by the oracle, i.e., the
         # series of printf statements.
-        go = system("./a.out", sender=self)
+        go = system("./a.out", sender=self)[0]
         # This golden list contains a list of (variable, value) pairs extracted
         # from the golden output.
         gl = []
@@ -85,7 +85,7 @@
 
         # First, capture the golden output emitted by the oracle, i.e., the
         # series of printf statements.
-        go = system("./a.out", sender=self)
+        go = system("./a.out", sender=self)[0]
         # This golden list contains a list of (variable, value) pairs extracted
         # from the golden output.
         gl = []

Modified: lldb/trunk/test/unique-types/TestUniqueTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/unique-types/TestUniqueTypes.py?rev=128162&r1=128161&r2=128162&view=diff
==============================================================================
--- lldb/trunk/test/unique-types/TestUniqueTypes.py (original)
+++ lldb/trunk/test/unique-types/TestUniqueTypes.py Wed Mar 23 15:28:59 2011
@@ -4,6 +4,7 @@
 
 import unittest2
 import lldb
+import lldbutil
 from lldbtest import *
 
 class UniqueTypesTestCase(TestBase):
@@ -45,6 +46,19 @@
             substrs = ['state is 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 -t longs" and verify "long" is in each line of output.
         self.runCmd("frame variable -t longs")
         output = self.res.GetOutput()
@@ -52,24 +66,16 @@
             # Skip empty line or closing brace.
             if not x or x == '}':
                 continue
-            # clang-137 does not emit instantiation parameter.
-            if self.getCompiler() in ['clang'] and x.find('Vector_base') != -1:
-                continue
             self.expect(x, "Expect type 'long'", exe=False,
                 substrs = ['long'])
 
         # Do a "frame variable -t shorts" and verify "short" is in each line of output.
-        if self.getCompiler() in ['clang']:
-            self.skipTest("rdar://problem/9173060 lldb hangs while running unique-types")
         self.runCmd("frame variable -t shorts")
         output = self.res.GetOutput()
         for x in [line.strip() for line in output.split(os.linesep)]:
             # Skip empty line or closing brace.
             if not x or x == '}':
                 continue
-            # clang-137 does not emit instantiation parameter for lines describing Vector_base.
-            if self.getCompiler() in ['clang'] and x.find('Vector_base') != -1:
-                continue
             self.expect(x, "Expect type 'short'", exe=False,
                 substrs = ['short'])
         





More information about the lldb-commits mailing list