Skip to contentSkip to conversation

Some fixes and minor improvements in tests/

PATCH Applied Phil Sutter 2 participants 6 messages Jun 7, 2019 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

cover Some fixes and minor improvements in tests/

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(-)
Signature · 1 line
2.21.0
author reviewer
#1 lore raw

PATCH 1/4 tests/py: Fix JSON equivalents

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

Fixes 27f6a4c68b4fd ("tests: replace single element sets")
---
 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(-)
tests/py/any/ct.t.json +25 -10
index 45e48f224957f..7c16f9df2195a 100644
@@ -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
+                        }
                     ]
                 ]
             }
tests/py/any/ct.t.json.output +19 -2
index 49d51771de9c1..aced3817cf49a 100644
@@ -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": [
tests/py/any/meta.t.json +42 -68

284 lines not on this page · raw message

Signature · 1 line
2.21.0
author reviewer
#2 lore raw

PATCH 2/4 tests/py: Add missing arp.t JSON equivalents

In reply to Phil Sutter
Fixes 4b0f2a712b579 ("src: support for arp sender and target ethernet and IPv4 addresses")
---
 tests/py/arp/arp.t.json        | 64 ++++++++++++++++++++++++++++++++++
 tests/py/arp/arp.t.json.output | 14 ++++----
 2 files changed, 70 insertions(+), 8 deletions(-)
tests/py/arp/arp.t.json +64 -0
index 4b0439e6edd58..0ea62645bbf6a 100644
@@ -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
 [
     {
tests/py/arp/arp.t.json.output +6 -8
index 4053d94763de5..b8507bffc8cc4 100644
@@ -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"
         }
     }
 ]
Signature · 1 line
2.21.0
author reviewer
#3 lore raw

PATCH 3/4 tests/shell: Fix warning from awk call

In reply to Phil Sutter

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")
---
 tests/shell/testcases/sets/0028delete_handle_0 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/shell/testcases/sets/0028delete_handle_0 +1 -1
index 626d51bc2cbb2..4e8b3228f6052 100755
@@ -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 {
Signature · 1 line
2.21.0
author reviewer
#4 lore raw

PATCH 4/4 tests/shell: Print unified diffs in dump errors

In reply to Phil Sutter

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

---
 tests/shell/run-tests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/shell/run-tests.sh +1 -1
index 81ee0cdd62f4a..632cccee0af29 100755
@@ -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
 
Signature · 1 line
2.21.0
maintainer Applied
#5 lore raw
In reply to Phil Sutter

i

Quoted 6 lines · Phil Sutter

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.