From 5666b9f77e1cc53e42b283b8471048ab68825ca1 Mon Sep 17 00:00:00 2001 From: Darafei Praliaskouski Date: Fri, 8 May 2026 18:35:22 +0400 Subject: [PATCH] test(split): cover closed stdin exit --- test/cmdparse.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/cmdparse.py b/test/cmdparse.py index f3f72be..914a478 100755 --- a/test/cmdparse.py +++ b/test/cmdparse.py @@ -45,6 +45,16 @@ class TestMtrCommandParse(unittest.TestCase): universal_newlines=True, ) + def run_mtr_detached(self, *args): + return subprocess.run( + [MTR] + list(args), + stdin=subprocess.DEVNULL, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + timeout=10, + universal_newlines=True, + ) + def test_first_ttl_cannot_exceed_max_ttl(self): 'Test that conflicting first/max TTL options fail fast.' @@ -88,6 +98,7 @@ class TestMtrCommandParse(unittest.TestCase): reply = self.run_mtr( '--report', + '--report-cycles', '1', '--no-dns', @@ -99,6 +110,19 @@ class TestMtrCommandParse(unittest.TestCase): self.assertIn('Loss%', reply.stdout) self.assertIn('0.00%', reply.stdout) + def test_split_exits_with_closed_stdin(self): + 'Test split mode exits when stdin is /dev/null.' + + reply = self.run_mtr_detached( + '--split', + '--report-cycles', + '1', + '--no-dns', + '127.0.0.1', + ) + + self.assertEqual(reply.returncode, 0) + def test_mtr_options_preserves_quoted_order_spaces(self): 'Test that quoted MTR_OPTIONS values can contain order separators.' -- 2.47.3