2 Test that global operators are found and evaluated.
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
9 class TestCppGlobalOperators(TestBase):
11 mydir = TestBase.compute_mydir(__file__)
13 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
14 def test_with_run_command(self):
17 # Get main source file
19 src_file_spec = lldb.SBFileSpec(src_file)
20 self.assertTrue(src_file_spec.IsValid(), "Main source file")
22 # Get the path of the executable
25 exe_path = os.path.join(cwd, exe_file)
28 target = self.dbg.CreateTarget(exe_path)
29 self.assertTrue(target.IsValid(), VALID_TARGET)
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)
38 process = target.LaunchSimple(args, env, self.get_process_working_directory())
39 self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
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)
45 # Check if global operators are evaluated
46 frame = thread.GetSelectedFrame()
48 test_result = frame.EvaluateExpression("operator==(s1, s2)")
49 self.assertTrue(test_result.IsValid() and test_result.GetValue() == "false", "operator==(s1, s2) = false")
51 test_result = frame.EvaluateExpression("operator==(s1, s3)")
52 self.assertTrue(test_result.IsValid() and test_result.GetValue() == "true", "operator==(s1, s3) = true")
54 test_result = frame.EvaluateExpression("operator==(s2, s3)")
55 self.assertTrue(test_result.IsValid() and test_result.GetValue() == "false", "operator==(s2, s3) = false")