summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2016-01-13 18:11:45 +0000
committerEnrico Granata <egranata@apple.com>2016-01-13 18:11:45 +0000
commit744959b9c9d7700a567926a4829f2e8cc6dc3cec (patch)
tree9236c8d51dbc00abc4f8cf758de375500760d3b9 /lldb/packages/Python/lldbsuite/test
parentc5d29aa7c4cb5fe4c5b424c88f5ab6de5a8c4ad2 (diff)
downloadbcm5719-llvm-744959b9c9d7700a567926a4829f2e8cc6dc3cec.tar.gz
bcm5719-llvm-744959b9c9d7700a567926a4829f2e8cc6dc3cec.zip
Fix an issue where scripted commands would not actually print any of their output if an immediate output file was set in the result object via a Python file object
Fixes rdar://24130303 llvm-svn: 257644
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py37
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py8
2 files changed, 45 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
new file mode 100644
index 00000000000..6484813f67b
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
@@ -0,0 +1,37 @@
+"""
+Test that LLDB correctly allows scripted commands to set an immediate output file
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import *
+
+class CommandScriptImmediateOutputTestCase (PExpectTest):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ PExpectTest.setUp(self)
+
+ @skipIfRemote # test not remote-ready llvm.org/pr24813
+ @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
+ @expectedFlakeyLinux("llvm.org/pr25172")
+ @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
+ def test_command_script_immediate_output (self):
+ """Test that LLDB correctly allows scripted commands to set an immediate output file."""
+ self.launch(timeout=5)
+
+ script = os.path.join(os.getcwd(), 'custom_command.py')
+ prompt = "(lldb)"
+
+ self.sendline('command script import %s' % script, patterns=[prompt])
+ self.sendline('command script add -f custom_command.command_function mycommand', patterns=[prompt])
+ self.sendline('mycommand', patterns='this is a test string, just a test string')
+ self.sendline('command script delete mycommand', patterns=[prompt])
+ self.quit(gracefully=False)
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py
new file mode 100644
index 00000000000..a9749196ca7
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py
@@ -0,0 +1,8 @@
+from __future__ import print_function
+
+import sys
+
+def command_function(debugger, command, exe_ctx, result, internal_dict):
+ result.SetImmediateOutputFile(sys.__stdout__)
+ print('this is a test string, just a test string', file=result)
+
OpenPOWER on IntegriCloud