From 8cf50997500978844f6069189d63f2e809a4abed Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 29 Dec 2020 19:33:44 +0100 Subject: tests/py: Add a test sanitizer and fix its findings This is just basic housekeeping: - Remove duplicate tests in any of the *.t files - Remove explicit output if equal to command itself in *.t files - Remove duplicate payload records in any of the *.t.payload* files - Remove stale payload records (for which no commands exist in the respective *.t file - Remove duplicate/stale entries in any of the *.t.json files In some cases, tests were added instead of removing a stale payload record if it fit nicely into the sequence of tests. Signed-off-by: Phil Sutter --- tests/py/ip6/dnat.t | 2 +- tests/py/ip6/ether.t | 2 +- tests/py/ip6/frag.t.payload.inet | 8 -------- tests/py/ip6/frag.t.payload.ip6 | 6 ------ tests/py/ip6/icmpv6.t | 2 +- tests/py/ip6/icmpv6.t.json | 11 +++++------ tests/py/ip6/icmpv6.t.payload.ip6 | 7 +++---- tests/py/ip6/ip6.t | 2 +- tests/py/ip6/ip6.t.payload.inet | 2 +- tests/py/ip6/ip6.t.payload.ip6 | 2 +- tests/py/ip6/snat.t | 2 +- 11 files changed, 15 insertions(+), 31 deletions(-) (limited to 'tests/py/ip6') diff --git a/tests/py/ip6/dnat.t b/tests/py/ip6/dnat.t index 28bd7ef9..89d5a5f9 100644 --- a/tests/py/ip6/dnat.t +++ b/tests/py/ip6/dnat.t @@ -3,7 +3,7 @@ *ip6;test-ip6;prerouting tcp dport 80-90 dnat to [2001:838:35f:1::]-[2001:838:35f:2::]:80-100;ok -tcp dport 80-90 dnat to [2001:838:35f:1::]-[2001:838:35f:2::]:100;ok;tcp dport 80-90 dnat to [2001:838:35f:1::]-[2001:838:35f:2::]:100 +tcp dport 80-90 dnat to [2001:838:35f:1::]-[2001:838:35f:2::]:100;ok tcp dport 80-90 dnat to [2001:838:35f:1::]:80;ok dnat to [2001:838:35f:1::]/64;ok;dnat to 2001:838:35f:1::/64 dnat to 2001:838:35f:1::-2001:838:35f:1:ffff:ffff:ffff:ffff;ok;dnat to 2001:838:35f:1::/64 diff --git a/tests/py/ip6/ether.t b/tests/py/ip6/ether.t index d94a0d21..49d7d063 100644 --- a/tests/py/ip6/ether.t +++ b/tests/py/ip6/ether.t @@ -3,6 +3,6 @@ *ip6;test-ip6;input tcp dport 22 iiftype ether ip6 daddr 1::2 ether saddr 00:0f:54:0c:11:4 accept;ok;tcp dport 22 ip6 daddr 1::2 ether saddr 00:0f:54:0c:11:04 accept -tcp dport 22 ip6 daddr 1::2 ether saddr 00:0f:54:0c:11:04;ok;tcp dport 22 ip6 daddr 1::2 ether saddr 00:0f:54:0c:11:04 +tcp dport 22 ip6 daddr 1::2 ether saddr 00:0f:54:0c:11:04;ok tcp dport 22 ether saddr 00:0f:54:0c:11:04 ip6 daddr 1::2;ok ether saddr 00:0f:54:0c:11:04 ip6 daddr 1::2 accept;ok diff --git a/tests/py/ip6/frag.t.payload.inet b/tests/py/ip6/frag.t.payload.inet index 917742ff..ff1458d2 100644 --- a/tests/py/ip6/frag.t.payload.inet +++ b/tests/py/ip6/frag.t.payload.inet @@ -192,14 +192,6 @@ inet test-inet output [ bitwise reg 1 = ( reg 1 & 0x0000f8ff ) ^ 0x00000000 ] [ lookup reg 1 set __set%d 0x1 ] -# frag more-fragments 1 -inet test-inet output - [ meta load nfproto => reg 1 ] - [ cmp eq reg 1 0x0000000a ] - [ exthdr load ipv6 1b @ 44 + 3 => reg 1 ] - [ bitwise reg 1 = ( reg 1 & 0x00000001 ) ^ 0x00000000 ] - [ cmp eq reg 1 0x00000001 ] - # frag id 1 inet test-inet output [ meta load nfproto => reg 1 ] diff --git a/tests/py/ip6/frag.t.payload.ip6 b/tests/py/ip6/frag.t.payload.ip6 index 2405fff8..dc4103fd 100644 --- a/tests/py/ip6/frag.t.payload.ip6 +++ b/tests/py/ip6/frag.t.payload.ip6 @@ -148,12 +148,6 @@ ip6 test-ip6 output [ bitwise reg 1 = ( reg 1 & 0x0000f8ff ) ^ 0x00000000 ] [ lookup reg 1 set __set%d 0x1 ] -# frag more-fragments 1 -ip6 test-ip6 output - [ exthdr load ipv6 1b @ 44 + 3 => reg 1 ] - [ bitwise reg 1 = ( reg 1 & 0x00000001 ) ^ 0x00000000 ] - [ cmp eq reg 1 0x00000001 ] - # frag id 1 ip6 test-ip6 output [ exthdr load ipv6 4b @ 44 + 4 => reg 1 ] diff --git a/tests/py/ip6/icmpv6.t b/tests/py/ip6/icmpv6.t index d07c34bd..a45efed6 100644 --- a/tests/py/ip6/icmpv6.t +++ b/tests/py/ip6/icmpv6.t @@ -38,7 +38,7 @@ icmpv6 code != { 3-66};ok icmpv6 checksum 2222 log;ok icmpv6 checksum != 2222 log;ok icmpv6 checksum 222-226;ok -icmpv6 checksum != 2222 log;ok +icmpv6 checksum != 222-226;ok icmpv6 checksum { 222, 226};ok icmpv6 checksum != { 222, 226};ok icmpv6 checksum { 222-226};ok diff --git a/tests/py/ip6/icmpv6.t.json b/tests/py/ip6/icmpv6.t.json index e2b25a65..96079042 100644 --- a/tests/py/ip6/icmpv6.t.json +++ b/tests/py/ip6/icmpv6.t.json @@ -640,7 +640,7 @@ } ] -# icmpv6 checksum != 2222 log +# icmpv6 checksum != 222-226 [ { "match": { @@ -650,12 +650,11 @@ "protocol": "icmpv6" } }, - "op": "!=", - "right": 2222 + "op": "!=", + "right": { + "range": [ 222, 226 ] + } } - }, - { - "log": null } ] diff --git a/tests/py/ip6/icmpv6.t.payload.ip6 b/tests/py/ip6/icmpv6.t.payload.ip6 index 448779d1..c98a2548 100644 --- a/tests/py/ip6/icmpv6.t.payload.ip6 +++ b/tests/py/ip6/icmpv6.t.payload.ip6 @@ -275,13 +275,12 @@ ip6 test-ip6 input [ cmp gte reg 1 0x0000de00 ] [ cmp lte reg 1 0x0000e200 ] -# icmpv6 checksum != 2222 log -ip6 test-ip6 input +# icmpv6 checksum != 222-226 +ip6 [ meta load l4proto => reg 1 ] [ cmp eq reg 1 0x0000003a ] [ payload load 2b @ transport header + 2 => reg 1 ] - [ cmp neq reg 1 0x0000ae08 ] - [ log ] + [ range neq reg 1 0x0000de00 0x0000e200 ] # icmpv6 checksum { 222, 226} __set%d test-ip6 3 diff --git a/tests/py/ip6/ip6.t b/tests/py/ip6/ip6.t index 8210d22b..dbb56fa3 100644 --- a/tests/py/ip6/ip6.t +++ b/tests/py/ip6/ip6.t @@ -26,7 +26,7 @@ ip6 flowlabel { 33, 55, 67, 88};ok ip6 flowlabel != { 33, 55, 67, 88};ok ip6 flowlabel { 33-55};ok ip6 flowlabel != { 33-55};ok -ip6 flowlabel vmap { 0 : accept, 2 : continue } ;ok +ip6 flowlabel vmap { 0 : accept, 2 : continue };ok ip6 length 22;ok ip6 length != 233;ok diff --git a/tests/py/ip6/ip6.t.payload.inet b/tests/py/ip6/ip6.t.payload.inet index 8912aadf..11ba34a1 100644 --- a/tests/py/ip6/ip6.t.payload.inet +++ b/tests/py/ip6/ip6.t.payload.inet @@ -113,7 +113,7 @@ inet test-inet input [ bitwise reg 1 = ( reg 1 & 0x00ffff0f ) ^ 0x00000000 ] [ lookup reg 1 set __set%d 0x1 ] -# ip6 flowlabel vmap { 0 : accept, 2 : continue } +# ip6 flowlabel vmap { 0 : accept, 2 : continue } __map%d test-inet b size 2 __map%d test-inet 0 element 00000000 : 0 [end] element 00020000 : 0 [end] diff --git a/tests/py/ip6/ip6.t.payload.ip6 b/tests/py/ip6/ip6.t.payload.ip6 index 287d58ac..78479253 100644 --- a/tests/py/ip6/ip6.t.payload.ip6 +++ b/tests/py/ip6/ip6.t.payload.ip6 @@ -89,7 +89,7 @@ ip6 test-ip6 input [ bitwise reg 1 = ( reg 1 & 0x00ffff0f ) ^ 0x00000000 ] [ lookup reg 1 set __set%d 0x1 ] -# ip6 flowlabel vmap { 0 : accept, 2 : continue } +# ip6 flowlabel vmap { 0 : accept, 2 : continue } __map%d test-ip6 b size 2 __map%d test-ip6 0 element 00000000 : 0 [end] element 00020000 : 0 [end] diff --git a/tests/py/ip6/snat.t b/tests/py/ip6/snat.t index c259f934..564f0894 100644 --- a/tests/py/ip6/snat.t +++ b/tests/py/ip6/snat.t @@ -2,5 +2,5 @@ *ip6;test-ip6;postrouting -tcp dport 80-90 snat to [2001:838:35f:1::]-[2001:838:35f:2::]:80-100;ok;tcp dport 80-90 snat to [2001:838:35f:1::]-[2001:838:35f:2::]:80-100 +tcp dport 80-90 snat to [2001:838:35f:1::]-[2001:838:35f:2::]:80-100;ok tcp dport 80-90 snat to [2001:838:35f:1::]-[2001:838:35f:2::]:100;ok -- cgit v1.2.3