Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test that lldb command "command source" works correctly. |
Johnny Chen | 8402832 | 2010-08-02 21:19:08 +0000 | [diff] [blame] | 3 | |
| 4 | See also http://llvm.org/viewvc/llvm-project?view=rev&revision=109673. |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 5 | """ |
| 6 | |
Zachary Turner | 35d017f | 2015-10-23 17:04:29 +0000 | [diff] [blame] | 7 | from __future__ import print_function |
| 8 | |
Zachary Turner | 77db4a8 | 2015-10-22 20:06:20 +0000 | [diff] [blame] | 9 | import lldb_shared |
| 10 | |
Johnny Chen | 6bcb81a | 2011-01-28 20:59:39 +0000 | [diff] [blame] | 11 | import os, sys |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 12 | import lldb |
Johnny Chen | 1794184 | 2010-08-09 23:44:24 +0000 | [diff] [blame] | 13 | from lldbtest import * |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 14 | |
Johnny Chen | cbb4be0 | 2010-09-01 19:59:58 +0000 | [diff] [blame] | 15 | class CommandSourceTestCase(TestBase): |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 16 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 17 | mydir = TestBase.compute_mydir(__file__) |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 18 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 19 | @no_debug_info_test |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 20 | def test_command_source(self): |
| 21 | """Test that lldb command "command source" works correctly.""" |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 22 | |
| 23 | # Sourcing .lldb in the current working directory, which in turn imports |
| 24 | # the "my" package that defines the date() function. |
Johnny Chen | 617cca9 | 2010-08-20 17:04:20 +0000 | [diff] [blame] | 25 | self.runCmd("command source .lldb") |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 26 | |
Johnny Chen | 8402832 | 2010-08-02 21:19:08 +0000 | [diff] [blame] | 27 | # Python should evaluate "my.date()" successfully. |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 28 | 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 Chen | 49c2245 | 2011-01-28 19:39:06 +0000 | [diff] [blame] | 32 | |
Johnny Chen | c03a362 | 2011-01-28 19:30:12 +0000 | [diff] [blame] | 33 | import datetime |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 34 | self.expect(result.GetOutput(), "script my.date() runs successfully", |
Johnny Chen | c03a362 | 2011-01-28 19:30:12 +0000 | [diff] [blame] | 35 | exe=False, |
| 36 | substrs = [str(datetime.date.today())]) |