1""" 2Test that lldb command "command source" works correctly. 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class CommandSourceTestCase(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 17 @no_debug_info_test 18 def test_command_source(self): 19 """Test that lldb command "command source" works correctly.""" 20 21 # Sourcing .lldb in the current working directory, which in turn imports 22 # the "my" package that defines the date() function. 23 self.runCmd("command source .lldb") 24 25 # Python should evaluate "my.date()" successfully. 26 command_interpreter = self.dbg.GetCommandInterpreter() 27 self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER) 28 result = lldb.SBCommandReturnObject() 29 command_interpreter.HandleCommand("script my.date()", result) 30 31 import datetime 32 self.expect(result.GetOutput(), "script my.date() runs successfully", 33 exe=False, 34 substrs=[str(datetime.date.today())]) 35