diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py | 27 |
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") |