iptables-test: Don't choke on empty lines
Phil Sutter
reviewerPATCH 1/1 iptables-test: Don't choke on empty lines
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 <[email protected]>
--- extensions/libxt_IDLETIMER.t | 1 - iptables-test.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
extensions/libxt_IDLETIMER.t +0 -1
@@ -3,4 +3,3 @@ -j IDLETIMER --timeout 42;;FAIL -j IDLETIMER --timeout 42 --label foo;=;OK -j IDLETIMER --timeout 42 --label foo --alarm;;OK -
iptables-test.py +1 -1
@@ -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] == ":":
Signature · 1 line
2.25.1