blob: 31862ac9bf5447fc28b7726dfaa837ab16bfc91d [file] [log] [blame]
Johnny Chenb9e7c0a2010-07-29 21:42:28 +00001"""
2Test that lldb command "command source" works correctly.
Johnny Chen84028322010-08-02 21:19:08 +00003
4See also http://llvm.org/viewvc/llvm-project?view=rev&revision=109673.
Johnny Chenb9e7c0a2010-07-29 21:42:28 +00005"""
6
Zachary Turner35d017f2015-10-23 17:04:29 +00007from __future__ import print_function
8
Zachary Turner77db4a82015-10-22 20:06:20 +00009import lldb_shared
10
Johnny Chen6bcb81a2011-01-28 20:59:39 +000011import os, sys
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000012import lldb
Johnny Chen17941842010-08-09 23:44:24 +000013from lldbtest import *
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000014
Johnny Chencbb4be02010-09-01 19:59:58 +000015class CommandSourceTestCase(TestBase):
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000016
Greg Clayton4570d3e2013-12-10 23:19:29 +000017 mydir = TestBase.compute_mydir(__file__)
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000018
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000019 @no_debug_info_test
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000020 def test_command_source(self):
21 """Test that lldb command "command source" works correctly."""
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000022
23 # Sourcing .lldb in the current working directory, which in turn imports
24 # the "my" package that defines the date() function.
Johnny Chen617cca92010-08-20 17:04:20 +000025 self.runCmd("command source .lldb")
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000026
Johnny Chen84028322010-08-02 21:19:08 +000027 # Python should evaluate "my.date()" successfully.
Greg Clayton44d93782014-01-27 23:43:24 +000028 command_interpreter = self.dbg.GetCommandInterpreter()
29 self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
30 result = lldb.SBCommandReturnObject()
31 command_interpreter.HandleCommand("script my.date()", result)
Johnny Chen49c22452011-01-28 19:39:06 +000032
Johnny Chenc03a3622011-01-28 19:30:12 +000033 import datetime
Greg Clayton44d93782014-01-27 23:43:24 +000034 self.expect(result.GetOutput(), "script my.date() runs successfully",
Johnny Chenc03a3622011-01-28 19:30:12 +000035 exe=False,
36 substrs = [str(datetime.date.today())])