diff options
| author | Ebuka Ezike <yerimyah1@gmail.com> | 2026-01-08 18:46:03 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-08 18:46:03 +0000 |
| commit | 43cb4631c1f42dbfce78288b8ae30b5840ed59b3 (patch) | |
| tree | b753c1d68e5fe96b0109962a8718ea722718de7a /lldb/test/API/python_api | |
| parent | f0275bd6ba888d409cf677d498233d3be75cbf6b (diff) | |
| download | llvm-43cb4631c1f42dbfce78288b8ae30b5840ed59b3.zip llvm-43cb4631c1f42dbfce78288b8ae30b5840ed59b3.tar.gz llvm-43cb4631c1f42dbfce78288b8ae30b5840ed59b3.tar.bz2 | |
[lldb] Fix typed commands not shown on the screen (#174216)
The cause is that in `python3.14`, `fcntl.ioctl` now throws a buffer
overflow error
when the buffer is too small or too large (see
https://github.com/python/cpython/pull/132919). This caused the Python
interpreter to fail terminal detection and not properly echo user
commands back to the screen.
Fix by dropping the custom terminal size check entirely and using the
built-in `sys.stdin.isatty()` instead.
Fixes #173302
Diffstat (limited to 'lldb/test/API/python_api')
| -rw-r--r-- | lldb/test/API/python_api/file_handle/TestFileHandle.py | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/lldb/test/API/python_api/file_handle/TestFileHandle.py b/lldb/test/API/python_api/file_handle/TestFileHandle.py index b385855..707044a 100644 --- a/lldb/test/API/python_api/file_handle/TestFileHandle.py +++ b/lldb/test/API/python_api/file_handle/TestFileHandle.py @@ -111,10 +111,11 @@ class FileHandleTestCase(lldbtest.TestBase): super(FileHandleTestCase, self).setUp() self.out_filename = self.getBuildArtifact("output") self.in_filename = self.getBuildArtifact("input") + self.err_filename = self.getBuildArtifact("error") def tearDown(self): super(FileHandleTestCase, self).tearDown() - for name in (self.out_filename, self.in_filename): + for name in (self.out_filename, self.in_filename, self.err_filename): if os.path.exists(name): os.unlink(name) @@ -679,6 +680,51 @@ class FileHandleTestCase(lldbtest.TestBase): lines = [x for x in f.read().strip().split() if x != "7"] self.assertEqual(lines, ["foobar"]) + def test_stdout_file_interactive(self): + """Ensure when we read stdin from a file, outputs from python goes to the right I/O stream.""" + with open(self.in_filename, "w") as f: + f.write( + "script --language python --\nvalue = 250 + 5\nprint(value)\nprint(vel)" + ) + + with open(self.out_filename, "w") as outf, open( + self.in_filename, "r" + ) as inf, open(self.err_filename, "w") as errf: + status = self.dbg.SetOutputFile(lldb.SBFile(outf)) + self.assertSuccess(status) + status = self.dbg.SetErrorFile(lldb.SBFile(errf)) + self.assertSuccess(status) + status = self.dbg.SetInputFile(lldb.SBFile(inf)) + self.assertSuccess(status) + auto_handle_events = True + spawn_thread = False + num_errs = 0 + quit_requested = False + stopped_for_crash = False + opts = lldb.SBCommandInterpreterRunOptions() + self.dbg.RunCommandInterpreter( + auto_handle_events, + spawn_thread, + opts, + num_errs, + quit_requested, + stopped_for_crash, + ) + self.dbg.GetOutputFile().Flush() + expected_out_text = "255" + expected_err_text = "NameError" + # check stdout + with open(self.out_filename, "r") as f: + out_text = f.read() + self.assertIn(expected_out_text, out_text) + self.assertNotIn(expected_err_text, out_text) + + # check stderr + with open(self.err_filename, "r") as f: + err_text = f.read() + self.assertIn(expected_err_text, err_text) + self.assertNotIn(expected_out_text, err_text) + def test_identity(self): f = io.StringIO() sbf = lldb.SBFile(f) |
