[Lldb-commits] [lldb] r114769 - in /lldb/trunk/test/types: TestBasicTypes.py char.cpp short.cpp unsigned_char.cpp unsigned_short.cpp

Johnny Chen johnny.chen at apple.com
Fri Sep 24 15:54:18 PDT 2010


Author: johnny
Date: Fri Sep 24 17:54:18 2010
New Revision: 114769

URL: http://llvm.org/viewvc/llvm-project?rev=114769&view=rev
Log:
Added 'char'/'unsigned char'/'short'/'unsigned short' to the test suite.

Extended generic_type_tester() method to take an additional keyword argument
quoteDisplay (default to False) to facilitate comparison with frame variable
display output of character types.

Added:
    lldb/trunk/test/types/char.cpp
    lldb/trunk/test/types/short.cpp
    lldb/trunk/test/types/unsigned_char.cpp
    lldb/trunk/test/types/unsigned_short.cpp
Modified:
    lldb/trunk/test/types/TestBasicTypes.py

Modified: lldb/trunk/test/types/TestBasicTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestBasicTypes.py?rev=114769&r1=114768&r2=114769&view=diff
==============================================================================
--- lldb/trunk/test/types/TestBasicTypes.py (original)
+++ lldb/trunk/test/types/TestBasicTypes.py Fri Sep 24 17:54:18 2010
@@ -19,6 +19,62 @@
     # printf() stmts (see basic_type.cpp).
     pattern = re.compile(" (\*?a[^=]*) = '([^=]*)'$")
 
+    def test_char_type_with_dsym(self):
+        """Test that char-type variables are displayed correctly."""
+        d = {'CXX_SOURCES': 'char.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.char_type()
+
+    def test_char_type_with_dwarf(self):
+        """Test that char-type variables are displayed correctly."""
+        d = {'CXX_SOURCES': 'char.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.char_type()
+
+    def test_unsigned_char_type_with_dsym(self):
+        """Test that 'unsigned_char'-type variables are displayed correctly."""
+        d = {'CXX_SOURCES': 'unsigned_char.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_char_type()
+
+    def test_unsigned_char_type_with_dwarf(self):
+        """Test that 'unsigned char'-type variables are displayed correctly."""
+        d = {'CXX_SOURCES': 'unsigned_char.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_char_type()
+
+    def test_short_type_with_dsym(self):
+        """Test that short-type variables are displayed correctly."""
+        d = {'CXX_SOURCES': 'short.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.short_type()
+
+    def test_short_type_with_dwarf(self):
+        """Test that short-type variables are displayed correctly."""
+        d = {'CXX_SOURCES': 'short.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.short_type()
+
+    def test_unsigned_short_type_with_dsym(self):
+        """Test that 'unsigned_short'-type variables are displayed correctly."""
+        d = {'CXX_SOURCES': 'unsigned_short.cpp'}
+        self.buildDsym(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_short_type()
+
+    def test_unsigned_short_type_with_dwarf(self):
+        """Test that 'unsigned short'-type variables are displayed correctly."""
+        d = {'CXX_SOURCES': 'unsigned_short.cpp'}
+        self.buildDwarf(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        self.unsigned_short_type()
+
     def test_int_type_with_dsym(self):
         """Test that int-type variables are displayed correctly."""
         d = {'CXX_SOURCES': 'int.cpp'}
@@ -75,6 +131,22 @@
         self.setTearDownCleanup(dictionary=d)
         self.unsigned_long_type()
 
+    def char_type(self):
+        """Test that char-type variables are displayed correctly."""
+        self.generic_type_tester("char", quotedDisplay=True)
+
+    def unsigned_char_type(self):
+        """Test that 'unsigned char'-type variables are displayed correctly."""
+        self.generic_type_tester("unsigned char", quotedDisplay=True)
+
+    def short_type(self):
+        """Test that short-type variables are displayed correctly."""
+        self.generic_type_tester("short")
+
+    def unsigned_short_type(self):
+        """Test that 'unsigned short'-type variables are displayed correctly."""
+        self.generic_type_tester("unsigned short")
+
     def int_type(self):
         """Test that int-type variables are displayed correctly."""
         self.generic_type_tester("int")
@@ -91,7 +163,7 @@
         """Test that 'unsigned long'-type variables are displayed correctly."""
         self.generic_type_tester("unsigned long")
 
-    def generic_type_tester(self, type):
+    def generic_type_tester(self, type, quotedDisplay=False):
         """Test that variables with basic types are displayed correctly."""
 
         # First, capture the golden output emitted by the oracle, i.e., the
@@ -137,6 +209,8 @@
         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:
@@ -155,8 +229,9 @@
                           (dt, type))
 
             # 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 = [" %s = %s" % (var, val)])
+                substrs = [nv])
 
 
 if __name__ == '__main__':

Added: lldb/trunk/test/types/char.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/char.cpp?rev=114769&view=auto
==============================================================================
--- lldb/trunk/test/types/char.cpp (added)
+++ lldb/trunk/test/types/char.cpp Fri Sep 24 17:54:18 2010
@@ -0,0 +1,9 @@
+#define T char
+#define T_CSTR "char"
+#define T_VALUE_1 'a'
+#define T_VALUE_2 'b'
+#define T_VALUE_3 '!'
+#define T_VALUE_4 '~'
+#define T_PRINTF_FORMAT "%c"
+
+#include "basic_type.cpp"

Added: lldb/trunk/test/types/short.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/short.cpp?rev=114769&view=auto
==============================================================================
--- lldb/trunk/test/types/short.cpp (added)
+++ lldb/trunk/test/types/short.cpp Fri Sep 24 17:54:18 2010
@@ -0,0 +1,9 @@
+#define T short
+#define T_CSTR "short"
+#define T_VALUE_1 11001
+#define T_VALUE_2 22002
+#define T_VALUE_3 -32768
+#define T_VALUE_4 32767
+#define T_PRINTF_FORMAT "%hd"
+
+#include "basic_type.cpp"

Added: lldb/trunk/test/types/unsigned_char.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/unsigned_char.cpp?rev=114769&view=auto
==============================================================================
--- lldb/trunk/test/types/unsigned_char.cpp (added)
+++ lldb/trunk/test/types/unsigned_char.cpp Fri Sep 24 17:54:18 2010
@@ -0,0 +1,9 @@
+#define T unsigned char
+#define T_CSTR "unsigned char"
+#define T_VALUE_1 '0'
+#define T_VALUE_2 '9'
+#define T_VALUE_3 '@'
+#define T_VALUE_4 '$'
+#define T_PRINTF_FORMAT "%c"
+
+#include "basic_type.cpp"

Added: lldb/trunk/test/types/unsigned_short.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/unsigned_short.cpp?rev=114769&view=auto
==============================================================================
--- lldb/trunk/test/types/unsigned_short.cpp (added)
+++ lldb/trunk/test/types/unsigned_short.cpp Fri Sep 24 17:54:18 2010
@@ -0,0 +1,9 @@
+#define T unsigned short
+#define T_CSTR "unsigned short"
+#define T_VALUE_1 11001
+#define T_VALUE_2 22002
+#define T_VALUE_3 0
+#define T_VALUE_4 65535
+#define T_PRINTF_FORMAT "%hu"
+
+#include "basic_type.cpp"





More information about the lldb-commits mailing list