• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""Test calling methods on super."""
2
3import os, time
4import unittest2
5import lldb
6import lldbutil
7from lldbtest import *
8
9class TestObjCSuperMethod(TestBase):
10
11    mydir = os.path.join("lang", "objc", "objc-super")
12
13    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
14    @expectedFailurei386
15    @python_api_test
16    @dsym_test
17    def test_with_dsym_and_python_api(self):
18        """Test calling methods on super."""
19        self.buildDsym()
20        self.objc_super()
21
22    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
23    @expectedFailurei386
24    @python_api_test
25    @dwarf_test
26    def test_with_dwarf_and_python_api(self):
27        """Test calling methods on super."""
28        self.buildDwarf()
29        self.objc_super()
30
31    def setUp(self):
32        # Call super's setUp().
33        TestBase.setUp(self)
34        # Find the line numbers to break inside main().
35        self.main_source = "class.m"
36        self.break_line = line_number(self.main_source, '// Set breakpoint here.')
37
38    def objc_super(self):
39        """Test calling methods on super."""
40        exe = os.path.join(os.getcwd(), "a.out")
41
42        target = self.dbg.CreateTarget(exe)
43        self.assertTrue(target, VALID_TARGET)
44
45        bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line)
46        self.assertTrue(bpt, VALID_BREAKPOINT)
47
48        # Now launch the process, and do not stop at entry point.
49        process = target.LaunchSimple (None, None, os.getcwd())
50
51        self.assertTrue(process, PROCESS_IS_VALID)
52
53        # The stop reason of the thread should be breakpoint.
54        thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, bpt)
55
56        # Make sure we stopped at the first breakpoint.
57        self.assertTrue (len(thread_list) != 0, "No thread stopped at our breakpoint.")
58        self.assertTrue (len(thread_list) == 1, "More than one thread stopped at our breakpoint.")
59
60        # Now make sure we can call a function in the class method we've stopped in.
61        frame = thread_list[0].GetFrameAtIndex(0)
62        self.assertTrue (frame, "Got a valid frame 0 frame.")
63
64        cmd_value = frame.EvaluateExpression ("[self get]")
65        self.assertTrue (cmd_value.IsValid())
66        self.assertTrue (cmd_value.GetValueAsUnsigned() == 2)
67
68        cmd_value = frame.EvaluateExpression ("[super get]")
69        self.assertTrue (cmd_value.IsValid())
70        self.assertTrue (cmd_value.GetValueAsUnsigned() == 1)
71
72if __name__ == '__main__':
73    import atexit
74    lldb.SBDebugger.Initialize()
75    atexit.register(lambda: lldb.SBDebugger.Terminate())
76    unittest2.main()
77