]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / cpp / global_operators / TestCppGlobalOperators.py
1 """
2 Test that global operators are found and evaluated.
3 """
4 import lldb
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
8
9 class TestCppGlobalOperators(TestBase):
10     
11     mydir = TestBase.compute_mydir(__file__)
12     
13     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
14     def test_with_run_command(self):
15         self.build()
16
17         # Get main source file
18         src_file = "main.cpp"
19         src_file_spec = lldb.SBFileSpec(src_file)
20         self.assertTrue(src_file_spec.IsValid(), "Main source file")
21         
22         # Get the path of the executable
23         cwd = os.getcwd()
24         exe_file = "a.out"
25         exe_path  = os.path.join(cwd, exe_file)
26         
27         # Load the executable
28         target = self.dbg.CreateTarget(exe_path)
29         self.assertTrue(target.IsValid(), VALID_TARGET)
30
31         # Break on main function
32         main_breakpoint = target.BreakpointCreateBySourceRegex("// break here", src_file_spec)
33         self.assertTrue(main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT)
34
35         # Launch the process
36         args = None
37         env = None
38         process = target.LaunchSimple(args, env, self.get_process_working_directory())
39         self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
40
41         # Get the thread of the process
42         self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
43         thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
44
45         # Check if global operators are evaluated 
46         frame = thread.GetSelectedFrame()
47
48         test_result = frame.EvaluateExpression("operator==(s1, s2)")
49         self.assertTrue(test_result.IsValid() and test_result.GetValue() == "false", "operator==(s1, s2) = false")
50  
51         test_result = frame.EvaluateExpression("operator==(s1, s3)")
52         self.assertTrue(test_result.IsValid() and test_result.GetValue() == "true", "operator==(s1, s3) = true")
53
54         test_result = frame.EvaluateExpression("operator==(s2, s3)")
55         self.assertTrue(test_result.IsValid() and test_result.GetValue() == "false", "operator==(s2, s3) = false")