]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
tests: check_extensions: introduce and use IPSET_MACHINE_SLOW
authorFlorian Westphal <fw@strlen.de>
Thu, 23 Jul 2026 10:35:00 +0000 (12:35 +0200)
committerJozsef Kadlecsik <kadlec@netfilter.org>
Wed, 29 Jul 2026 15:04:12 +0000 (17:04 +0200)
Running ipset tests on my laptop with a debug kernel (i.e. kasan,
kmemleak and so on) fails the check_extensions subtests because the
observed timeout is below the lower threshold.  Add IPSET_MACHINE_SLOW,
similar to KSFT_MACHINE_SLOW used in the kernel kselftest framework.

If set, raise the slack value to 30s.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
tests/check_extensions

index 77e7c2cd8b90dab7f0f8b5d161a50c293d8e08a1..ce39366ad46d1917ced62848a3c89f02d2194fe0 100755 (executable)
@@ -1,11 +1,26 @@
 #!/bin/bash
 
 ipset=${IPSET_BIN:-../src/ipset}
+setname="$1"
+elem="$2"
+wanted_timeout="$3"
+wanted_packets="$4"
+wanted_bytes="$5"
 
-read ip t timeout p packets b bytes <<< $($ipset l $1 | grep ^$2)
-test -z "$timeout" -o -z "$packets" -o -z "$bytes" && exit 1
-test $timeout -gt $3 -o $timeout -lt $(($3 - 10)) && exit 1
-test $packets -ne $4 -o $bytes -ne $5 && exit 1
+allowed_slack=10
+[ "$IPSET_MACHINE_SLOW" = "yes" ] && allowed_slack=30
+
+die() {
+       echo "FAIL: $0: $@"
+       exit 1
+}
+
+timeout_lower=$((wanted_timeout - allowed_slack))
+
+read ip t timeout p packets b bytes <<< $($ipset l $setname | grep ^$elem)
+test -z "$timeout" -o -z "$packets" -o -z "$bytes" && die "at least of one timeout $timeout, packets $packets, bytes $bytes not set"
+test $timeout -gt $wanted_timeout -o $timeout -lt $timeout_lower && die "timeout $timeout gt $wanted_timeout or $timeout lt $timeout_lower"
+test $packets -ne $wanted_packets -o $bytes -ne $wanted_bytes && die "packets $packets ne $wanted_packets or $bytes ne $wanted_bytes"
 exit 0