1"""Test calling functions in class methods.""" 2 3 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test import lldbutil 9 10 11class TestObjCClassMethod(TestBase): 12 13 def setUp(self): 14 # Call super's setUp(). 15 TestBase.setUp(self) 16 # Find the line numbers to break inside main(). 17 self.main_source = "test.m" 18 self.break_line = line_number( 19 self.main_source, '// Set breakpoint here.') 20 21 @add_test_categories(['pyapi']) 22 def test_with_python_api(self): 23 """Test calling functions in class methods.""" 24 self.build() 25 exe = self.getBuildArtifact("a.out") 26 27 target = self.dbg.CreateTarget(exe) 28 self.assertTrue(target, VALID_TARGET) 29 30 bpt = target.BreakpointCreateByLocation( 31 self.main_source, self.break_line) 32 self.assertTrue(bpt, VALID_BREAKPOINT) 33 34 # Now launch the process, and do not stop at entry point. 35 process = target.LaunchSimple( 36 None, None, self.get_process_working_directory()) 37 38 self.assertTrue(process, PROCESS_IS_VALID) 39 40 # The stop reason of the thread should be breakpoint. 41 thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt) 42 43 # Make sure we stopped at the first breakpoint. 44 self.assertTrue( 45 len(thread_list) != 0, 46 "No thread stopped at our breakpoint.") 47 self.assertEquals(len(thread_list), 1, 48 "More than one thread stopped at our breakpoint.") 49 50 frame = thread_list[0].GetFrameAtIndex(0) 51 self.assertTrue(frame, "Got a valid frame 0 frame.") 52 53 # Now make sure we can call a method that returns a struct without 54 # crashing. 55 cmd_value = frame.EvaluateExpression("[provider getRange]") 56 self.assertTrue(cmd_value.IsValid()) 57