2 Test calling a function that waits a while, and make sure the timeout option to expr works.
5 from __future__ import print_function
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class ExprCommandWithTimeoutsTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
19 # Call super's setUp().
22 self.main_source = "wait-a-while.cpp"
23 self.main_source_spec = lldb.SBFileSpec(self.main_source)
25 @expectedFlakeyFreeBSD("llvm.org/pr19605")
30 bugnumber="llvm.org/pr21765")
32 """Test calling std::String member function."""
36 exe = os.path.join(os.getcwd(), exe_name)
38 target = self.dbg.CreateTarget(exe)
39 self.assertTrue(target, VALID_TARGET)
41 breakpoint = target.BreakpointCreateBySourceRegex(
42 'stop here in main.', self.main_source_spec)
43 self.assertTrue(breakpoint, VALID_BREAKPOINT)
44 self.runCmd("breakpoint list")
46 # Launch the process, and do not stop at the entry point.
47 process = target.LaunchSimple(
48 None, None, self.get_process_working_directory())
50 self.assertTrue(process, PROCESS_IS_VALID)
52 # Frame #0 should be on self.step_out_of_malloc.
53 threads = lldbutil.get_threads_stopped_at_breakpoint(
56 self.assertTrue(len(threads) == 1)
59 # First set the timeout too short, and make sure we fail.
60 options = lldb.SBExpressionOptions()
61 options.SetTimeoutInMicroSeconds(10)
62 options.SetUnwindOnError(True)
64 frame = thread.GetFrameAtIndex(0)
66 value = frame.EvaluateExpression("wait_a_while(1000000)", options)
67 self.assertTrue(value.IsValid())
68 self.assertFalse(value.GetError().Success())
70 # Now do the same thing with the command line command, and make sure it
72 interp = self.dbg.GetCommandInterpreter()
74 result = lldb.SBCommandReturnObject()
75 return_value = interp.HandleCommand(
76 "expr -t 100 -u true -- wait_a_while(1000000)", result)
77 self.assertTrue(return_value == lldb.eReturnStatusFailed)
79 # Okay, now do it again with long enough time outs:
81 options.SetTimeoutInMicroSeconds(1000000)
82 value = frame.EvaluateExpression("wait_a_while (1000)", options)
83 self.assertTrue(value.IsValid())
84 self.assertTrue(value.GetError().Success())
86 # Now do the same thingwith the command line command, and make sure it
88 interp = self.dbg.GetCommandInterpreter()
90 result = lldb.SBCommandReturnObject()
91 return_value = interp.HandleCommand(
92 "expr -t 1000000 -u true -- wait_a_while(1000)", result)
93 self.assertTrue(return_value == lldb.eReturnStatusSuccessFinishResult)
95 # Finally set the one thread timeout and make sure that doesn't change
98 options.SetTimeoutInMicroSeconds(1000000)
99 options.SetOneThreadTimeoutInMicroSeconds(500000)
100 value = frame.EvaluateExpression("wait_a_while (1000)", options)
101 self.assertTrue(value.IsValid())
102 self.assertTrue(value.GetError().Success())