]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
tests: iptables-test: Fix missing chain case
authorPhil Sutter <phil@nwl.cc>
Thu, 12 Aug 2021 17:11:59 +0000 (19:11 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 13 Sep 2021 15:00:51 +0000 (17:00 +0200)
If a chain line was really missing, Python complained about reference
before assignment of 'chain_array' variable. While being at it, reuse
print_error() function for reporting and allow to continue with the next
input file instead of exiting.

Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables-test.py

index 90e07feed36589ce6a07c8b13b93a9b17158fc8e..01966f916957bd0d0d299cfb1442528dc9903f24 100755 (executable)
@@ -215,6 +215,7 @@ def run_test_file(filename, netns):
     tests = 0
     passed = 0
     table = ""
+    chain_array = []
     total_test_passed = True
 
     if netns:
@@ -249,8 +250,10 @@ def run_test_file(filename, netns):
             continue
 
         if len(chain_array) == 0:
-            print("broken test, missing chain, leaving")
-            sys.exit()
+            print_error("broken test, missing chain",
+                        filename = filename, lineno = lineno)
+            total_test_passed = False
+            break
 
         test_passed = True
         tests += 1