2010-07-29 21:42:28 +00:00
|
|
|
"""
|
|
|
|
|
Test that lldb command "command source" works correctly.
|
2010-08-02 21:19:08 +00:00
|
|
|
|
|
|
|
|
See also http://llvm.org/viewvc/llvm-project?view=rev&revision=109673.
|
2010-07-29 21:42:28 +00:00
|
|
|
"""
|
|
|
|
|
|
2011-01-28 20:59:39 +00:00
|
|
|
import os, sys
|
2010-08-05 23:42:46 +00:00
|
|
|
import unittest2
|
2010-07-29 21:42:28 +00:00
|
|
|
import lldb
|
2010-08-09 23:44:24 +00:00
|
|
|
from lldbtest import *
|
2010-07-29 21:42:28 +00:00
|
|
|
|
2010-09-01 19:59:58 +00:00
|
|
|
class CommandSourceTestCase(TestBase):
|
2010-07-29 21:42:28 +00:00
|
|
|
|
2013-12-10 23:19:29 +00:00
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
2010-07-29 21:42:28 +00:00
|
|
|
|
|
|
|
|
def test_command_source(self):
|
|
|
|
|
"""Test that lldb command "command source" works correctly."""
|
|
|
|
|
|
|
|
|
|
# Sourcing .lldb in the current working directory, which in turn imports
|
|
|
|
|
# the "my" package that defines the date() function.
|
2010-08-20 17:04:20 +00:00
|
|
|
self.runCmd("command source .lldb")
|
2010-07-29 21:42:28 +00:00
|
|
|
|
2010-08-02 21:19:08 +00:00
|
|
|
# Python should evaluate "my.date()" successfully.
|
2014-01-27 23:43:24 +00:00
|
|
|
command_interpreter = self.dbg.GetCommandInterpreter()
|
|
|
|
|
self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
|
|
|
|
|
result = lldb.SBCommandReturnObject()
|
|
|
|
|
command_interpreter.HandleCommand("script my.date()", result)
|
2011-01-28 19:39:06 +00:00
|
|
|
|
2011-01-28 19:30:12 +00:00
|
|
|
import datetime
|
2014-01-27 23:43:24 +00:00
|
|
|
self.expect(result.GetOutput(), "script my.date() runs successfully",
|
2011-01-28 19:30:12 +00:00
|
|
|
exe=False,
|
|
|
|
|
substrs = [str(datetime.date.today())])
|
|
|
|
|
|
2010-07-29 21:42:28 +00:00
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2010-08-05 21:23:45 +00:00
|
|
|
import atexit
|
2010-07-29 21:42:28 +00:00
|
|
|
lldb.SBDebugger.Initialize()
|
2010-08-05 21:23:45 +00:00
|
|
|
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
2010-08-05 23:42:46 +00:00
|
|
|
unittest2.main()
|