diff options
| -rwxr-xr-x | lldb/test/dotest.py | 27 | ||||
| -rw-r--r-- | lldb/test/types/TestBasicTypes.py | 201 | ||||
| -rw-r--r-- | lldb/test/types/TestFloatTypes.py | 54 | ||||
| -rw-r--r-- | lldb/test/types/TestIntegerTypes.py | 205 | ||||
| -rw-r--r-- | lldb/test/types/double.cpp | 9 | ||||
| -rw-r--r-- | lldb/test/types/float.cpp | 9 |
6 files changed, 304 insertions, 201 deletions
diff --git a/lldb/test/dotest.py b/lldb/test/dotest.py index c345c146024..5d46cc410b6 100755 --- a/lldb/test/dotest.py +++ b/lldb/test/dotest.py @@ -57,6 +57,9 @@ delay = False # Ignore the build search path relative to this script to locate the lldb.py module. ignore = False +# The regular expression pattern to match against eligible filenames as our test cases. +regexp = None + # Default verbosity is 0. verbose = 0 @@ -77,6 +80,7 @@ where options: -d : delay startup for 10 seconds (in order for the debugger to attach) -i : ignore (don't bailout) if 'lldb.py' module cannot be located in the build tree relative to this script; use PYTHONPATH to locate the module +-p : specify a regexp filename pattern for inclusion in the test suite -t : trace lldb command execution and result -v : do verbose mode of unittest framework @@ -109,7 +113,8 @@ def parseOptionsAndInitTestdirs(): global configFile global delay - global inore + global ignore + global regexp global verbose global testdirs @@ -141,6 +146,13 @@ def parseOptionsAndInitTestdirs(): elif sys.argv[index].startswith('-i'): ignore = True index += 1 + elif sys.argv[index].startswith('-p'): + # Increment by 1 to fetch the reg exp pattern argument. + index += 1 + if index >= len(sys.argv) or sys.argv[index].startswith('-'): + usage() + regexp = sys.argv[index] + index += 1 elif sys.argv[index].startswith('-t'): os.environ["LLDB_COMMAND_TRACE"] = "YES" index += 1 @@ -246,13 +258,24 @@ def visit(prefix, dir, names): """Visitor function for os.path.walk(path, visit, arg).""" global suite + global regexp for name in names: if os.path.isdir(os.path.join(dir, name)): continue if '.py' == os.path.splitext(name)[1] and name.startswith(prefix): - # We found a pattern match for our test case. Add it to the suite. + # Try to match the regexp pattern, if specified. + if regexp: + import re + if re.search(regexp, name): + #print "Filename: '%s' matches pattern: '%s'" % (name, regexp) + pass + else: + #print "Filename: '%s' does not match pattern: '%s'" % (name, regexp) + continue + + # We found a match for our test case. Add it to the suite. if not sys.path.count(dir): sys.path.append(dir) base = os.path.splitext(name)[0] diff --git a/lldb/test/types/TestBasicTypes.py b/lldb/test/types/TestBasicTypes.py index 13b519c839d..bb3b153fda5 100644 --- a/lldb/test/types/TestBasicTypes.py +++ b/lldb/test/types/TestBasicTypes.py @@ -1,211 +1,21 @@ """ -Test that variables of integer basic types are displayed correctly. +Abstract base class of basic types provides a generic type tester method. """ import os, time import re -import unittest2 import lldb from lldbtest import * def Msg(var, val): return "'frame variable %s' matches the compiler's output: %s" % (var, val) -class BasicTypesTestCase(TestBase): - - mydir = "types" +class AbstractBase(TestBase): # This is the pattern by design to match the " var = 'value'" output from # 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'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.int_type() - - def test_int_type_with_dwarf(self): - """Test that int-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'int.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.int_type() - - def test_unsigned_int_type_with_dsym(self): - """Test that 'unsigned_int'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_int.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_int_type() - - def test_unsigned_int_type_with_dwarf(self): - """Test that 'unsigned int'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_int.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_int_type() - - def test_long_type_with_dsym(self): - """Test that long-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_type() - - def test_long_type_with_dwarf(self): - """Test that long-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_type() - - def test_unsigned_long_type_with_dsym(self): - """Test that 'unsigned long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_type() - - def test_unsigned_long_type_with_dwarf(self): - """Test that 'unsigned long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_type() - - # 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 variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long_long.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_long_type() - - @unittest2.expectedFailure - def test_long_long_type_with_dwarf(self): - """Test that 'long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long_long.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_long_type() - - @unittest2.expectedFailure - def test_unsigned_long_long_type_with_dsym(self): - """Test that 'unsigned long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_long_type() - - @unittest2.expectedFailure - def test_unsigned_long_long_type_with_dwarf(self): - """Test that 'unsigned long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_long_type() - - def char_type(self): - """Test that char-type variables are displayed correctly.""" - self.generic_type_tester(set(['char']), quotedDisplay=True) - - def unsigned_char_type(self): - """Test that 'unsigned char'-type variables are displayed correctly.""" - self.generic_type_tester(set(['unsigned', 'char']), quotedDisplay=True) - - def short_type(self): - """Test that short-type variables are displayed correctly.""" - self.generic_type_tester(set(['short'])) - - def unsigned_short_type(self): - """Test that 'unsigned short'-type variables are displayed correctly.""" - self.generic_type_tester(set(['unsigned', 'short'])) - - def int_type(self): - """Test that int-type variables are displayed correctly.""" - self.generic_type_tester(set(['int'])) - - def unsigned_int_type(self): - """Test that 'unsigned int'-type variables are displayed correctly.""" - self.generic_type_tester(set(['unsigned', 'int'])) - - def long_type(self): - """Test that long-type variables are displayed correctly.""" - self.generic_type_tester(set(['long'])) - - def unsigned_long_type(self): - """Test that 'unsigned long'-type variables are displayed correctly.""" - self.generic_type_tester(set(['unsigned', 'long'])) - - def long_long_type(self): - """Test that long long-type variables are displayed correctly.""" - self.generic_type_tester(set(['long long'])) - - def unsigned_long_long_type(self): - """Test that 'unsigned long long'-type variables are displayed correctly.""" - self.generic_type_tester(set(['unsigned', 'long long'])) - def generic_type_tester(self, atoms, quotedDisplay=False): """Test that variables with basic types are displayed correctly.""" @@ -275,10 +85,3 @@ class BasicTypesTestCase(TestBase): nv = (" %s = '%s'" if quotedDisplay else " %s = %s") % (var, val) self.expect(output, Msg(var, val), exe=False, substrs = [nv]) - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/types/TestFloatTypes.py b/lldb/test/types/TestFloatTypes.py new file mode 100644 index 00000000000..270fe7d0265 --- /dev/null +++ b/lldb/test/types/TestFloatTypes.py @@ -0,0 +1,54 @@ +""" +Test that variables of floating point types are displayed correctly. +""" + +import TestBasicTypes +import unittest2 +import lldb + +class FloatTypesTestCase(TestBasicTypes.AbstractBase): + + mydir = "types" + + def test_float_types_with_dsym(self): + """Test that float-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'float.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.float_type() + + def test_float_type_with_dwarf(self): + """Test that float-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'float.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.float_type() + + def test_double_type_with_dsym(self): + """Test that double-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'double.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.double_type() + + def test_double_type_with_dwarf(self): + """Test that double-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'double.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.double_type() + + def float_type(self): + """Test that float-type variables are displayed correctly.""" + self.generic_type_tester(set(['float'])) + + def double_type(self): + """Test that double-type variables are displayed correctly.""" + self.generic_type_tester(set(['double'])) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() diff --git a/lldb/test/types/TestIntegerTypes.py b/lldb/test/types/TestIntegerTypes.py new file mode 100644 index 00000000000..7192777ad71 --- /dev/null +++ b/lldb/test/types/TestIntegerTypes.py @@ -0,0 +1,205 @@ +""" +Test that variables of integer basic types are displayed correctly. +""" + +import TestBasicTypes +import unittest2 +import lldb + +class IntegerTypesTestCase(TestBasicTypes.AbstractBase): + + mydir = "types" + + 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'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.int_type() + + def test_int_type_with_dwarf(self): + """Test that int-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'int.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.int_type() + + def test_unsigned_int_type_with_dsym(self): + """Test that 'unsigned_int'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_int.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_int_type() + + def test_unsigned_int_type_with_dwarf(self): + """Test that 'unsigned int'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_int.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_int_type() + + def test_long_type_with_dsym(self): + """Test that long-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_type() + + def test_long_type_with_dwarf(self): + """Test that long-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_type() + + def test_unsigned_long_type_with_dsym(self): + """Test that 'unsigned long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_type() + + def test_unsigned_long_type_with_dwarf(self): + """Test that 'unsigned long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_type() + + # 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 variables are displayed correctly.""" + d = {'CXX_SOURCES': 'long_long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_long_type() + + @unittest2.expectedFailure + def test_long_long_type_with_dwarf(self): + """Test that 'long long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'long_long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_long_type() + + @unittest2.expectedFailure + def test_unsigned_long_long_type_with_dsym(self): + """Test that 'unsigned long long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_long_type() + + @unittest2.expectedFailure + def test_unsigned_long_long_type_with_dwarf(self): + """Test that 'unsigned long long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_long_type() + + def char_type(self): + """Test that char-type variables are displayed correctly.""" + self.generic_type_tester(set(['char']), quotedDisplay=True) + + def unsigned_char_type(self): + """Test that 'unsigned char'-type variables are displayed correctly.""" + self.generic_type_tester(set(['unsigned', 'char']), quotedDisplay=True) + + def short_type(self): + """Test that short-type variables are displayed correctly.""" + self.generic_type_tester(set(['short'])) + + def unsigned_short_type(self): + """Test that 'unsigned short'-type variables are displayed correctly.""" + self.generic_type_tester(set(['unsigned', 'short'])) + + def int_type(self): + """Test that int-type variables are displayed correctly.""" + self.generic_type_tester(set(['int'])) + + def unsigned_int_type(self): + """Test that 'unsigned int'-type variables are displayed correctly.""" + self.generic_type_tester(set(['unsigned', 'int'])) + + def long_type(self): + """Test that long-type variables are displayed correctly.""" + self.generic_type_tester(set(['long'])) + + def unsigned_long_type(self): + """Test that 'unsigned long'-type variables are displayed correctly.""" + self.generic_type_tester(set(['unsigned', 'long'])) + + def long_long_type(self): + """Test that long long-type variables are displayed correctly.""" + self.generic_type_tester(set(['long long'])) + + def unsigned_long_long_type(self): + """Test that 'unsigned long long'-type variables are displayed correctly.""" + self.generic_type_tester(set(['unsigned', 'long long'])) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() diff --git a/lldb/test/types/double.cpp b/lldb/test/types/double.cpp new file mode 100644 index 00000000000..6788dadfe02 --- /dev/null +++ b/lldb/test/types/double.cpp @@ -0,0 +1,9 @@ +#define T double +#define T_CSTR "double" +#define T_VALUE_1 1100.125 +#define T_VALUE_2 2200.250 +#define T_VALUE_3 33.00 +#define T_VALUE_4 44.00 +#define T_PRINTF_FORMAT "%lg" + +#include "basic_type.cpp" diff --git a/lldb/test/types/float.cpp b/lldb/test/types/float.cpp new file mode 100644 index 00000000000..4bc124661aa --- /dev/null +++ b/lldb/test/types/float.cpp @@ -0,0 +1,9 @@ +#define T float +#define T_CSTR "float" +#define T_VALUE_1 1100.125 +#define T_VALUE_2 2200.250 +#define T_VALUE_3 33.00 +#define T_VALUE_4 44.00 +#define T_PRINTF_FORMAT "%g" + +#include "basic_type.cpp" |

