kunit: tool: skip stty when stdin is not a tty
PATCH 1/1 kunit: tool: skip stty when stdin is not a tty
run_kernel() cleanup and signal_handler() invoke stty unconditionally. When stdin is not a tty (for example in CI or unit tests), this writes noise to stderr.
Call stty only when stdin is a tty.
Add regression tests for these paths:
- run_kernel() with non-tty stdin
- signal_handler() with non-tty stdin
- signal_handler() with tty stdin
--- tools/testing/kunit/kunit_kernel.py | 10 ++++-- tools/testing/kunit/kunit_tool_test.py | 42 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-)
tools/testing/kunit/kunit_kernel.py +8 -2
@@ -345,6 +345,12 @@ class LinuxSourceTree: return False return self.validate_config(build_dir) + def _restore_terminal_if_tty(self) -> None: + # stty requires a controlling terminal; skip headless runs. + if sys.stdin is None or not sys.stdin.isatty(): + return + subprocess.call(['stty', 'sane']) + def run_kernel(self, args: Optional[List[str]]=None, build_dir: str='', filter_glob: str='', filter: str='', filter_action: Optional[str]=None, timeout: Optional[int]=None) -> Iterator[str]: if not args: args = []
@@ -384,8 +390,8 @@ class LinuxSourceTree: process.stdout.close() waiter.join() - subprocess.call(['stty', 'sane']) + self._restore_terminal_if_tty() def signal_handler(self, unused_sig: int, unused_frame: Optional[FrameType]) -> None: logging.error('Build interruption occurred. Cleaning console.') - subprocess.call(['stty', 'sane']) + self._restore_terminal_if_tty()
tools/testing/kunit/kunit_tool_test.py +42 -0
48 lines not on this page · raw message
base-commit: a75cb869a8ccc88b0bc7a44e1597d9c7995c56e5
Signature · 1 line
2.50.0
Le 27/02/2026 à 8:31 PM, Shuvam Pandey a écrit :
Quoted 6 lines
run_kernel()cleanup andsignal_handler()invoke stty unconditionally. When stdin is not a tty (for example in CI or unit tests), this writes noise to stderr.Call stty only when stdin is a tty.
Quoted 7 lines
Add regression tests for these paths:
-run_kernel()with non-tty stdin
-signal_handler()with non-tty stdin
-signal_handler()with tty stdinSigned-off-by Shuvam Pandey <[email protected]>---
Cheers,
-- David