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 | |
| 7 | import os, time |
Johnny Chen | 7325883 | 2010-08-05 23:42:46 +0000 | [diff] [blame] | 8 | import unittest2 |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 9 | import lldb |
Johnny Chen | 1794184 | 2010-08-09 23:44:24 +0000 | [diff] [blame^] | 10 | from lldbtest import * |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 11 | |
Johnny Chen | 1794184 | 2010-08-09 23:44:24 +0000 | [diff] [blame^] | 12 | class TestCommandSource(TestBase): |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 13 | |
| 14 | mydir = "command_source" |
| 15 | |
| 16 | def test_command_source(self): |
| 17 | """Test that lldb command "command source" works correctly.""" |
| 18 | res = self.res |
| 19 | |
| 20 | # Sourcing .lldb in the current working directory, which in turn imports |
| 21 | # the "my" package that defines the date() function. |
| 22 | self.ci.HandleCommand("command source .lldb", res) |
Johnny Chen | 1794184 | 2010-08-09 23:44:24 +0000 | [diff] [blame^] | 23 | self.assertTrue(res.Succeeded(), CMD_MSG('command source .lldb')) |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 24 | |
Johnny Chen | 8402832 | 2010-08-02 21:19:08 +0000 | [diff] [blame] | 25 | # Python should evaluate "my.date()" successfully. |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 26 | self.ci.HandleCommand("script my.date()", res) |
Johnny Chen | 7dc2e47 | 2010-07-30 22:33:14 +0000 | [diff] [blame] | 27 | if (not res.Succeeded()): |
| 28 | print res.GetError() |
Johnny Chen | 1794184 | 2010-08-09 23:44:24 +0000 | [diff] [blame^] | 29 | self.assertTrue(res.Succeeded(), CMD_MSG('script my.date()')) |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 30 | |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 31 | |
| 32 | if __name__ == '__main__': |
Johnny Chen | a212495 | 2010-08-05 21:23:45 +0000 | [diff] [blame] | 33 | import atexit |
Johnny Chen | b9e7c0a | 2010-07-29 21:42:28 +0000 | [diff] [blame] | 34 | lldb.SBDebugger.Initialize() |
Johnny Chen | a212495 | 2010-08-05 21:23:45 +0000 | [diff] [blame] | 35 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
Johnny Chen | 7325883 | 2010-08-05 23:42:46 +0000 | [diff] [blame] | 36 | unittest2.main() |