From c256b99a1754efb97bd72dc8a3c9b9df5441a645 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Tue, 10 Jan 2012 02:04:04 +0000 Subject: [PATCH] Refactor the test/types directory to reduce some stupid reduant code. Also add test cases to the test suite to exercise displaying of variables captured inside a block (Darwin-only). llvm-svn: 147828 --- lldb/test/types/AbstractBase.py | 56 +++++-- lldb/test/types/TestFloatTypes.py | 38 ++--- lldb/test/types/TestFloatTypesExpr.py | 38 ++--- lldb/test/types/TestIntegerTypes.py | 190 +++++++++--------------- lldb/test/types/TestIntegerTypesExpr.py | 190 +++++++++--------------- lldb/test/types/basic_type.cpp | 44 +++++- 6 files changed, 256 insertions(+), 300 deletions(-) diff --git a/lldb/test/types/AbstractBase.py b/lldb/test/types/AbstractBase.py index fef0063f0a62..7fd34bb74a83 100644 --- a/lldb/test/types/AbstractBase.py +++ b/lldb/test/types/AbstractBase.py @@ -29,7 +29,31 @@ class GenericTester(TestBase): # used for all the test cases. self.exe_name = self.testMethodName - def generic_type_tester(self, exe_name, atoms, quotedDisplay=False): + # bc -> blockCaptured + # qd -> quotedDisplay + + def build_and_run(self, source, atoms, dsym=True, bc=False, qd=False): + self.build_and_run_with_source_atoms_expr(source, atoms, expr=False, dsym=dsym, bc=bc, qd=qd) + + def build_and_run_expr(self, source, atoms, dsym=True, bc=False, qd=False): + self.build_and_run_with_source_atoms_expr(source, atoms, expr=True, dsym=dsym, bc=bc, qd=qd) + + def build_and_run_with_source_atoms_expr(self, source, atoms, expr, dsym=True, bc=False, qd=False): + if bc: + d = {'CXX_SOURCES': source, 'EXE': self.exe_name, 'CFLAGS_EXTRAS': '-DTEST_BLOCK_CAPTURED_VARS'} + else: + d = {'CXX_SOURCES': source, 'EXE': self.exe_name} + if dsym: + self.buildDsym(dictionary=d) + else: + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + if expr: + self.generic_type_expr_tester(self.exe_name, atoms, blockCaptured=bc, quotedDisplay=qd) + else: + self.generic_type_tester(self.exe_name, atoms, blockCaptured=bc, quotedDisplay=qd) + + def generic_type_tester(self, exe_name, atoms, quotedDisplay=False, blockCaptured=False): """Test that variables with basic types are displayed correctly.""" # First, capture the golden output emitted by the oracle, i.e., the @@ -44,6 +68,9 @@ class GenericTester(TestBase): # variable = 'value' # for line in go.split(os.linesep): + # We'll ignore variables of array types from inside a block. + if blockCaptured and '[' in line: + continue match = self.pattern.search(line) if match: var, val = match.group(1), match.group(2) @@ -53,15 +80,18 @@ class GenericTester(TestBase): # Bring the program to the point where we can issue a series of # 'frame variable -T' command. self.runCmd("file %s" % exe_name, CURRENT_EXECUTABLE_SET) - puts_line = line_number ("basic_type.cpp", "// Here is the line we will break on to check variables") - self.expect("breakpoint set -f basic_type.cpp -l %d" % puts_line, + if blockCaptured: + break_line = line_number ("basic_type.cpp", "// Break here to test block captured variables.") + else: + break_line = line_number ("basic_type.cpp", "// Here is the line we will break on to check variables.") + self.expect("breakpoint set -f basic_type.cpp -l %d" % break_line, BREAKPOINT_CREATED, startstr = "Breakpoint created: 1: file ='basic_type.cpp', line = %d, locations = 1" % - puts_line) + break_line) self.runCmd("run", RUN_SUCCEEDED) self.expect("process status", STOPPED_DUE_TO_BREAKPOINT, - substrs = [" at basic_type.cpp:%d" % puts_line, + substrs = [" at basic_type.cpp:%d" % break_line, "stop reason = breakpoint"]) #self.runCmd("frame variable -T") @@ -96,7 +126,7 @@ class GenericTester(TestBase): self.expect(output, Msg(var, val, True), exe=False, substrs = [nv]) - def generic_type_expr_tester(self, exe_name, atoms, quotedDisplay=False): + def generic_type_expr_tester(self, exe_name, atoms, quotedDisplay=False, blockCaptured=False): """Test that variable expressions with basic types are evaluated correctly.""" # First, capture the golden output emitted by the oracle, i.e., the @@ -111,6 +141,9 @@ class GenericTester(TestBase): # variable = 'value' # for line in go.split(os.linesep): + # We'll ignore variables of array types from inside a block. + if blockCaptured and '[' in line: + continue match = self.pattern.search(line) if match: var, val = match.group(1), match.group(2) @@ -120,14 +153,17 @@ class GenericTester(TestBase): # Bring the program to the point where we can issue a series of # 'expr' command. self.runCmd("file %s" % exe_name, CURRENT_EXECUTABLE_SET) - puts_line = line_number ("basic_type.cpp", "// Here is the line we will break on to check variables.") - self.expect("breakpoint set -f basic_type.cpp -l %d" % puts_line, + if blockCaptured: + break_line = line_number ("basic_type.cpp", "// Break here to test block captured variables.") + else: + break_line = line_number ("basic_type.cpp", "// Here is the line we will break on to check variables.") + self.expect("breakpoint set -f basic_type.cpp -l %d" % break_line, BREAKPOINT_CREATED, startstr = "Breakpoint created: 1: file ='basic_type.cpp', line = %d, locations = 1" % - puts_line) + break_line) self.runCmd("run", RUN_SUCCEEDED) self.expect("process status", STOPPED_DUE_TO_BREAKPOINT, - substrs = [" at basic_type.cpp:%d" % puts_line, + substrs = [" at basic_type.cpp:%d" % break_line, "stop reason = breakpoint"]) #self.runCmd("frame variable -T") diff --git a/lldb/test/types/TestFloatTypes.py b/lldb/test/types/TestFloatTypes.py index f4037f16c461..80cc880e74ab 100644 --- a/lldb/test/types/TestFloatTypes.py +++ b/lldb/test/types/TestFloatTypes.py @@ -14,40 +14,30 @@ class FloatTypesTestCase(AbstractBase.GenericTester): @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_float_type_with_dsym(self): """Test that float-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'float.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.float_type(self.exe_name) + self.build_and_run('float.cpp', set(['float'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_float_type_from_block_with_dsym(self): + """Test that float-type variables are displayed correctly from a block.""" + self.build_and_run('float.cpp', set(['float']), bc=True) def test_float_type_with_dwarf(self): """Test that float-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'float.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.float_type(self.exe_name) + self.build_and_run('float.cpp', set(['float']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_double_type_with_dsym(self): """Test that double-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'double.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.double_type(self.exe_name) + self.build_and_run('double.cpp', set(['double'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_double_type_from_block_with_dsym(self): + """Test that double-type variables are displayed correctly from a block.""" + self.build_and_run('double.cpp', set(['double']), bc=True) def test_double_type_with_dwarf(self): """Test that double-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'double.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.double_type(self.exe_name) - - def float_type(self, exe_name): - """Test that float-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['float'])) - - def double_type(self, exe_name): - """Test that double-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['double'])) + self.build_and_run('double.cpp', set(['double']), dsym=False) if __name__ == '__main__': diff --git a/lldb/test/types/TestFloatTypesExpr.py b/lldb/test/types/TestFloatTypesExpr.py index d05fa2957029..7257820e1526 100644 --- a/lldb/test/types/TestFloatTypesExpr.py +++ b/lldb/test/types/TestFloatTypesExpr.py @@ -17,40 +17,30 @@ class FloatTypesExprTestCase(AbstractBase.GenericTester): @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_float_type_with_dsym(self): """Test that float-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'float.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.float_type_expr(self.exe_name) + self.build_and_run_expr('float.cpp', set(['float'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_float_type_from_block_with_dsym(self): + """Test that float-type variables are displayed correctly from a block.""" + self.build_and_run_expr('float.cpp', set(['float']), bc=True) def test_float_type_with_dwarf(self): """Test that float-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'float.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.float_type_expr(self.exe_name) + self.build_and_run_expr('float.cpp', set(['float']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_double_type_with_dsym(self): """Test that double-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'double.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.double_type_expr(self.exe_name) + self.build_and_run_expr('double.cpp', set(['double'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_double_type_from_block_with_dsym(self): + """Test that double-type variables are displayed correctly from a block.""" + self.build_and_run_expr('double.cpp', set(['double']), bc=True) def test_double_type_with_dwarf(self): """Test that double-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'double.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.double_type_expr(self.exe_name) - - def float_type_expr(self, exe_name): - """Test that float-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['float'])) - - def double_type_expr(self, exe_name): - """Test that double-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['double'])) + self.build_and_run_expr('double.cpp', set(['double']), dsym=False) if __name__ == '__main__': diff --git a/lldb/test/types/TestIntegerTypes.py b/lldb/test/types/TestIntegerTypes.py index f5b3a0c43c81..2eeb9c5bf588 100644 --- a/lldb/test/types/TestIntegerTypes.py +++ b/lldb/test/types/TestIntegerTypes.py @@ -14,122 +14,114 @@ class IntegerTypesTestCase(AbstractBase.GenericTester): @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_char_type_with_dsym(self): """Test that char-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'char.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.char_type(self.exe_name) + self.build_and_run('char.cpp', set(['char']), qd=True) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_char_type_from_block_with_dsym(self): + """Test that char-type variables are displayed correctly from a block.""" + self.build_and_run('char.cpp', set(['char']), bc=True, qd=True) def test_char_type_with_dwarf(self): """Test that char-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'char.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.char_type(self.exe_name) + self.build_and_run('char.cpp', set(['char']), dsym=False, qd=True) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_char_type_with_dsym(self): """Test that 'unsigned_char'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_char.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_char_type(self.exe_name) + self.build_and_run('unsigned_char.cpp', set(['unsigned', 'char']), qd=True) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_char_type_from_block_with_dsym(self): + """Test that 'unsigned char'-type variables are displayed correctly from a block.""" + self.build_and_run('unsigned_char.cpp', set(['unsigned', 'char']), bc=True, qd=True) def test_unsigned_char_type_with_dwarf(self): """Test that 'unsigned char'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_char.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_char_type(self.exe_name) + self.build_and_run('unsigned_char.cpp', set(['unsigned', 'char']), dsym=False, qd=True) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_short_type_with_dsym(self): """Test that short-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'short.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.short_type(self.exe_name) + self.build_and_run('short.cpp', set(['short'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_short_type_from_block_with_dsym(self): + """Test that short-type variables are displayed correctly from a block.""" + self.build_and_run('short.cpp', set(['short']), bc=True) def test_short_type_with_dwarf(self): """Test that short-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'short.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.short_type(self.exe_name) + self.build_and_run('short.cpp', set(['short']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_short_type_with_dsym(self): """Test that 'unsigned_short'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_short.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_short_type(self.exe_name) + self.build_and_run('unsigned_short.cpp', set(['unsigned', 'short'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_short_type_from_block_with_dsym(self): + """Test that 'unsigned short'-type variables are displayed correctly from a block.""" + self.build_and_run('unsigned_short.cpp', set(['unsigned', 'short']), bc=True) def test_unsigned_short_type_with_dwarf(self): """Test that 'unsigned short'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_short.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_short_type(self.exe_name) + self.build_and_run('unsigned_short.cpp', set(['unsigned', 'short']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_int_type_with_dsym(self): """Test that int-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'int.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.int_type(self.exe_name) + self.build_and_run('int.cpp', set(['int'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_int_type_from_block_with_dsym(self): + """Test that int-type variables are displayed correctly from a block.""" + self.build_and_run('int.cpp', set(['int']), dsym=False) def test_int_type_with_dwarf(self): """Test that int-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'int.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.int_type(self.exe_name) + self.build_and_run('int.cpp', set(['int']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_int_type_with_dsym(self): """Test that 'unsigned_int'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_int.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_int_type(self.exe_name) + self.build_and_run('unsigned_int.cpp', set(['unsigned', 'int'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_int_type_from_block_with_dsym(self): + """Test that 'unsigned int'-type variables are displayed correctly from a block.""" + self.build_and_run('unsigned_int.cpp', set(['unsigned', 'int']), bc=True) def test_unsigned_int_type_with_dwarf(self): """Test that 'unsigned int'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_int.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_int_type(self.exe_name) + self.build_and_run('unsigned_int.cpp', set(['unsigned', 'int']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_long_type_with_dsym(self): """Test that long-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_type(self.exe_name) + self.build_and_run('long.cpp', set(['long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_long_type_from_block_with_dsym(self): + """Test that long-type variables are displayed correctly from a block.""" + self.build_and_run('long.cpp', set(['long']), bc=True) def test_long_type_with_dwarf(self): """Test that long-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_type(self.exe_name) + self.build_and_run('long.cpp', set(['long']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_long_type_with_dsym(self): """Test that 'unsigned long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_type(self.exe_name) + self.build_and_run('unsigned_long.cpp', set(['unsigned', 'long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_long_type_from_block_with_dsym(self): + """Test that 'unsigned_long'-type variables are displayed correctly from a block.""" + self.build_and_run('unsigned_long.cpp', set(['unsigned', 'long']), bc=True) def test_unsigned_long_type_with_dwarf(self): """Test that 'unsigned long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_type(self.exe_name) + self.build_and_run('unsigned_long.cpp', set(['unsigned', 'long']), dsym=False) # rdar://problem/8482903 # test suite failure for types dir -- "long long" and "unsigned long long" @@ -137,72 +129,30 @@ class IntegerTypesTestCase(AbstractBase.GenericTester): @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_long_long_type_with_dsym(self): """Test that 'long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long_long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_long_type(self.exe_name) + self.build_and_run('long_long.cpp', set(['long long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_long_long_type_from_block_with_dsym(self): + """Test that 'long_long'-type variables are displayed correctly from a block.""" + self.build_and_run('long_long.cpp', set(['long long']), bc=True) def test_long_long_type_with_dwarf(self): """Test that 'long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long_long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_long_type(self.exe_name) + self.build_and_run('long_long.cpp', set(['long long']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 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', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_long_type(self.exe_name) + self.build_and_run('unsigned_long_long.cpp', set(['unsigned', 'long long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_long_long_type_from_block_with_dsym(self): + """Test that 'unsigned_long_long'-type variables are displayed correctly from a block.""" + self.build_and_run('unsigned_long_long.cpp', set(['unsigned', 'long long']), bc=True) 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', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_long_type(self.exe_name) - - def char_type(self, exe_name): - """Test that char-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['char']), quotedDisplay=True) - - def unsigned_char_type(self, exe_name): - """Test that 'unsigned char'-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['unsigned', 'char']), quotedDisplay=True) - - def short_type(self, exe_name): - """Test that short-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['short'])) - - def unsigned_short_type(self, exe_name): - """Test that 'unsigned short'-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['unsigned', 'short'])) - - def int_type(self, exe_name): - """Test that int-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['int'])) - - def unsigned_int_type(self, exe_name): - """Test that 'unsigned int'-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['unsigned', 'int'])) - - def long_type(self, exe_name): - """Test that long-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['long'])) - - def unsigned_long_type(self, exe_name): - """Test that 'unsigned long'-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['unsigned', 'long'])) - - def long_long_type(self, exe_name): - """Test that long long-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['long long'])) - - def unsigned_long_long_type(self, exe_name): - """Test that 'unsigned long long'-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['unsigned', 'long long'])) + self.build_and_run('unsigned_long_long.cpp', set(['unsigned', 'long long']), dsym=False) if __name__ == '__main__': diff --git a/lldb/test/types/TestIntegerTypesExpr.py b/lldb/test/types/TestIntegerTypesExpr.py index c40f6b19be75..028d63153db1 100644 --- a/lldb/test/types/TestIntegerTypesExpr.py +++ b/lldb/test/types/TestIntegerTypesExpr.py @@ -14,122 +14,114 @@ class IntegerTypesExprTestCase(AbstractBase.GenericTester): @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_char_type_with_dsym(self): """Test that char-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'char.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.char_type_expr(self.exe_name) + self.build_and_run_expr('char.cpp', set(['char']), qd=True) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_char_type_from_block_with_dsym(self): + """Test that char-type variables are displayed correctly from a block.""" + self.build_and_run_expr('char.cpp', set(['char']), bc=True, qd=True) def test_char_type_with_dwarf(self): """Test that char-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'char.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.char_type_expr(self.exe_name) + self.build_and_run_expr('char.cpp', set(['char']), dsym=False, qd=True) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_char_type_with_dsym(self): """Test that 'unsigned_char'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_char.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_char_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_char.cpp', set(['unsigned', 'char']), qd=True) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_char_type_from_block_with_dsym(self): + """Test that 'unsigned char'-type variables are displayed correctly from a block.""" + self.build_and_run_expr('unsigned_char.cpp', set(['unsigned', 'char']), bc=True, qd=True) def test_unsigned_char_type_with_dwarf(self): """Test that 'unsigned char'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_char.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_char_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_char.cpp', set(['unsigned', 'char']), dsym=False, qd=True) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_short_type_with_dsym(self): """Test that short-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'short.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.short_type_expr(self.exe_name) + self.build_and_run_expr('short.cpp', set(['short'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_short_type_from_block_with_dsym(self): + """Test that short-type variables are displayed correctly from a block.""" + self.build_and_run_expr('short.cpp', set(['short']), bc=True) def test_short_type_with_dwarf(self): """Test that short-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'short.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.short_type_expr(self.exe_name) + self.build_and_run_expr('short.cpp', set(['short']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_short_type_with_dsym(self): """Test that 'unsigned_short'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_short.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_short_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_short.cpp', set(['unsigned', 'short'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_short_type_from_block_with_dsym(self): + """Test that 'unsigned short'-type variables are displayed correctly from a block.""" + self.build_and_run_expr('unsigned_short.cpp', set(['unsigned', 'short']), bc=True) def test_unsigned_short_type_with_dwarf(self): """Test that 'unsigned short'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_short.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_short_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_short.cpp', set(['unsigned', 'short']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_int_type_with_dsym(self): """Test that int-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'int.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.int_type_expr(self.exe_name) + self.build_and_run_expr('int.cpp', set(['int'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_int_type_from_block_with_dsym(self): + """Test that int-type variables are displayed correctly from a block.""" + self.build_and_run_expr('int.cpp', set(['int']), dsym=False) def test_int_type_with_dwarf(self): """Test that int-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'int.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.int_type_expr(self.exe_name) + self.build_and_run_expr('int.cpp', set(['int']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_int_type_with_dsym(self): """Test that 'unsigned_int'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_int.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_int_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_int.cpp', set(['unsigned', 'int'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_int_type_from_block_with_dsym(self): + """Test that 'unsigned int'-type variables are displayed correctly from a block.""" + self.build_and_run_expr('unsigned_int.cpp', set(['unsigned', 'int']), bc=True) def test_unsigned_int_type_with_dwarf(self): """Test that 'unsigned int'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_int.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_int_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_int.cpp', set(['unsigned', 'int']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_long_type_with_dsym(self): """Test that long-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_type_expr(self.exe_name) + self.build_and_run_expr('long.cpp', set(['long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_long_type_from_block_with_dsym(self): + """Test that long-type variables are displayed correctly from a block.""" + self.build_and_run_expr('long.cpp', set(['long']), bc=True) def test_long_type_with_dwarf(self): """Test that long-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_type_expr(self.exe_name) + self.build_and_run_expr('long.cpp', set(['long']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_long_type_with_dsym(self): """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_long.cpp', set(['unsigned', 'long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_long_type_from_block_with_dsym(self): + """Test that 'unsigned_long'-type variables are displayed correctly from a block.""" + self.build_and_run_expr('unsigned_long.cpp', set(['unsigned', 'long']), bc=True) def test_unsigned_long_type_with_dwarf(self): """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_long.cpp', set(['unsigned', 'long']), dsym=False) # rdar://problem/8482903 # test suite failure for types dir -- "long long" and "unsigned long long" @@ -137,72 +129,30 @@ class IntegerTypesExprTestCase(AbstractBase.GenericTester): @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_long_long_type_with_dsym(self): """Test that 'long long'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'long_long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_long_type_expr(self.exe_name) + self.build_and_run_expr('long_long.cpp', set(['long long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_long_long_type_from_block_with_dsym(self): + """Test that 'long_long'-type variables are displayed correctly from a block.""" + self.build_and_run_expr('long_long.cpp', set(['long long']), bc=True) def test_long_long_type_with_dwarf(self): """Test that 'long long'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'long_long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_long_type_expr(self.exe_name) + self.build_and_run_expr('long_long.cpp', set(['long long']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 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', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_long_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_long_long.cpp', set(['unsigned', 'long long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_long_long_type_from_block_with_dsym(self): + """Test that 'unsigned_long_long'-type variables are displayed correctly from a block.""" + self.build_and_run_expr('unsigned_long_long.cpp', set(['unsigned', 'long long']), bc=True) 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', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_long_type_expr(self.exe_name) - - def char_type_expr(self, exe_name): - """Test that char-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['char']), quotedDisplay=True) - - def unsigned_char_type_expr(self, exe_name): - """Test that 'unsigned char'-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['unsigned', 'char']), quotedDisplay=True) - - def short_type_expr(self, exe_name): - """Test that short-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['short'])) - - def unsigned_short_type_expr(self, exe_name): - """Test that 'unsigned short'-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['unsigned', 'short'])) - - def int_type_expr(self, exe_name): - """Test that int-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['int'])) - - def unsigned_int_type_expr(self, exe_name): - """Test that 'unsigned int'-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['unsigned', 'int'])) - - def long_type_expr(self, exe_name): - """Test that long-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['long'])) - - def unsigned_long_type_expr(self, exe_name): - """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['unsigned', 'long'])) - - def long_long_type_expr(self, exe_name): - """Test that long long-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['long long'])) - - def unsigned_long_long_type_expr(self, exe_name): - """Test that 'unsigned long long'-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['unsigned', 'long long'])) + self.build_and_run_expr('unsigned_long_long.cpp', set(['unsigned', 'long long']), dsym=False) if __name__ == '__main__': diff --git a/lldb/test/types/basic_type.cpp b/lldb/test/types/basic_type.cpp index 149c22b2f846..818c0c5e33b7 100644 --- a/lldb/test/types/basic_type.cpp +++ b/lldb/test/types/basic_type.cpp @@ -20,6 +20,10 @@ #endif +#ifdef TEST_BLOCK_CAPTURED_VARS +#include +#endif + class a_class { public: @@ -34,7 +38,7 @@ public: } const T& - get_a() + get_a() const { return m_a; } @@ -46,7 +50,7 @@ public: } const T& - get_b() + get_b() const { return m_b; } @@ -169,5 +173,41 @@ main (int argc, char const *argv[]) #endif puts("About to exit, break here to check values..."); // Here is the line we will break on to check variables. + +#ifdef TEST_BLOCK_CAPTURED_VARS +#include + + void (^myBlock)() = ^() { + printf ("%s: a = '" T_PRINTF_FORMAT "'\n", T_CSTR, a); + printf ("%s*: %p => *a_ptr = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_ptr, *a_ptr); + printf ("%s&: @%p => a_ref = '" T_PRINTF_FORMAT "'\n", T_CSTR, &a_ref, a_ref); + + printf ("(a_class) a_class_instance.m_a = '" T_PRINTF_FORMAT "'\n", a_class_instance.get_a()); + printf ("(a_class) a_class_instance.m_b = '" T_PRINTF_FORMAT "'\n", a_class_instance.get_b()); + printf ("(a_class*) a_class_ptr = %p, a_class_ptr->m_a = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_a()); + printf ("(a_class*) a_class_ptr = %p, a_class_ptr->m_b = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_b()); + printf ("(a_class&) a_class_ref = %p, a_class_ref.m_a = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_a()); + printf ("(a_class&) a_class_ref = %p, a_class_ref.m_b = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_b()); + + printf ("(a_struct_t) a_struct.a = '" T_PRINTF_FORMAT "'\n", a_struct.a); + printf ("(a_struct_t) a_struct.b = '" T_PRINTF_FORMAT "'\n", a_struct.b); + printf ("(a_struct_t*) a_struct_ptr = %p, a_struct_ptr->a = '" T_PRINTF_FORMAT "'\n", a_struct_ptr, a_struct_ptr->a); + printf ("(a_struct_t*) a_struct_ptr = %p, a_struct_ptr->b = '" T_PRINTF_FORMAT "'\n", a_struct_ptr, a_struct_ptr->b); + printf ("(a_struct_t&) a_struct_ref = %p, a_struct_ref.a = '" T_PRINTF_FORMAT "'\n", &a_struct_ref, a_struct_ref.a); + printf ("(a_struct_t&) a_struct_ref = %p, a_struct_ref.b = '" T_PRINTF_FORMAT "'\n", &a_struct_ref, a_struct_ref.b); + + printf ("(a_union_zero_t) a_union_zero.a = '" T_PRINTF_FORMAT "'\n", a_union_zero.a); + printf ("(a_union_zero_t*) a_union_zero_ptr = %p, a_union_zero_ptr->a = '" T_PRINTF_FORMAT "'\n", a_union_zero_ptr, a_union_zero_ptr->a); + printf ("(a_union_zero_t&) a_union_zero_ref = %p, a_union_zero_ref.a = '" T_PRINTF_FORMAT "'\n", &a_union_zero_ref, a_union_zero_ref.a); + + printf ("(a_union_nonzero_t) a_union_nonzero.u.a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero.u.a); + printf ("(a_union_nonzero_t*) a_union_nonzero_ptr = %p, a_union_nonzero_ptr->u.a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero_ptr, a_union_nonzero_ptr->u.a); + printf ("(a_union_nonzero_t&) a_union_nonzero_ref = %p, a_union_nonzero_ref.u.a = '" T_PRINTF_FORMAT "'\n", &a_union_nonzero_ref, a_union_nonzero_ref.u.a); + + printf ("That's All Folks!\n"); // Break here to test block captured variables. + }; + + myBlock(); +#endif return 0; }