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] iptables-test: Don't choke on empty lines
Date: Mon, 11 May 2020 15:37:43 +0200	[thread overview]
Message-ID: <20200511133743.10938-1-phil@nwl.cc> (raw)

The script code wasn't expecting empty lines:

| Traceback (most recent call last):
|   File "./iptables-test.py", line 380, in <module>
|     main()
|   File "./iptables-test.py", line 370, in main
|     file_tests, file_passed = run_test_file(filename, args.netns)
|   File "./iptables-test.py", line 265, in run_test_file
|     if item[1] == "=":
| IndexError: list index out of range

Fix this by ignoring empty lines or those consisting of whitespace only.

While being at it, remove the empty line from libxt_IDLETIMER.t which
exposed the problem.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 extensions/libxt_IDLETIMER.t | 1 -
 iptables-test.py             | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/extensions/libxt_IDLETIMER.t b/extensions/libxt_IDLETIMER.t
index d13b119e98e03..e8f306d2462c7 100644
--- a/extensions/libxt_IDLETIMER.t
+++ b/extensions/libxt_IDLETIMER.t
@@ -3,4 +3,3 @@
 -j IDLETIMER --timeout 42;;FAIL
 -j IDLETIMER --timeout 42 --label foo;=;OK
 -j IDLETIMER --timeout 42 --label foo --alarm;;OK
-
diff --git a/iptables-test.py b/iptables-test.py
index e986d7a318218..6b6eb611a7290 100755
--- a/iptables-test.py
+++ b/iptables-test.py
@@ -221,7 +221,7 @@ def run_test_file(filename, netns):
         execute_cmd("ip netns add ____iptables-container-test", filename, 0)
 
     for lineno, line in enumerate(f):
-        if line[0] == "#":
+        if line[0] == "#" or len(line.strip()) == 0:
             continue
 
         if line[0] == ":":
-- 
2.25.1


                 reply	other threads:[~2020-05-11 13:37 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=20200511133743.10938-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).