summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite
diff options
context:
space:
mode:
authorLawrence D'Anna <lawrence_danna@apple.com>2019-10-15 17:41:40 +0000
committerLawrence D'Anna <lawrence_danna@apple.com>2019-10-15 17:41:40 +0000
commit30cf609548d9379178ef618d9c8790459221ed22 (patch)
tree858eb178708952d85cc7d9e283350f71c0a1d2f3 /lldb/packages/Python/lldbsuite
parentfdfd6ab12e5e2ad3f6641a3b4442b3140212d29b (diff)
downloadbcm5719-llvm-30cf609548d9379178ef618d9c8790459221ed22.tar.gz
bcm5719-llvm-30cf609548d9379178ef618d9c8790459221ed22.zip
remove FILE* usage from SBStream.i
Summary: This patch removes FILE* and replaces it with SBFile and FileSP the SWIG interface for `SBStream.i`. And this is the last one. With this change, nothing in the python API will can access a FILE* method on the C++ side. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68960 llvm-svn: 374924
Diffstat (limited to 'lldb/packages/Python/lldbsuite')
-rw-r--r--lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py b/lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
index c9c55b458b4..6b17b07218c 100644
--- a/lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
+++ b/lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
@@ -892,3 +892,30 @@ class FileHandleTestCase(lldbtest.TestBase):
sbf = self.debugger.GetInputFile()
if sys.version_info.major >= 3:
self.assertEqual(sbf.GetFile().fileno(), 0)
+
+
+ @add_test_categories(['pyapi'])
+ def test_sbstream(self):
+
+ with open(self.out_filename, 'w') as f:
+ stream = lldb.SBStream()
+ stream.RedirectToFile(f)
+ stream.Print("zork")
+ with open(self.out_filename, 'r') as f:
+ self.assertEqual(f.read().strip(), "zork")
+
+ with open(self.out_filename, 'w') as f:
+ stream = lldb.SBStream()
+ stream.RedirectToFileHandle(f, True)
+ stream.Print("Yendor")
+ with open(self.out_filename, 'r') as f:
+ self.assertEqual(f.read().strip(), "Yendor")
+
+ stream = lldb.SBStream()
+ f = open(self.out_filename, 'w')
+ stream.RedirectToFile(lldb.SBFile.Create(f, borrow=False))
+ stream.Print("Frobozz")
+ stream = None
+ self.assertTrue(f.closed)
+ with open(self.out_filename, 'r') as f:
+ self.assertEqual(f.read().strip(), "Frobozz")
OpenPOWER on IntegriCloud