]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: Add socat availability feature test
authorPhil Sutter <phil@nwl.cc>
Thu, 27 Mar 2025 17:44:49 +0000 (18:44 +0100)
committerPhil Sutter <phil@nwl.cc>
Fri, 28 Mar 2025 14:08:50 +0000 (15:08 +0100)
Several tests did this manually and skipped if unavail, others just
implicitly depended on the tool.

Note that for the sake of simplicity, this will skip
packetpath/tcp_options test entirely when it did a partial run before.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: Florian Westphal <fw@strlen.de>
tests/shell/features/socat.sh [new file with mode: 0755]
tests/shell/testcases/packetpath/cgroupv2
tests/shell/testcases/packetpath/flowtables
tests/shell/testcases/packetpath/match_l4proto
tests/shell/testcases/packetpath/payload
tests/shell/testcases/packetpath/tcp_options
tests/shell/testcases/packetpath/tcp_reset

diff --git a/tests/shell/features/socat.sh b/tests/shell/features/socat.sh
new file mode 100755 (executable)
index 0000000..93cad6f
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# check whether socat is installed
+socat -h >/dev/null 2>&1
index 5c5bea0c903d3af5ab93357d5119abf465050265..65916e9db1e8c72eff6d55978eb59e9bdab25130 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_socat)
+
 doit="$1"
 rc=0
 
@@ -11,11 +13,6 @@ rc=0
 # should never match, it only exists so we
 # can create cgroupv2 match rules.
 
-if ! socat -h > /dev/null ; then
-       echo "socat tool is missing"
-       exit 77
-fi
-
 if [ ! -r /sys/fs/cgroup/cgroup.procs ] ;then
        echo "cgroup filesystem not available"
        exit 77
index 2c4a7e1f725adbccf0550fe770721ad5e3c492b0..d4e0a5bd1c07346ea3027f6de0d401b1593a83ba 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_socat)
 # NFT_TEST_SKIP(NFT_TEST_SKIP_slow)
 
 set -x
index 31fbe6c27d66ad29b01e662fb042f6c4647f7691..e61524e9cbdb80de8ba675fafbed3f77ac49c023 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/bash
 
 # NFT_TEST_REQUIRES(NFT_TEST_HAVE_netdev_egress)
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_socat)
 
 rnd=$(mktemp -u XXXXXXXX)
 ns1="nft1payload-$rnd"
index 83e0b7fc647acd2899f3c95dee4ac56c24a442cf..1e6b5a51969bba0a4418e63cd884331e550af1bd 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/bash
 
 # NFT_TEST_REQUIRES(NFT_TEST_HAVE_netdev_egress)
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_socat)
 
 rnd=$(mktemp -u XXXXXXXX)
 ns1="nft1payload-$rnd"
index 57e228c5990e07ecc6792fdf6299912ac04a71cb..88c095ff66dec5db74bde83c79c1cc8f250ea760 100755 (executable)
@@ -1,9 +1,7 @@
 #!/bin/bash
 
 # NFT_TEST_REQUIRES(NFT_TEST_HAVE_reset_tcp_options)
-
-have_socat="no"
-socat -h > /dev/null && have_socat="yes"
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_socat)
 
 ip link set lo up
 
@@ -33,11 +31,6 @@ if [ $? -ne 0 ]; then
        exit 1
 fi
 
-if [ $have_socat != "yes" ]; then
-       echo "Ran partial test, socat not available (skipped)"
-       exit 77
-fi
-
 # This will fail (drop in output -> connect fails with eperm)
 socat -u STDIN TCP:127.0.0.1:22345,connect-timeout=1 < /dev/null > /dev/null
 
index 3dfcdde40c77a156b3083e1b27617cb21016e065..559260a377090e560cd45568a484076b96001c73 100755 (executable)
@@ -1,10 +1,10 @@
 #!/bin/bash
 
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_socat)
+
 # regression check for kernel commit
 # netfilter: nf_reject: init skb->dev for reset packet
 
-socat -h > /dev/null || exit 77
-
 ip link set lo up
 
 $NFT -f - <<EOF