]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
test(options): cover quoted MTR_OPTIONS order 644/head
authorDarafei Praliaskouski <me@komzpa.net>
Fri, 8 May 2026 14:47:47 +0000 (18:47 +0400)
committerDarafei Praliaskouski <me@komzpa.net>
Mon, 25 May 2026 11:03:54 +0000 (15:03 +0400)
test/cmdparse.py

index f344eafd891f7af55004ebbca510be674945f1c1..6a093d2eeccc99c0784167f6bdfeeabcb5433f29 100755 (executable)
@@ -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.'