Skip to contentSkip to conversation

tests: add *.got files to .gitignore

PATCH In review Pablo M. Bermudo Garay 2 participants 5 messages Dec 1, 2015 – Dec 14, 2015 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 tests: add *.got files to .gitignore

During tests execution, some *.payload.got files may be generated. To avoid annoyances, this commit adds the pattern to .gitignore. Also, the file "dup.t.payload.got", that was presumably included by mistake, has been deleted.

---
 .gitignore                            |  3 +++
 tests/regression/ip/dup.t.payload.got | 26 --------------------------
 2 files changed, 3 insertions(+), 26 deletions(-)
 delete mode 100644 tests/regression/ip/dup.t.payload.got
.gitignore +3 -0
index 63ef1a2..009f7d0 100644
@@ -24,5 +24,8 @@ ylwrap
 src/parser_bison.c
 src/parser_bison.h
 
+# Generated by tests
+*.payload.got
+
 # Debian package build temporary files
 build-stamp
tests/regression/ip/dup.t.payload.got deleted +0 -26
deleted file mode 100644
index 23e0a7e..0000000
@@ -1,26 +0,0 @@
-# dup to 192.168.2.1 device eth0
-ip test-ip4 input 
-  [ immediate reg 1 0x0102a8c0 ]
-  [ immediate reg 2 0x00000002 0x00000000 0x00000000 0x00000000 ]
-  [ dup sreg_addr 1  sreg_dev 2 ]
-
-# dup to ip saddr map { 192.168.2.120 : 192.168.2.1 } device eth0
-map%d test-ip4 b
-map%d test-ip4 0
-	element 7802a8c0  : 0102a8c0 0 [end]
-ip test-ip4 input 
-  [ payload load 4b @ network header + 12 => reg 1 ]
-  [ lookup reg 1 set map%d dreg 1 ]
-  [ immediate reg 2 0x00000002 0x00000000 0x00000000 0x00000000 ]
-  [ dup sreg_addr 1  sreg_dev 2 ]
-
-# dup to ip saddr map { 192.168.2.120 : 192.168.2.1 } device eth0
-map%d test-ip4 b
-map%d test-ip4 0
-	element 7802a8c0  : 0102a8c0 0 [end]
-ip test-ip4 input 
-  [ payload load 4b @ network header + 12 => reg 1 ]
-  [ lookup reg 1 set map%d dreg 1 ]
-  [ immediate reg 2 0x00000002 0x00000000 0x00000000 0x00000000 ]
-  [ dup sreg_addr 1 sreg_dev 2 ]
-
Signature · 1 line
2.6.2
#1 lore raw

PATCH 2/3 tests: remove useless logic

In the test files, some lines defining tables was commented out with a minus "-" sign, also used to mark broken rules. This commit replaces these signs with actual comments "#" and removes the code that handled the situation.

---
 tests/regression/any/ct.t     | 4 ++--
 tests/regression/ip/icmp.t    | 2 +-
 tests/regression/ip6/icmpv6.t | 2 +-
 tests/regression/ip6/snat.t   | 2 +-
 tests/regression/nft-test.py  | 2 --
 5 files changed, 5 insertions(+), 7 deletions(-)
tests/regression/any/ct.t +2 -2
index ab4b167..0f5394a 100644
@@ -2,8 +2,8 @@
 *ip6;test-ip6
 *inet;test-inet
 # ct expresion is not supported in arp and bridge family yet.
-- *arp;test-arp
-- *bridge;test-bridge
+# *arp;test-arp
+# *bridge;test-bridge
 
 :output;type filter hook output priority 0
 
tests/regression/ip/icmp.t +1 -1
index 9c2aba7..bd00f5c 100644
@@ -1,6 +1,6 @@
 *ip;test-ip4
 # BUG: There is a bug with icmp protocol and inet family.
-- *inet;test-inet
+# *inet;test-inet
 :input;type filter hook input priority 0
 
 icmp type echo-reply accept;ok
tests/regression/ip6/icmpv6.t +1 -1
index c86c825..fca903f 100644
@@ -1,6 +1,6 @@
 *ip6;test-ip6
 # BUG: There is a bug with icmpv6 and inet tables
-- *inet;test-inet
+# *inet;test-inet
 :input;type filter hook input priority 0
 
 icmpv6 type destination-unreachable accept;ok
tests/regression/ip6/snat.t +1 -1
index 44ca9e4..8f841da 100644
@@ -1,5 +1,5 @@
 *ip6;test-ip6
-- *inet;test-inet
+# *inet;test-inet
 :postrouting;type nat hook postrouting priority 0
 
 tcp dport 80-90 snat 2001:838:35f:1::-2001:838:35f:2:: :80-100;ok;tcp dport 80-90 snat 2001:838:35f:1::-2001:838:35f:2:::80-100
tests/regression/nft-test.py +0 -2
index 0b0be5d..9d623b7 100755
@@ -809,8 +809,6 @@ def run_test_file(filename, force_all_family_option, specific_file):
         # Rule
         rule = line.split(';')  # rule[1] Ok or FAIL
         if line[0] == "-":  # Run omitted lines
-            if line[1:].find("*") != -1:
-                continue
             if need_fix_option:
                 rule[0] = rule[0].rstrip()[1:].strip()
             else:
Signature · 1 line
2.6.2
#2 lore raw

PATCH 3/3 tests: fix crash when rule test is malformed

In reply to Pablo M. Bermudo Garay

The tests script suffers a crash when a rule test line is malformed (e.g. if expected result is missing). This commit fixes these crashes and now the line is skipped and a warning is printed.

---
 tests/regression/nft-test.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
tests/regression/nft-test.py +5 -6
index 9d623b7..e68087f 100755
@@ -508,12 +508,6 @@ def rule_add(rule, table_list, chain_list, filename, lineno,
                     print_error("did not find payload information for rule '%s'" % rule[0], payload_log.name, 1)
 
         for chain in chain_list:
-            if len(rule) == 1:
-                reason = "Skipping malformed test. (" + \
-                    str(rule[0].rstrip('\n')) + ")"
-                print_warning(reason, filename, lineno)
-                continue
-
             unit_tests += 1
             table_flush(table, filename, lineno)
             table_info = " " + table[0] + " " + table[1] + " "
@@ -808,6 +802,11 @@ def run_test_file(filename, force_all_family_option, specific_file):
 
         # Rule
         rule = line.split(';')  # rule[1] Ok or FAIL
+        if len(rule) == 1 or len(rule) > 3 or rule[1].rstrip() not in {"ok", "fail"}:
+            reason = "Skipping malformed rule test. (" + line.rstrip('\n') + ")"
+            print_warning(reason, filename, lineno)
+            continue
+
         if line[0] == "-":  # Run omitted lines
             if need_fix_option:
                 rule[0] = rule[0].rstrip()[1:].strip()
Signature · 1 line
2.6.2
#3 lore raw
In reply to Pablo M. Bermudo Garay
Quoted 4 lines · Pablo M. Bermudo Garay

During tests execution, some *.payload.got files may be generated. To avoid annoyances, this commit adds the pattern to .gitignore. Also, the file "dup.t.payload.got", that was presumably included by mistake, has been deleted.

Series from 1 to 3 applied, thanks.

I have slightly mangled patch 2/3 to effectively remove some lines that don't make sense to have at this stage.