* [PATCH ipset] tests: runtest.sh: do kmemleak scan if available
@ 2026-08-13 23:04 Florian Westphal
0 siblings, 0 replies; only message in thread
From: Florian Westphal @ 2026-08-13 23:04 UTC (permalink / raw)
To: netfilter-devel; +Cc: Jozsef Kadlecsik, Florian Westphal
If we find that the kernel has kmemleak support, run a scan
at the end of the test and report an error in case there are new
reports. It won't report any leaks that existed before in order
to not indicate errors in case of earlier memory leaks triggered
by other, non-ipset related tests.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
tests/runtest.sh | 52 ++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 44 insertions(+), 8 deletions(-)
diff --git a/tests/runtest.sh b/tests/runtest.sh
index 1b00b7bc55d5..3571c310095e 100755
--- a/tests/runtest.sh
+++ b/tests/runtest.sh
@@ -36,6 +36,45 @@ cleanup() {
ip link del eth0
}
trap cleanup EXIT
+
+kmemleak_found=0
+test -f /sys/kernel/debug/kmemleak && kmemleak_found=$(grep "unreferenced object" /sys/kernel/debug/kmemleak | wc -l)
+
+check_kmemleak_force()
+{
+ echo scan > /sys/kernel/debug/kmemleak
+
+ local lines=$(grep "unreferenced object" /sys/kernel/debug/kmemleak | wc -l)
+ if [ $lines -ne $kmemleak_found ];then
+ echo "FAILED"
+ cat /sys/kernel/debug/kmemleak
+ failcount=$((failcount+1))
+ else
+ echo "OK"
+ fi
+}
+
+check_failcount() {
+ local ret=0
+
+ if [ -f /sys/kernel/debug/kmemleak ]; then
+ echo -n "Waiting 30 seconds, then doing kmemleak scan "
+ sleep 30
+ check_kmemleak_force
+ fi
+
+ rmmod ip_set >/dev/null 2>&1
+
+ if [ "$failcount" -eq 0 ]; then
+ echo "All tests are passed"
+ else
+ echo "$failcount tests have failed"
+ ret=1
+ fi
+
+ exit $ret
+}
+
tmpdir=$(mktemp -t -d ip-set-XXXXXXXX)
ip link set lo up
@@ -111,7 +150,9 @@ else
fi
# Make sure the scripts are executable
-chmod a+x check_* *.sh
+for f in check_* *.sh; do
+ test -x "$f" || chmod a+x "$f"
+done
failcount=0
for types in $tests; do
@@ -181,10 +222,5 @@ for x in $tests; do
;;
esac
done
-rmmod ip_set >/dev/null 2>&1
-if [ "$failcount" -eq 0 ]; then
- echo "All tests are passed"
-else
- echo "$failcount tests have failed"
- exit 1
-fi
+
+check_failcount
--
2.54.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-13 23:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 23:04 [PATCH ipset] tests: runtest.sh: do kmemleak scan if available Florian Westphal
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.