Skip to contentSkip to conversation

xlate-test: Fix for empty source line on failure

PATCH New Phil Sutter 1 participant 1 message Mar 30, 2022 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 xlate-test: Fix for empty source line on failure

The code overwrites 'line' before checking expected output. Save it in a temporary variable.

Fixes 62828a6aff231 ("tests: xlate-test: support multiline expectation")
---
 xlate-test.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xlate-test.py +2 -1
index d78e864869318..03bef7e2e5934 100755
@@ -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:
Signature · 1 line
2.34.1