All of lore.kernel.org
 help / color / mirror / Atom feed
* [nft PATCH 0/4] Some fixes and minor improvements in tests/
@ 2019-06-07 17:25 Phil Sutter
  2019-06-07 17:25 ` [nft PATCH 1/4] tests/py: Fix JSON equivalents Phil Sutter
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Phil Sutter @ 2019-06-07 17:25 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

This series mostly adds missing bits and changes to JSON equivalents in
tests/py to avoid errors when running the suite with -j flag.

In addition to that, patch 3 fixes awk syntax in 0028delete_handle_0
test of tests/shell suite. Patch 4 improves the diff output upon dump
errors in same suite by printing unified diffs instead of normal ones.

Phil Sutter (4):
  tests/py: Fix JSON equivalents
  tests/py: Add missing arp.t JSON equivalents
  tests/shell: Fix warning from awk call
  tests/shell: Print unified diffs in dump errors

 tests/py/any/ct.t.json                        |  35 ++++--
 tests/py/any/ct.t.json.output                 |  21 +++-
 tests/py/any/meta.t.json                      | 110 +++++++-----------
 tests/py/arp/arp.t.json                       |  64 ++++++++++
 tests/py/arp/arp.t.json.output                |  14 +--
 tests/shell/run-tests.sh                      |   2 +-
 .../shell/testcases/sets/0028delete_handle_0  |   2 +-
 7 files changed, 158 insertions(+), 90 deletions(-)

-- 
2.21.0


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

* [nft PATCH 1/4] tests/py: Fix JSON equivalents
  2019-06-07 17:25 [nft PATCH 0/4] Some fixes and minor improvements in tests/ Phil Sutter
@ 2019-06-07 17:25 ` Phil Sutter
  2019-06-07 17:25 ` [nft PATCH 2/4] tests/py: Add missing arp.t " Phil Sutter
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2019-06-07 17:25 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Recent patch removing single element set use missed to adjust JSON
equivalents accordingly.

Fixes: 27f6a4c68b4fd ("tests: replace single element sets")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 tests/py/any/ct.t.json        |  35 +++++++----
 tests/py/any/ct.t.json.output |  21 ++++++-
 tests/py/any/meta.t.json      | 110 +++++++++++++---------------------
 3 files changed, 86 insertions(+), 80 deletions(-)

diff --git a/tests/py/any/ct.t.json b/tests/py/any/ct.t.json
index 45e48f224957f..7c16f9df2195a 100644
--- a/tests/py/any/ct.t.json
+++ b/tests/py/any/ct.t.json
@@ -883,7 +883,7 @@
     }
 ]
 
-# ct expiration {33-55}
+# ct expiration {33-55, 66-88}
 [
     {
         "match": {
@@ -895,16 +895,15 @@
             "op": "==",
             "right": {
                 "set": [
-                    {
-                        "range": [ 33, 55 ]
-                    }
+                    { "range": [ 33, 55 ] },
+                    { "range": [ 66, 88 ] }
                 ]
             }
         }
     }
 ]
 
-# ct expiration != {33-55}
+# ct expiration != {33-55, 66-88}
 [
     {
         "match": {
@@ -916,9 +915,8 @@
             "op": "!=",
             "right": {
                 "set": [
-                    {
-                        "range": [ 33, 55 ]
-                    }
+                    { "range": [ 33, 55 ] },
+                    { "range": [ 66, 88 ] }
                 ]
             }
         }
@@ -1003,7 +1001,7 @@
     }
 ]
 
-# ct direction . ct mark { original . 0x12345678}
+# ct direction . ct mark { original . 0x12345678, reply . 0x87654321}
 [
     {
         "match": {
@@ -1029,6 +1027,12 @@
                             "original",
                             "0x12345678"
                         ]
+                    },
+                    {
+                        "concat": [
+                            "reply",
+                            "0x87654321"
+                        ]
                     }
                 ]
             }
@@ -1036,7 +1040,7 @@
     }
 ]
 
-# ct state . ct mark vmap { new . 0x12345678 : drop}
+# ct state . ct mark vmap { new . 0x12345678 : drop, established . 0x87654321 : accept}
 [
     {
         "vmap": {
@@ -1066,6 +1070,17 @@
                         {
                             "drop": null
                         }
+                    ],
+                    [
+                        {
+                            "concat": [
+                                "established",
+                                "0x87654321"
+                            ]
+                        },
+                        {
+                            "accept": null
+                        }
                     ]
                 ]
             }
diff --git a/tests/py/any/ct.t.json.output b/tests/py/any/ct.t.json.output
index 49d51771de9c1..aced3817cf49a 100644
--- a/tests/py/any/ct.t.json.output
+++ b/tests/py/any/ct.t.json.output
@@ -549,7 +549,7 @@
     }
 ]
 
-# ct direction . ct mark { original . 0x12345678}
+# ct direction . ct mark { original . 0x12345678, reply . 0x87654321}
 [
     {
         "match": {
@@ -575,6 +575,12 @@
                             "original",
                             305419896
                         ]
+                    },
+                    {
+                        "concat": [
+                            "reply",
+                            2271560481
+                        ]
                     }
                 ]
             }
@@ -582,7 +588,7 @@
     }
 ]
 
-# ct state . ct mark vmap { new . 0x12345678 : drop}
+# ct state . ct mark vmap { new . 0x12345678 : drop, established . 0x87654321 : accept}
 [
     {
         "vmap": {
@@ -602,6 +608,17 @@
             },
             "data": {
                 "set": [
+                    [
+                        {
+                            "concat": [
+                                "established",
+                                2271560481
+                            ]
+                        },
+                        {
+                            "accept": null
+                        }
+                    ],
                     [
                         {
                             "concat": [
diff --git a/tests/py/any/meta.t.json b/tests/py/any/meta.t.json
index 2cf91cdae60e8..447e553f8ba78 100644
--- a/tests/py/any/meta.t.json
+++ b/tests/py/any/meta.t.json
@@ -143,7 +143,7 @@
     }
 ]
 
-# meta length { 33-55}
+# meta length { 33-55, 66-88}
 [
     {
         "match": {
@@ -153,14 +153,15 @@
             "op": "==",
             "right": {
                 "set": [
-                    { "range": [ 33, 55 ] }
+                    { "range": [ 33, 55 ] },
+		    { "range": [ 66, 88 ] }
                 ]
             }
         }
     }
 ]
 
-# meta length != { 33-55}
+# meta length != { 33-55, 66-88}
 [
     {
         "match": {
@@ -170,7 +171,8 @@
             "op": "!=",
             "right": {
                 "set": [
-                    { "range": [ 33, 55 ] }
+                    { "range": [ 33, 55 ] },
+		    { "range": [ 66, 88 ] }
                 ]
             }
         }
@@ -339,7 +341,7 @@
     }
 ]
 
-# meta l4proto { 33-55}
+# meta l4proto { 33-55, 66-88}
 [
     {
         "match": {
@@ -349,14 +351,15 @@
             "op": "==",
             "right": {
                 "set": [
-                    { "range": [ 33, 55 ] }
+                    { "range": [ 33, 55 ] },
+                    { "range": [ 66, 88 ] }
                 ]
             }
         }
     }
 ]
 
-# meta l4proto != { 33-55}
+# meta l4proto != { 33-55, 66-88}
 [
     {
         "match": {
@@ -366,7 +369,8 @@
             "op": "!=",
             "right": {
                 "set": [
-                    { "range": [ 33, 55 ] }
+                    { "range": [ 33, 55 ] },
+                    { "range": [ 66, 88 ] }
                 ]
             }
         }
@@ -980,46 +984,6 @@
     }
 ]
 
-# meta oif {"lo"} accept
-[
-    {
-        "match": {
-            "left": {
-                "meta": { "key": "oif" }
-            },
-            "op": "==",
-            "right": {
-                "set": [
-                    "lo"
-                ]
-            }
-        }
-    },
-    {
-        "accept": null
-    }
-]
-
-# meta oif != {"lo"} accept
-[
-    {
-        "match": {
-            "left": {
-                "meta": { "key": "oif" }
-            },
-            "op": "!=",
-            "right": {
-                "set": [
-                    "lo"
-                ]
-            }
-        }
-    },
-    {
-        "accept": null
-    }
-]
-
 # meta oifname "dummy0"
 [
     {
@@ -1316,7 +1280,7 @@
     }
 ]
 
-# meta skuid { 2001-2005} accept
+# meta skuid { 2001-2005, 3001-3005} accept
 [
     {
         "match": {
@@ -1326,7 +1290,8 @@
             "op": "==",
             "right": {
                 "set": [
-                    { "range": [ 2001, 2005 ] }
+                    { "range": [ 2001, 2005 ] },
+                    { "range": [ 3001, 3005 ] }
                 ]
             }
         }
@@ -1336,7 +1301,7 @@
     }
 ]
 
-# meta skuid != { 2001-2005} accept
+# meta skuid != { 2001-2005, 3001-3005} accept
 [
     {
         "match": {
@@ -1346,7 +1311,8 @@
             "op": "!=",
             "right": {
                 "set": [
-                    { "range": [ 2001, 2005 ] }
+                    { "range": [ 2001, 2005 ] },
+                    { "range": [ 3001, 3005 ] }
                 ]
             }
         }
@@ -1988,7 +1954,7 @@
     }
 ]
 
-# meta iifgroup {"default"}
+# meta iifgroup {"default", 11}
 [
     {
         "match": {
@@ -1998,14 +1964,15 @@
             "op": "==",
             "right": {
                 "set": [
-                    "default"
+                    "default",
+		    11
                 ]
             }
         }
     }
 ]
 
-# meta iifgroup != {"default"}
+# meta iifgroup != {"default", 11}
 [
     {
         "match": {
@@ -2015,7 +1982,8 @@
             "op": "!=",
             "right": {
                 "set": [
-                    "default"
+                    "default",
+		    11
                 ]
             }
         }
@@ -2040,7 +2008,7 @@
     }
 ]
 
-# meta iifgroup {11-33}
+# meta iifgroup {11-33, 44-55}
 [
     {
         "match": {
@@ -2050,7 +2018,8 @@
             "op": "==",
             "right": {
                 "set": [
-                    { "range": [ 11, 33 ] }
+                    { "range": [ 11, 33 ] },
+                    { "range": [ 44, 55 ] }
                 ]
             }
         }
@@ -2075,7 +2044,7 @@
     }
 ]
 
-# meta iifgroup != {11-33}
+# meta iifgroup != {11-33, 44-55}
 [
     {
         "match": {
@@ -2085,7 +2054,8 @@
             "op": "!=",
             "right": {
                 "set": [
-                    { "range": [ 11, 33 ] }
+                    { "range": [ 11, 33 ] },
+                    { "range": [ 44, 55 ] }
                 ]
             }
         }
@@ -2144,7 +2114,7 @@
     }
 ]
 
-# meta oifgroup {"default"}
+# meta oifgroup {"default", 11}
 [
     {
         "match": {
@@ -2154,14 +2124,15 @@
             "op": "==",
             "right": {
                 "set": [
-                    "default"
+                    "default",
+		    11
                 ]
             }
         }
     }
 ]
 
-# meta oifgroup != {"default"}
+# meta oifgroup != {"default", 11}
 [
     {
         "match": {
@@ -2171,7 +2142,8 @@
             "op": "!=",
             "right": {
                 "set": [
-                    "default"
+                    "default",
+		    11
                 ]
             }
         }
@@ -2196,7 +2168,7 @@
     }
 ]
 
-# meta oifgroup {11-33}
+# meta oifgroup {11-33, 44-55}
 [
     {
         "match": {
@@ -2206,7 +2178,8 @@
             "op": "==",
             "right": {
                 "set": [
-                    { "range": [ 11, 33 ] }
+                    { "range": [ 11, 33 ] },
+                    { "range": [ 44, 55 ] }
                 ]
             }
         }
@@ -2231,7 +2204,7 @@
     }
 ]
 
-# meta oifgroup != {11-33}
+# meta oifgroup != {11-33, 44-55}
 [
     {
         "match": {
@@ -2241,7 +2214,8 @@
             "op": "!=",
             "right": {
                 "set": [
-                    { "range": [ 11, 33 ] }
+                    { "range": [ 11, 33 ] },
+                    { "range": [ 44, 55 ] }
                 ]
             }
         }
-- 
2.21.0


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

* [nft PATCH 2/4] tests/py: Add missing arp.t JSON equivalents
  2019-06-07 17:25 [nft PATCH 0/4] Some fixes and minor improvements in tests/ Phil Sutter
  2019-06-07 17:25 ` [nft PATCH 1/4] tests/py: Fix JSON equivalents Phil Sutter
@ 2019-06-07 17:25 ` Phil Sutter
  2019-06-07 17:25 ` [nft PATCH 3/4] tests/shell: Fix warning from awk call Phil Sutter
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2019-06-07 17:25 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Fixes: 4b0f2a712b579 ("src: support for arp sender and target ethernet and IPv4 addresses")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 tests/py/arp/arp.t.json        | 64 ++++++++++++++++++++++++++++++++++
 tests/py/arp/arp.t.json.output | 14 ++++----
 2 files changed, 70 insertions(+), 8 deletions(-)

diff --git a/tests/py/arp/arp.t.json b/tests/py/arp/arp.t.json
index 4b0439e6edd58..0ea62645bbf6a 100644
--- a/tests/py/arp/arp.t.json
+++ b/tests/py/arp/arp.t.json
@@ -816,6 +816,70 @@
     }
 ]
 
+# arp saddr ip 1.2.3.4
+[
+    {
+        "match": {
+            "left": {
+                "payload": {
+                    "field": "saddr ip",
+                    "protocol": "arp"
+                }
+            },
+            "op": "==",
+            "right": "1.2.3.4"
+        }
+    }
+]
+
+# arp daddr ip 4.3.2.1
+[
+    {
+        "match": {
+            "left": {
+                "payload": {
+                    "field": "daddr ip",
+                    "protocol": "arp"
+                }
+            },
+            "op": "==",
+            "right": "4.3.2.1"
+        }
+    }
+]
+
+# arp saddr ether aa:bb:cc:aa:bb:cc
+[
+    {
+        "match": {
+            "left": {
+                "payload": {
+                    "field": "saddr ether",
+                    "protocol": "arp"
+                }
+            },
+            "op": "==",
+            "right": "aa:bb:cc:aa:bb:cc"
+        }
+    }
+]
+
+# arp daddr ether aa:bb:cc:aa:bb:cc
+[
+    {
+        "match": {
+            "left": {
+                "payload": {
+                    "field": "daddr ether",
+                    "protocol": "arp"
+                }
+            },
+            "op": "==",
+            "right": "aa:bb:cc:aa:bb:cc"
+        }
+    }
+]
+
 # meta iifname "invalid" arp ptype 0x0800 arp htype 1 arp hlen 6 arp plen 4 @nh,192,32 0xc0a88f10 @nh,144,48 set 0x112233445566
 [
     {
diff --git a/tests/py/arp/arp.t.json.output b/tests/py/arp/arp.t.json.output
index 4053d94763de5..b8507bffc8cc4 100644
--- a/tests/py/arp/arp.t.json.output
+++ b/tests/py/arp/arp.t.json.output
@@ -129,25 +129,23 @@
         "match": {
             "left": {
                 "payload": {
-                    "base": "nh",
-                    "len": 32,
-                    "offset": 192
+                    "field": "daddr ip",
+                    "protocol": "arp"
                 }
             },
 	    "op": "==",
-            "right": 3232272144
+            "right": "192.168.143.16"
         }
     },
     {
         "mangle": {
             "key": {
                 "payload": {
-                    "base": "nh",
-                    "len": 48,
-                    "offset": 144
+                    "field": "daddr ether",
+                    "protocol": "arp"
                 }
             },
-            "value": 18838586676582
+            "value": "11:22:33:44:55:66"
         }
     }
 ]
-- 
2.21.0


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

* [nft PATCH 3/4] tests/shell: Fix warning from awk call
  2019-06-07 17:25 [nft PATCH 0/4] Some fixes and minor improvements in tests/ Phil Sutter
  2019-06-07 17:25 ` [nft PATCH 1/4] tests/py: Fix JSON equivalents Phil Sutter
  2019-06-07 17:25 ` [nft PATCH 2/4] tests/py: Add missing arp.t " Phil Sutter
@ 2019-06-07 17:25 ` Phil Sutter
  2019-06-07 17:25 ` [nft PATCH 4/4] tests/shell: Print unified diffs in dump errors Phil Sutter
  2019-06-07 22:06 ` [nft PATCH 0/4] Some fixes and minor improvements in tests/ Pablo Neira Ayuso
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2019-06-07 17:25 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Syntax passed to awk in that one testcase caused a warning, fix the
syntax.

Fixes: e0a9aad024809 ("tests: shell: fix tests for deletion via handle attribute")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 tests/shell/testcases/sets/0028delete_handle_0 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/shell/testcases/sets/0028delete_handle_0 b/tests/shell/testcases/sets/0028delete_handle_0
index 626d51bc2cbb2..4e8b3228f6052 100755
--- a/tests/shell/testcases/sets/0028delete_handle_0
+++ b/tests/shell/testcases/sets/0028delete_handle_0
@@ -7,7 +7,7 @@ $NFT add set test-ip y { type inet_service \; timeout 3h45s \;}
 $NFT add set test-ip z { type ipv4_addr\; flags constant , interval\;}
 $NFT add set test-ip c {type ipv4_addr \; flags timeout \; elements={192.168.1.1 timeout 10s, 192.168.1.2 timeout 30s} \;}
 
-set_handle=$($NFT list ruleset -a | awk '/set\ c/{print $NF}')
+set_handle=$($NFT list ruleset -a | awk '/set c/{print $NF}')
 $NFT delete set test-ip handle $set_handle
 
 EXPECTED="table ip test-ip {
-- 
2.21.0


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

* [nft PATCH 4/4] tests/shell: Print unified diffs in dump errors
  2019-06-07 17:25 [nft PATCH 0/4] Some fixes and minor improvements in tests/ Phil Sutter
                   ` (2 preceding siblings ...)
  2019-06-07 17:25 ` [nft PATCH 3/4] tests/shell: Fix warning from awk call Phil Sutter
@ 2019-06-07 17:25 ` Phil Sutter
  2019-06-07 22:06 ` [nft PATCH 0/4] Some fixes and minor improvements in tests/ Pablo Neira Ayuso
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2019-06-07 17:25 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Non-unified format is useful only if the expected output is printed as
well, which is not the case.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 tests/shell/run-tests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/shell/run-tests.sh b/tests/shell/run-tests.sh
index 81ee0cdd62f4a..632cccee0af29 100755
--- a/tests/shell/run-tests.sh
+++ b/tests/shell/run-tests.sh
@@ -106,7 +106,7 @@ do
 		dumpfile="${dumppath}/$(basename ${testfile}).nft"
 		rc_spec=0
 		if [ "$rc_got" -eq 0 ] && [ -f ${dumpfile} ]; then
-			test_output=$(${DIFF} ${dumpfile} <($NFT list ruleset) 2>&1)
+			test_output=$(${DIFF} -u ${dumpfile} <($NFT list ruleset) 2>&1)
 			rc_spec=$?
 		fi
 
-- 
2.21.0


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

* Re: [nft PATCH 0/4] Some fixes and minor improvements in tests/
  2019-06-07 17:25 [nft PATCH 0/4] Some fixes and minor improvements in tests/ Phil Sutter
                   ` (3 preceding siblings ...)
  2019-06-07 17:25 ` [nft PATCH 4/4] tests/shell: Print unified diffs in dump errors Phil Sutter
@ 2019-06-07 22:06 ` Pablo Neira Ayuso
  4 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2019-06-07 22:06 UTC (permalink / raw)
  To: Phil Sutter; +Cc: netfilter-devel

i
On Fri, Jun 07, 2019 at 07:25:23PM +0200, Phil Sutter wrote:
> This series mostly adds missing bits and changes to JSON equivalents in
> tests/py to avoid errors when running the suite with -j flag.
> 
> In addition to that, patch 3 fixes awk syntax in 0028delete_handle_0
> test of tests/shell suite. Patch 4 improves the diff output upon dump
> errors in same suite by printing unified diffs instead of normal ones.

Applied, thanks Phil.

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

end of thread, other threads:[~2019-06-07 22:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-07 17:25 [nft PATCH 0/4] Some fixes and minor improvements in tests/ Phil Sutter
2019-06-07 17:25 ` [nft PATCH 1/4] tests/py: Fix JSON equivalents Phil Sutter
2019-06-07 17:25 ` [nft PATCH 2/4] tests/py: Add missing arp.t " Phil Sutter
2019-06-07 17:25 ` [nft PATCH 3/4] tests/shell: Fix warning from awk call Phil Sutter
2019-06-07 17:25 ` [nft PATCH 4/4] tests/shell: Print unified diffs in dump errors Phil Sutter
2019-06-07 22:06 ` [nft PATCH 0/4] Some fixes and minor improvements in tests/ Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.