diff options
author | Johnny Chen <johnny.chen@apple.com> | 2011-06-26 21:36:28 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2011-06-26 21:36:28 +0000 |
commit | 2027e2af214c5bad59737e8e7992b5e19d78adf0 (patch) | |
tree | b5d840efb83ed55b02e9fea2f914785fb6fcd3bf /lldb/test/functionalities/command_source/TestCommandSource.py | |
parent | 1429bcb3302b2edb05908ccd09855c13d54a951e (diff) | |
download | bcm5719-llvm-2027e2af214c5bad59737e8e7992b5e19d78adf0.tar.gz bcm5719-llvm-2027e2af214c5bad59737e8e7992b5e19d78adf0.zip |
Move more top level test dirs to reside under functionalities dir.
llvm-svn: 133894
Diffstat (limited to 'lldb/test/functionalities/command_source/TestCommandSource.py')
-rw-r--r-- | lldb/test/functionalities/command_source/TestCommandSource.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lldb/test/functionalities/command_source/TestCommandSource.py b/lldb/test/functionalities/command_source/TestCommandSource.py new file mode 100644 index 00000000000..26138bb31be --- /dev/null +++ b/lldb/test/functionalities/command_source/TestCommandSource.py @@ -0,0 +1,46 @@ +""" +Test that lldb command "command source" works correctly. + +See also http://llvm.org/viewvc/llvm-project?view=rev&revision=109673. +""" + +import os, sys +import unittest2 +import lldb +from lldbtest import * + +class CommandSourceTestCase(TestBase): + + mydir = os.path.join("functionalities", "command_source") + + 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. + self.runCmd("command source .lldb") + + # Let's temporarily redirect the stdout to our StringIO session object + # in order to capture the script evaluation output. + old_stdout = sys.stdout + session = StringIO.StringIO() + sys.stdout = session + + # Python should evaluate "my.date()" successfully. + # Pass 'check=False' so that sys.stdout gets restored unconditionally. + self.runCmd("script my.date()", check=False) + + # Now restore stdout to the way we were. :-) + sys.stdout = old_stdout + + import datetime + self.expect(session.getvalue(), "script my.date() runs successfully", + exe=False, + substrs = [str(datetime.date.today())]) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() |