blob: 0744a54055bf74aaa6e8922c61d16cd556dca272 [file] [log] [blame]
Sean Callanan72e49402011-08-05 23:43:37 +00001"""
2Tests that ObjC member variables are available where they should be.
3"""
4
5from lldbtest import *
6
7class ObjCSelfTestCase(TestBase):
8
9 mydir = os.path.join("lang", "objc", "self")
10
11 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
Johnny Chen24086bc2012-04-06 19:54:10 +000012 @dsym_test
Sean Callanan72e49402011-08-05 23:43:37 +000013 def test_with_dsym_and_run_command(self):
14 """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods"""
15 self.buildDsym()
16 self.self_commands()
17
Johnny Chen24086bc2012-04-06 19:54:10 +000018 @dwarf_test
Sean Callanan72e49402011-08-05 23:43:37 +000019 def test_with_dwarf_and_run_command(self):
20 """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods"""
21 self.buildDwarf()
22 self.self_commands()
23
24 def setUp(self):
25 TestBase.setUp(self)
26
27 def set_breakpoint(self, line):
28 self.expect("breakpoint set -f main.m -l %d" % line,
29 BREAKPOINT_CREATED,
30 startstr = "Breakpoint created")
31
32 def self_commands(self):
33 """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods"""
34 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
35
36 self.set_breakpoint(line_number('main.m', '// breakpoint 1'))
37 self.set_breakpoint(line_number('main.m', '// breakpoint 2'))
38
39 self.runCmd("process launch", RUN_SUCCEEDED)
40
41 self.expect("expression -- m_a = 2",
42 startstr = "(int) $0 = 2")
43
44 self.runCmd("process continue")
45
46 # This would be disallowed if we enforced const. But we don't.
47 self.expect("expression -- m_a = 2",
48 error=True)
49
50 self.expect("expression -- s_a",
51 startstr = "(int) $1 = 5")
52
53if __name__ == '__main__':
54 import atexit
55 lldb.SBDebugger.Initialize()
56 atexit.register(lambda: lldb.SBDebugger.Terminate())
57 unittest2.main()