blob: c40cdb000bbbde755f98c04aa3768d6047586754 [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")
12 def test_with_dsym_and_run_command(self):
13 """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods"""
14 self.buildDsym()
15 self.self_commands()
16
17 def test_with_dwarf_and_run_command(self):
18 """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods"""
19 self.buildDwarf()
20 self.self_commands()
21
22 def setUp(self):
23 TestBase.setUp(self)
24
25 def set_breakpoint(self, line):
26 self.expect("breakpoint set -f main.m -l %d" % line,
27 BREAKPOINT_CREATED,
28 startstr = "Breakpoint created")
29
30 def self_commands(self):
31 """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods"""
32 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
33
34 self.set_breakpoint(line_number('main.m', '// breakpoint 1'))
35 self.set_breakpoint(line_number('main.m', '// breakpoint 2'))
36
37 self.runCmd("process launch", RUN_SUCCEEDED)
38
39 self.expect("expression -- m_a = 2",
40 startstr = "(int) $0 = 2")
41
42 self.runCmd("process continue")
43
44 # This would be disallowed if we enforced const. But we don't.
45 self.expect("expression -- m_a = 2",
46 error=True)
47
48 self.expect("expression -- s_a",
49 startstr = "(int) $1 = 5")
50
51if __name__ == '__main__':
52 import atexit
53 lldb.SBDebugger.Initialize()
54 atexit.register(lambda: lldb.SBDebugger.Terminate())
55 unittest2.main()