blob: e6eb18a6815a7653e3a8e262b59ee1024abdc06e [file] [log] [blame]
Sean Callanan683a97c2012-10-17 22:09:59 +00001"""
2Tests that bool types work
3"""
4import lldb
5from lldbtest import *
6import lldbutil
7
8class 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 Mastef40b0922013-07-30 13:08:24 +000019 @expectedFailureFreeBSD('llvm.org/pr16697') # Expression fails with 'there is no JIT compiled function'
Sean Callanan683a97c2012-10-17 22:09:59 +000020 @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 Malea2b606ab2013-03-13 20:50:05 +000030 # 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 Callanan683a97c2012-10-17 22:09:59 +000033
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
48if __name__ == '__main__':
49 import atexit
50 lldb.SBDebugger.Initialize()
51 atexit.register(lambda: lldb.SBDebugger.Terminate())
52 unittest2.main()