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