[nft PATCH 12/13] tests/py: Don't read expected payload for each table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When testing rule adding to different table families, expected payload
was read for each tested family again. Instead, read it just once and
just try to read a family-specific payload for each tested family.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 tests/py/nft-test.py | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
index ef9c6dbb769e5..5f00b7d658f55 100755
--- a/tests/py/nft-test.py
+++ b/tests/py/nft-test.py
@@ -647,23 +647,25 @@ def rule_add(rule, filename, lineno, force_all_family_option, filename_path):
         print_error(reason, filename, lineno)
         return [-1, warning, error, unit_tests]
 
-    payload_expected = []
-
-    for table in table_list:
+    if rule[1].strip() == "ok":
         try:
-            payload_log = open("%s.payload.%s" % (filename_path, table.family))
-        except IOError:
             payload_log = open("%s.payload" % filename_path)
+            payload_expected = payload_find_expected(payload_log, rule[0])
+        except:
+            payload_expected = None
 
+    for table in table_list:
         if rule[1].strip() == "ok":
+            table_payload_expected = None
             try:
-                payload_expected.index(rule[0])
-            except ValueError:
-                payload_expected = payload_find_expected(payload_log, rule[0])
-
+                payload_log = open("%s.payload.%s" % (filename_path, table.family))
+                table_payload_expected = payload_find_expected(payload_log, rule[0])
+            except:
                 if not payload_expected:
                     print_error("did not find payload information for "
                                 "rule '%s'" % rule[0], payload_log.name, 1)
+            if not table_payload_expected:
+                table_payload_expected = payload_expected
 
         for table_chain in table.chains:
             chain = chain_get_by_name(table_chain)
@@ -696,7 +698,7 @@ def rule_add(rule, filename, lineno, force_all_family_option, filename_path):
                 continue
 
             # Check for matching payload
-            if state == "ok" and not payload_check(payload_expected,
+            if state == "ok" and not payload_check(table_payload_expected,
                                                    payload_log, cmd):
                 error += 1
                 gotf = open("%s.payload.got" % filename_path, 'a')
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux