Linux Netfilter development
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: kadlec@netfilter.org, Florian Westphal <fw@strlen.de>
Subject: [PATCH ipset 6/7] tests: make setlist_resize.sh more verbose on error
Date: Thu,  9 Jul 2026 22:03:57 +0200	[thread overview]
Message-ID: <20260709200358.15504-7-fw@strlen.de> (raw)
In-Reply-To: <20260709200358.15504-1-fw@strlen.de>

Instead of just existing, tell where we failed.
Use -x and take advantage of $IPSET_TMP to capture the
full output.

On success, remove the file.
cleanup handler will dump the content in case we failed somewhere.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 tests/setlist_resize.sh | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/tests/setlist_resize.sh b/tests/setlist_resize.sh
index db347ca06517..393048adac38 100755
--- a/tests/setlist_resize.sh
+++ b/tests/setlist_resize.sh
@@ -1,22 +1,41 @@
 #!/bin/sh
 
 set -e
-# set -x
-# exec > setlist.res
-# exec 2>&1
+
+cleanup() {
+	exec 1>&3
+	exec 2>&4
+	if [ -r "$IPSET_TMP/setlist.res" ]; then
+		cat "$IPSET_TMP/setlist.res"
+		rm -f "$IPSET_TMP/setlist.res"
+	fi
+}
+trap cleanup EXIT
+
+exec 3>&1
+exec 4>&2
+exec > "$IPSET_TMP/setlist.res" 2>&1
+
+set -x
 
 ipset=${IPSET_BIN:-../src/ipset}
 
 loop=8
 
+fail() {
+	echo "FAILED: $0 $@"
+	exit 1
+}
+
 n=0
 while [ $n -le 9 ]; do
     egrep '^(ip_set_|xt_set)' /proc/modules | while read x y; do
-    	rmmod $x >/dev/null 2>&1
+    	rmmod $x || :
     done
     if [ "`egrep '^(ip_set_|xt_set)' /proc/modules`" ]; then
     	sleep 1s
     else
+    	echo "Modules unloaded after $n attempts."
     	n=10
     fi
 done
@@ -35,7 +54,7 @@ for x in `seq 1 $loop`; do
     create 1 &
     create 2 &
     wait
-    test `$ipset l -n | wc -l` -eq 1024 || exit 1
+    test `$ipset l -n | wc -l` -eq 1024 || fail "expected 1024 sets"
     $ipset x
     # Wait for destroy to be finished and reference counts releases
     n=0
@@ -53,7 +72,10 @@ for x in `seq 1 $loop`; do
     	lsmod
     	echo $ref
     fi
-    test "$ref" -eq 0 || exit 1
+    test "$ref" -eq 0 || fail "ref was $ref"
     rmmod ip_set_hash_ip >/dev/null 2>&1
     rmmod ip_set >/dev/null 2>&1
 done
+
+rm -f "$IPSET_TMP/setlist.res"
+cleanup
-- 
2.54.0


  parent reply	other threads:[~2026-07-09 20:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 20:03 [PATCH ipset 0/7] test updates Florian Westphal
2026-07-09 20:03 ` [PATCH ipset 1/7] tests: make runtest.sh work with readonly-cwd Florian Westphal
2026-07-09 20:03 ` [PATCH ipset 2/7] tests: runtest.sh: run inside namespace Florian Westphal
2026-07-09 20:03 ` [PATCH ipset 3/7] tests: diff.sh: preserve file name Florian Westphal
2026-07-09 20:03 ` [PATCH ipset 4/7] tests: check_klog.sh: unclutter stderr Florian Westphal
2026-07-09 20:03 ` [PATCH ipset 5/7] tests: setlist_ns.sh: use local ipset binary and don't rely on userns Florian Westphal
2026-07-09 20:03 ` Florian Westphal [this message]
2026-07-09 20:03 ` [PATCH ipset 7/7] tests: runtest.sh: add sendip emulation via scapy Florian Westphal
2026-07-13 13:35 ` [PATCH ipset 0/7] test updates Jozsef Kadlecsik
2026-07-13 14:11   ` Pablo Neira Ayuso
2026-07-13 14:25     ` Jozsef Kadlecsik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260709200358.15504-7-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=kadlec@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox