blob: c9f151e698c1fb3687b4d007388fd65b5699a560 [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
7import os, time
Johnny Chen73258832010-08-05 23:42:46 +00008import unittest2
Johnny Chenb9e7c0a2010-07-29 21:42:28 +00009import lldb
Johnny Chen17941842010-08-09 23:44:24 +000010from lldbtest import *
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000011
Johnny Chen17941842010-08-09 23:44:24 +000012class TestCommandSource(TestBase):
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000013
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 Chen17941842010-08-09 23:44:24 +000023 self.assertTrue(res.Succeeded(), CMD_MSG('command source .lldb'))
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000024
Johnny Chen84028322010-08-02 21:19:08 +000025 # Python should evaluate "my.date()" successfully.
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000026 self.ci.HandleCommand("script my.date()", res)
Johnny Chen7dc2e472010-07-30 22:33:14 +000027 if (not res.Succeeded()):
28 print res.GetError()
Johnny Chen17941842010-08-09 23:44:24 +000029 self.assertTrue(res.Succeeded(), CMD_MSG('script my.date()'))
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000030
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000031
32if __name__ == '__main__':
Johnny Chena2124952010-08-05 21:23:45 +000033 import atexit
Johnny Chenb9e7c0a2010-07-29 21:42:28 +000034 lldb.SBDebugger.Initialize()
Johnny Chena2124952010-08-05 21:23:45 +000035 atexit.register(lambda: lldb.SBDebugger.Terminate())
Johnny Chen73258832010-08-05 23:42:46 +000036 unittest2.main()