1"""
2Test completion in our IOHandlers.
3"""
4
5import os
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test.lldbpexpect import PExpectTest
11
12
13class BreakpointCallbackCommandSource(PExpectTest):
14
15    mydir = TestBase.compute_mydir(__file__)
16    file_to_source = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'source.lldb')
17
18    # PExpect uses many timeouts internally and doesn't play well
19    # under ASAN on a loaded machine..
20    @skipIfAsan
21    @skipIfEditlineSupportMissing
22    @skipIf(oslist=["freebsd"], bugnumber="llvm.org/pr48316")
23    def test_breakpoint_callback_command_source(self):
24        self.build()
25        exe = self.getBuildArtifact("a.out")
26
27        self.launch(exe)
28        self.expect("b main", substrs=["Breakpoint 1"])
29        self.child.send("breakpoint command add -s python\n")
30        self.child.send(
31            "frame.GetThread().GetProcess().GetTarget().GetDebugger().HandleCommand('command source -s true {}')\n"
32            .format(self.file_to_source))
33        self.child.send("DONE\n")
34        self.expect_prompt()
35        self.expect("run", substrs=["Process", "stopped"])
36        self.expect("script print(foo)", substrs=["95126"])
37