From: Darafei Praliaskouski Date: Fri, 8 May 2026 14:47:47 +0000 (+0400) Subject: test(options): cover quoted MTR_OPTIONS order X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=refs%2Fpull%2F644%2Fhead;p=thirdparty%2Fmtr.git test(options): cover quoted MTR_OPTIONS order --- diff --git a/test/cmdparse.py b/test/cmdparse.py index f344eaf..6a093d2 100755 --- a/test/cmdparse.py +++ b/test/cmdparse.py @@ -35,11 +35,13 @@ MTR = os.path.join(PROJECT_ROOT, 'mtr') class TestMtrCommandParse(unittest.TestCase): '''Test cases with malformed mtr command-line arguments.''' - def run_mtr(self, *args): + def run_mtr(self, *args, **kwargs): + env = kwargs.get('env') return subprocess.run( [MTR] + list(args), stdout=subprocess.PIPE, stderr=subprocess.PIPE, + env=env, universal_newlines=True, ) @@ -97,6 +99,26 @@ class TestMtrCommandParse(unittest.TestCase): self.assertIn('Loss%', reply.stdout) self.assertIn('0.00%', reply.stdout) + def test_mtr_options_preserves_quoted_order_spaces(self): + 'Test that quoted MTR_OPTIONS values can contain order separators.' + + env = os.environ.copy() + env['MTR_OPTIONS'] = '--order "SRDL NBAGVW JMXI"' + + reply = self.run_mtr( + '--report', + '--report-cycles', + '1', + '--no-dns', + '127.0.0.1', + env=env, + ) + + self.assertEqual(reply.returncode, 0) + self.assertEqual(reply.stderr, '') + self.assertIn('Drop', reply.stdout) + self.assertIn('Jint', reply.stdout) + def test_port_with_tcp_succeeds_flag(self): 'Test that specifying -P with -T (TCP) succeeds.'