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.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114769 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/types/TestBasicTypes.py b/test/types/TestBasicTypes.py
index c11c73a..22a2d7d 100644
--- a/test/types/TestBasicTypes.py
+++ b/test/types/TestBasicTypes.py
@@ -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__':
diff --git a/test/types/char.cpp b/test/types/char.cpp
new file mode 100644
index 0000000..584582e
--- /dev/null
+++ b/test/types/char.cpp
@@ -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"
diff --git a/test/types/short.cpp b/test/types/short.cpp
new file mode 100644
index 0000000..470c68a
--- /dev/null
+++ b/test/types/short.cpp
@@ -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"
diff --git a/test/types/unsigned_char.cpp b/test/types/unsigned_char.cpp
new file mode 100644
index 0000000..0ac555a
--- /dev/null
+++ b/test/types/unsigned_char.cpp
@@ -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"
diff --git a/test/types/unsigned_short.cpp b/test/types/unsigned_short.cpp
new file mode 100644
index 0000000..09af2aa
--- /dev/null
+++ b/test/types/unsigned_short.cpp
@@ -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"