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