]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / cpp / chained-calls / TestCppChainedCalls.py
1 import lldb
2 from lldbsuite.test.decorators import *
3 from lldbsuite.test.lldbtest import *
4 from lldbsuite.test import lldbutil
5
6
7 class TestCppChainedCalls(TestBase):
8
9     mydir = TestBase.compute_mydir(__file__)
10
11     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
12     def test_with_run_command(self):
13         self.build()
14
15         # Get main source file
16         src_file = "main.cpp"
17         src_file_spec = lldb.SBFileSpec(src_file)
18         self.assertTrue(src_file_spec.IsValid(), "Main source file")
19
20         # Get the path of the executable
21         cwd = os.getcwd()
22         exe_file = "a.out"
23         exe_path = os.path.join(cwd, exe_file)
24
25         # Load the executable
26         target = self.dbg.CreateTarget(exe_path)
27         self.assertTrue(target.IsValid(), VALID_TARGET)
28
29         # Break on main function
30         main_breakpoint = target.BreakpointCreateBySourceRegex(
31             "break here", src_file_spec)
32         self.assertTrue(
33             main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1,
34             VALID_BREAKPOINT)
35
36         # Launch the process
37         args = None
38         env = None
39         process = target.LaunchSimple(
40             args, env, self.get_process_working_directory())
41         self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
42
43         # Get the thread of the process
44         self.assertTrue(
45             process.GetState() == lldb.eStateStopped,
46             PROCESS_STOPPED)
47         thread = lldbutil.get_stopped_thread(
48             process, lldb.eStopReasonBreakpoint)
49
50         # Get frame for current thread
51         frame = thread.GetSelectedFrame()
52
53         # Test chained calls
54         test_result = frame.EvaluateExpression("get(set(true))")
55         self.assertTrue(
56             test_result.IsValid() and test_result.GetValue() == "true",
57             "get(set(true)) = true")
58
59         test_result = frame.EvaluateExpression("get(set(false))")
60         self.assertTrue(
61             test_result.IsValid() and test_result.GetValue() == "false",
62             "get(set(false)) = false")
63
64         test_result = frame.EvaluateExpression("get(t & f)")
65         self.assertTrue(
66             test_result.IsValid() and test_result.GetValue() == "false",
67             "get(t & f) = false")
68
69         test_result = frame.EvaluateExpression("get(f & t)")
70         self.assertTrue(
71             test_result.IsValid() and test_result.GetValue() == "false",
72             "get(f & t) = false")
73
74         test_result = frame.EvaluateExpression("get(t & t)")
75         self.assertTrue(
76             test_result.IsValid() and test_result.GetValue() == "true",
77             "get(t & t) = true")
78
79         test_result = frame.EvaluateExpression("get(f & f)")
80         self.assertTrue(
81             test_result.IsValid() and test_result.GetValue() == "false",
82             "get(f & f) = false")
83
84         test_result = frame.EvaluateExpression("get(t & f)")
85         self.assertTrue(
86             test_result.IsValid() and test_result.GetValue() == "false",
87             "get(t & f) = false")
88
89         test_result = frame.EvaluateExpression("get(f) && get(t)")
90         self.assertTrue(
91             test_result.IsValid() and test_result.GetValue() == "false",
92             "get(f) && get(t) = false")
93
94         test_result = frame.EvaluateExpression("get(f) && get(f)")
95         self.assertTrue(
96             test_result.IsValid() and test_result.GetValue() == "false",
97             "get(f) && get(t) = false")
98
99         test_result = frame.EvaluateExpression("get(t) && get(t)")
100         self.assertTrue(
101             test_result.IsValid() and test_result.GetValue() == "true",
102             "get(t) && get(t) = true")