[Lldb-commits] [lldb] r114987 - in /lldb/trunk/test/types: AbstractBase.py TestFloatTypesExpr.py TestIntegerTypesExpr.py

Johnny Chen johnny.chen at apple.com
Tue Sep 28 14:03:58 PDT 2010


Author: johnny
Date: Tue Sep 28 16:03:58 2010
New Revision: 114987

URL: http://llvm.org/viewvc/llvm-project?rev=114987&view=rev
Log:
Added TestIntegerTypesExpr.py and TestFloatTypesExpr.py which exercise 'expr'
command on the various basic types, similar to TestIntegerTypes.py and
TestFloatTypes.py, which exercise 'frame variable' on the various basic types.

Right now, they don't employ the self.expect() facility to compare against the
golden output.  They just invoke the self.runCmd() method to run the 'expr'
command.  Decorated the two classes with @unittest2.skip decorators for the time
being.

Added:
    lldb/trunk/test/types/TestFloatTypesExpr.py
    lldb/trunk/test/types/TestIntegerTypesExpr.py
Modified:
    lldb/trunk/test/types/AbstractBase.py

Modified: lldb/trunk/test/types/AbstractBase.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=114987&r1=114986&r2=114987&view=diff
==============================================================================
--- lldb/trunk/test/types/AbstractBase.py (original)
+++ lldb/trunk/test/types/AbstractBase.py Tue Sep 28 16:03:58 2010
@@ -85,3 +85,55 @@
             nv = (" %s = '%s'" if quotedDisplay else " %s = %s") % (var, val)
             self.expect(output, Msg(var, val), exe=False,
                 substrs = [nv])
+
+    def generic_type_expr_tester(self, atoms, quotedDisplay=False):
+        """Test that variable expressions with basic types are evaluated correctly."""
+
+        # First, capture the golden output emitted by the oracle, i.e., the
+        # series of printf statements.
+        go = system("./a.out")
+        # This golden list contains a list of (variable, value) pairs extracted
+        # from the golden output.
+        gl = []
+
+        # Scan the golden output line by line, looking for the pattern:
+        #
+        #     variable = 'value'
+        #
+        for line in go.split(os.linesep):
+            match = self.pattern.search(line)
+            if match:
+                var, val = match.group(1), match.group(2)
+                gl.append((var, val))
+        #print "golden list:", gl
+
+        # Bring the program to the point where we can issue a series of
+        # 'frame variable' command.
+        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+        self.runCmd("breakpoint set --name Puts")
+        self.runCmd("run", RUN_SUCCEEDED)
+        self.runCmd("thread step-out", STEP_OUT_SUCCEEDED)
+
+        #self.runCmd("frame variable")
+
+        # Now iterate through the golden list, comparing against the output from
+        # 'frame variable var'.
+        for var, val in gl:
+            self.runCmd("expr %s" % var)
+            output = self.res.GetOutput()
+            
+            # The input type is in a canonical form as a set named atoms.
+            # The display type string must conatin each and every element.
+            #dt = re.match("^\((.*)\)", output).group(1)
+
+            # Expect the display type string to contain each and every atoms.
+            #self.expect(dt,
+            #            "Display type: '%s' must contain the type atoms: '%s'" %
+            #            (dt, atoms),
+            #            exe=False,
+            #    substrs = list(atoms))
+
+            # The (var, val) pair must match, too.
+            #nv = (" %s = '%s'" if quotedDisplay else " %s = %s") % (var, val)
+            #self.expect(output, Msg(var, val), exe=False,
+            #    substrs = [nv])

Added: lldb/trunk/test/types/TestFloatTypesExpr.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=114987&view=auto
==============================================================================
--- lldb/trunk/test/types/TestFloatTypesExpr.py (added)
+++ lldb/trunk/test/types/TestFloatTypesExpr.py Tue Sep 28 16:03:58 2010
@@ -0,0 +1,55 @@
+"""
+Test that variable expressions of floating point types are evaluated correctly.
+"""
+
+import AbstractBase
+import unittest2
+import lldb
+
+ at unittest2.skip("rdar://problem/8488437 test/types/TestIntegerTypesExpr.py asserts")
+class FloatTypesTestCase(AbstractBase.GenericTester):
+
+    mydir = "types"
+
+    def test_float_types_with_dsym(self):
+        """Test that float-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'float.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.float_type_expr()
+
+    def test_float_type_with_dwarf(self):
+        """Test that float-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'float.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.float_type_expr()
+
+    def test_double_type_with_dsym(self):
+        """Test that double-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'double.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.double_type_expr()
+
+    def test_double_type_with_dwarf(self):
+        """Test that double-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'double.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.double_type_expr()
+
+    def float_type_expr(self):
+        """Test that float-type variable expressions are evaluated correctly."""
+        self.generic_type_expr_tester(set(['float']))
+
+    def double_type_expr(self):
+        """Test that double-type variable expressions are evaluated correctly."""
+        self.generic_type_expr_tester(set(['double']))
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Added: lldb/trunk/test/types/TestIntegerTypesExpr.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=114987&view=auto
==============================================================================
--- lldb/trunk/test/types/TestIntegerTypesExpr.py (added)
+++ lldb/trunk/test/types/TestIntegerTypesExpr.py Tue Sep 28 16:03:58 2010
@@ -0,0 +1,206 @@
+"""
+Test that variable expressions of integer basic types are evaluated correctly.
+"""
+
+import AbstractBase
+import unittest2
+import lldb
+
+ at unittest2.skip("rdar://problem/8488437 test/types/TestIntegerTypesExpr.py asserts")
+class IntegerTypesTestCase(AbstractBase.GenericTester):
+
+    mydir = "types"
+
+    def test_char_type_with_dsym(self):
+        """Test that char-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'char.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.char_type_expr()
+
+    def test_char_type_with_dwarf(self):
+        """Test that char-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'char.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.char_type_expr()
+
+    def test_unsigned_char_type_with_dsym(self):
+        """Test that 'unsigned_char'-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'unsigned_char.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_char_type_expr()
+
+    def test_unsigned_char_type_with_dwarf(self):
+        """Test that 'unsigned char'-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'unsigned_char.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_char_type_expr()
+
+    def test_short_type_with_dsym(self):
+        """Test that short-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'short.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.short_type_expr()
+
+    def test_short_type_with_dwarf(self):
+        """Test that short-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'short.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.short_type_expr()
+
+    def test_unsigned_short_type_with_dsym(self):
+        """Test that 'unsigned_short'-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'unsigned_short.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_short_type_expr()
+
+    def test_unsigned_short_type_with_dwarf(self):
+        """Test that 'unsigned short'-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'unsigned_short.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_short_type_expr()
+
+    def test_int_type_with_dsym(self):
+        """Test that int-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'int.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.int_type_expr()
+
+    def test_int_type_with_dwarf(self):
+        """Test that int-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'int.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.int_type_expr()
+
+    def test_unsigned_int_type_with_dsym(self):
+        """Test that 'unsigned_int'-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'unsigned_int.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_int_type_expr()
+
+    def test_unsigned_int_type_with_dwarf(self):
+        """Test that 'unsigned int'-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'unsigned_int.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_int_type_expr()
+
+    def test_long_type_with_dsym(self):
+        """Test that long-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'long.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.long_type_expr()
+
+    def test_long_type_with_dwarf(self):
+        """Test that long-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'long.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.long_type_expr()
+
+    def test_unsigned_long_type_with_dsym(self):
+        """Test that 'unsigned long'-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'unsigned_long.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_long_type_expr()
+
+    def test_unsigned_long_type_with_dwarf(self):
+        """Test that 'unsigned long'-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'unsigned_long.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_long_type_expr()
+
+    # rdar://problem/8482903
+    # test suite failure for types dir -- "long long" and "unsigned long long"
+
+    @unittest2.expectedFailure
+    def test_long_long_type_with_dsym(self):
+        """Test that 'long long'-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'long_long.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.long_long_type_expr()
+
+    @unittest2.expectedFailure
+    def test_long_long_type_with_dwarf(self):
+        """Test that 'long long'-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'long_long.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.long_long_type_expr()
+
+    @unittest2.expectedFailure
+    def test_unsigned_long_long_type_with_dsym(self):
+        """Test that 'unsigned long long'-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'unsigned_long_long.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_long_long_type_expr()
+
+    @unittest2.expectedFailure
+    def test_unsigned_long_long_type_with_dwarf(self):
+        """Test that 'unsigned long long'-type variable expressions are evaluated correctly."""
+        d = {'CXX_SOURCES': 'unsigned_long_long.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_long_long_type_expr()
+
+    def char_type_expr(self):
+        """Test that char-type variable expressions are evaluated correctly."""
+        self.generic_type_expr_tester(set(['char']), quotedDisplay=True)
+
+    def unsigned_char_type_expr(self):
+        """Test that 'unsigned char'-type variable expressions are evaluated correctly."""
+        self.generic_type_expr_tester(set(['unsigned', 'char']), quotedDisplay=True)
+
+    def short_type_expr(self):
+        """Test that short-type variable expressions are evaluated correctly."""
+        self.generic_type_expr_tester(set(['short']))
+
+    def unsigned_short_type_expr(self):
+        """Test that 'unsigned short'-type variable expressions are evaluated correctly."""
+        self.generic_type_expr_tester(set(['unsigned', 'short']))
+
+    def int_type_expr(self):
+        """Test that int-type variable expressions are evaluated correctly."""
+        self.generic_type_expr_tester(set(['int']))
+
+    def unsigned_int_type_expr(self):
+        """Test that 'unsigned int'-type variable expressions are evaluated correctly."""
+        self.generic_type_expr_tester(set(['unsigned', 'int']))
+
+    def long_type_expr(self):
+        """Test that long-type variable expressions are evaluated correctly."""
+        self.generic_type_expr_tester(set(['long']))
+
+    def unsigned_long_type_expr(self):
+        """Test that 'unsigned long'-type variable expressions are evaluated correctly."""
+        self.generic_type_expr_tester(set(['unsigned', 'long']))
+
+    def long_long_type_expr(self):
+        """Test that long long-type variable expressions are evaluated correctly."""
+        self.generic_type_expr_tester(set(['long long']))
+
+    def unsigned_long_long_type_expr(self):
+        """Test that 'unsigned long long'-type variable expressions are evaluated correctly."""
+        self.generic_type_expr_tester(set(['unsigned', 'long long']))
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()





More information about the lldb-commits mailing list