netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [iptables PATCH] xlate-test: Fix for empty source line on failure
Date: Wed, 30 Mar 2022 17:59:10 +0200	[thread overview]
Message-ID: <20220330155910.13668-1-phil@nwl.cc> (raw)

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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xlate-test.py b/xlate-test.py
index d78e864869318..03bef7e2e5934 100755
--- a/xlate-test.py
+++ b/xlate-test.py
@@ -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:
-- 
2.34.1


                 reply	other threads:[~2022-03-30 16:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220330155910.13668-1-phil@nwl.cc \
    --to=phil@nwl.cc \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).