Sean Callanan | 683a97c | 2012-10-17 22:09:59 +0000 | [diff] [blame] | 1 | """ |
| 2 | Tests that bool types work |
| 3 | """ |
| 4 | import lldb |
| 5 | from lldbtest import * |
| 6 | import lldbutil |
| 7 | |
| 8 | class CPPBoolTestCase(TestBase): |
| 9 | |
| 10 | mydir = os.path.join("lang", "cpp", "bool") |
| 11 | |
| 12 | @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") |
| 13 | @dsym_test |
| 14 | def test_with_dsym_and_run_command(self): |
| 15 | """Test that bool types work in the expression parser""" |
| 16 | self.buildDsym() |
| 17 | self.static_method_commands() |
| 18 | |
Ed Maste | f40b092 | 2013-07-30 13:08:24 +0000 | [diff] [blame^] | 19 | @expectedFailureFreeBSD('llvm.org/pr16697') # Expression fails with 'there is no JIT compiled function' |
Sean Callanan | 683a97c | 2012-10-17 22:09:59 +0000 | [diff] [blame] | 20 | @dwarf_test |
| 21 | def test_with_dwarf_and_run_command(self): |
| 22 | """Test that bool types work in the expression parser""" |
| 23 | self.buildDwarf() |
| 24 | self.static_method_commands() |
| 25 | |
| 26 | def setUp(self): |
| 27 | TestBase.setUp(self) |
| 28 | |
| 29 | def set_breakpoint(self, line): |
Daniel Malea | 2b606ab | 2013-03-13 20:50:05 +0000 | [diff] [blame] | 30 | # Some compilers (for example GCC 4.4.7 and 4.6.1) emit multiple locations for the statement with the ternary |
| 31 | # operator in the test program, while others emit only 1. |
| 32 | lldbutil.run_break_set_by_file_and_line (self, "main.cpp", line, num_expected_locations=-1, loc_exact=False) |
Sean Callanan | 683a97c | 2012-10-17 22:09:59 +0000 | [diff] [blame] | 33 | |
| 34 | def static_method_commands(self): |
| 35 | """Test that bool types work in the expression parser""" |
| 36 | self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) |
| 37 | |
| 38 | self.set_breakpoint(line_number('main.cpp', '// breakpoint 1')) |
| 39 | |
| 40 | self.runCmd("process launch", RUN_SUCCEEDED) |
| 41 | |
| 42 | self.expect("expression -- bool second_bool = my_bool; second_bool", |
| 43 | startstr = "(bool) $0 = false") |
| 44 | |
| 45 | self.expect("expression -- my_bool = true", |
| 46 | startstr = "(bool) $1 = true") |
| 47 | |
| 48 | if __name__ == '__main__': |
| 49 | import atexit |
| 50 | lldb.SBDebugger.Initialize() |
| 51 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 52 | unittest2.main() |