]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
test(output): cover bad host exit status 642/head
authorDarafei Praliaskouski <me@komzpa.net>
Fri, 8 May 2026 14:38:43 +0000 (18:38 +0400)
committerDarafei Praliaskouski <me@komzpa.net>
Mon, 25 May 2026 11:05:39 +0000 (15:05 +0400)
test/cmdparse.py

index 1aaf166ee7c2adf1484bcaf0a67e56b9e8e30ef4..f3f72be7ac68bbaee806ba57ce5e01252773bb19 100755 (executable)
@@ -127,6 +127,31 @@ class TestMtrCommandParse(unittest.TestCase):
         self.assertEqual(reply.returncode, 0)
         self.assertIn('--report-on-exit', reply.stdout)
 
+    def test_bad_host_fails_in_output_modes(self):
+        'Test failed host resolution exits non-zero in output modes.'
+
+        modes = [
+            '--csv',
+            '--raw',
+            '--report',
+            '--xml',
+        ]
+
+        reply = self.run_mtr('--help')
+        if '--json' in reply.stdout:
+            modes.append('--json')
+
+        for mode in modes:
+            reply = self.run_mtr(
+                mode,
+                '--report-cycles',
+                '1',
+                'nonexistent.invalid',
+            )
+
+            self.assertNotEqual(reply.returncode, 0)
+            self.assertIn('Failed to resolve host', reply.stderr)
+
     def test_port_with_tcp_succeeds_flag(self):
         'Test that specifying -P with -T (TCP) succeeds.'