netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [iptables PATCH 1/7] tests: iptables-test: Fix missing chain case
@ 2021-09-06 16:30 Phil Sutter
  2021-09-06 16:30 ` [iptables PATCH 2/7] tests: xlate-test: Don't skip any input after the first empty line Phil Sutter
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Phil Sutter @ 2021-09-06 16:30 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

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

diff --git a/iptables-test.py b/iptables-test.py
index 90e07feed3658..01966f916957b 100755
--- a/iptables-test.py
+++ b/iptables-test.py
@@ -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
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-06 16:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06 16:30 [iptables PATCH 1/7] tests: iptables-test: Fix missing chain case Phil Sutter
2021-09-06 16:30 ` [iptables PATCH 2/7] tests: xlate-test: Don't skip any input after the first empty line Phil Sutter
2021-09-06 16:30 ` [iptables PATCH 3/7] tests: xlate-test: Print errors to stderr Phil Sutter
2021-09-06 16:30 ` [iptables PATCH 4/7] tests: iptables-test: " Phil Sutter
2021-09-06 16:30 ` [iptables PATCH 5/7] tests: xlate-test: Exit non-zero on error Phil Sutter
2021-09-06 16:30 ` [iptables PATCH 6/7] tests: iptables-test: " Phil Sutter
2021-09-06 16:30 ` [iptables PATCH 7/7] tests: shell: Return " Phil Sutter

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).