]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xlate-test: Fix for empty source line on failure
authorPhil Sutter <phil@nwl.cc>
Wed, 30 Mar 2022 15:54:13 +0000 (17:54 +0200)
committerPhil Sutter <phil@nwl.cc>
Thu, 31 Mar 2022 08:45:11 +0000 (10:45 +0200)
The code overwrites 'line' before checking expected output. Save it in a
temporary variable.

Fixes: 62828a6aff231 ("tests: xlate-test: support multiline expectation")
Signed-off-by: Phil Sutter <phil@nwl.cc>
xlate-test.py

index d78e864869318dca96abe577eba79b83fa4b959a..03bef7e2e59341ab6196320378f072c9c73d5061 100755 (executable)
@@ -42,6 +42,7 @@ def run_test(name, payload):
     line = payload.readline()
     while line:
         if line.startswith(keywords):
+            sourceline = line
             tests += 1
             process = Popen([ xtables_nft_multi ] + shlex.split(line), stdout=PIPE, stderr=PIPE)
             (output, error) = process.communicate()
@@ -58,7 +59,7 @@ def run_test(name, payload):
                     test_passed = False
                     failed += 1
                     result.append(name + ": " + red("Fail"))
-                    result.append(magenta("src: ") + line.rstrip(" \n"))
+                    result.append(magenta("src: ") + sourceline.rstrip(" \n"))
                     result.append(magenta("exp: ") + expected)
                     result.append(magenta("res: ") + translation + "\n")
                 else: