2 Test that lldb command "command source" works correctly.
7 from lldbsuite
.test
.decorators
import *
8 from lldbsuite
.test
.lldbtest
import *
9 from lldbsuite
.test
import lldbutil
12 class CommandSourceTestCase(TestBase
):
14 def test_command_source(self
):
15 """Test that lldb command "command source" works correctly."""
17 # Sourcing .lldb in the current working directory, which in turn imports
18 # the "my" package that defines the date() function.
19 self
.runCmd("command source .lldb")
23 def test_command_source_relative(self
):
24 """Test that lldb command "command source" works correctly with relative paths."""
26 # Sourcing .lldb in the current working directory, which in turn imports
27 # the "my" package that defines the date() function.
28 self
.runCmd("command source commands2.txt")
31 def check_results(self
, failure
=False):
32 # Python should evaluate "my.date()" successfully.
33 command_interpreter
= self
.dbg
.GetCommandInterpreter()
34 self
.assertTrue(command_interpreter
, VALID_COMMAND_INTERPRETER
)
35 result
= lldb
.SBCommandReturnObject()
36 command_interpreter
.HandleCommand("script my.date()", result
)
43 "script my.date() runs successfully",
50 "script my.date() runs successfully",
52 substrs
=[str(datetime
.date
.today())],
56 def test_command_source_relative_error(self
):
57 """Test that 'command source -C' gives an error for a relative path"""
58 source_dir
= self
.getSourceDir()
59 result
= lldb
.SBCommandReturnObject()
60 self
.runCmd("command source --stop-on-error 1 not-relative.txt")
61 self
.check_results(failure
=True)