]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
iptables-test: Don't choke on empty lines
authorPhil Sutter <phil@nwl.cc>
Fri, 8 May 2020 12:57:36 +0000 (14:57 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 11 May 2020 14:51:15 +0000 (16:51 +0200)
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
iptables-test.py

index d13b119e98e032c5e28a607ef28954b5c190828f..e8f306d2462c70649d3dc93bda004710e580fed4 100644 (file)
@@ -3,4 +3,3 @@
 -j IDLETIMER --timeout 42;;FAIL
 -j IDLETIMER --timeout 42 --label foo;=;OK
 -j IDLETIMER --timeout 42 --label foo --alarm;;OK
-
index e986d7a318218de6217f77b1593ca0e14f50f063..6b6eb611a729002da3e2205a1470fb07e68cae32 100755 (executable)
@@ -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] == ":":