Hello,
GNU/Linux distributions are deprecating some legacy IP tools [1], moving
them to a -deprecated package: in this case netstat. Please review the
attached patch adding compatible support for it's functional successor
ss(8).
[[[
Support modern network utilities for finding free ports for tests
* subversion/tests/cmdline/davautocheck.sh:
Check for presence of ss, netstat and fail if neither is found.
Prefer ss to find a free port, fall back to netstat.
* subversion/tests/cmdline/svnserveautocheck.sh:
Same, and augment $PATH to include /usr/{,local/}sbin.
]]]
[1] https://build.opensuse.org/request/show/308848
With kind regards,
Andreas Stieger
Index: subversion/tests/cmdline/davautocheck.sh
===================================================================
--- subversion/tests/cmdline/davautocheck.sh (revision 1684476)
+++ subversion/tests/cmdline/davautocheck.sh (working copy)
@@ -318,12 +318,18 @@ fi
# Stop any previous instances, os we can re-use the port.
if [ -x $STOPSCRIPT ]; then $STOPSCRIPT ; sleep 1; fi
+ss > /dev/null 2>&1 || netstat > /dev/null 2>&1 || fail "unable to find ss or netstat required to find a free port"
+
HTTPD_PORT=3691
-while netstat -an | grep $HTTPD_PORT | grep 'LISTEN' >/dev/null; do
+while \
+ (ss -ltn sport = :$HTTP_PORT 2>&1 | grep :$HTTP_PORT > /dev/null ) \
+ || \
+ (netstat -an 2>&1 | grep $HTTP_PORT | grep 'LISTEN' > /dev/null ) \
+ do
HTTPD_PORT=$(( HTTPD_PORT + 1 ))
if [ $HTTPD_PORT -eq 65536 ]; then
# Most likely the loop condition is true regardless of $HTTPD_PORT
- fail "netstat claims you have no free ports for httpd to listen on."
+ fail "ss/netstat claim you have no free ports for httpd to listen on."
fi
done
HTTPD_ROOT="$ABS_BUILDDIR/subversion/tests/cmdline/httpd-$(date '+%Y%m%d-%H%M%S')"
Index: subversion/tests/cmdline/svnserveautocheck.sh
===================================================================
--- subversion/tests/cmdline/svnserveautocheck.sh (revision 1684476)
+++ subversion/tests/cmdline/svnserveautocheck.sh (working copy)
@@ -95,9 +95,16 @@ random_port() {
if type time > /dev/null ; then TIME_CMD() { time "$@"; } ; else TIME_CMD() { "$@"; } ; fi
MAKE=${MAKE:-make}
+PATH="$PATH:/usr/sbin/:/usr/local/sbin/"
+ss > /dev/null 2>&1 || netstat > /dev/null 2>&1 || fail "unable to find ss or netstat required to find a free port"
+
SVNSERVE_PORT=$(random_port)
-while netstat -an | grep $SVNSERVE_PORT | grep 'LISTEN'; do
+while \
+ (ss -ltn sport = :$SVNSERVE_PORT 2>&1 | grep :$SVNSERVE_PORT > /dev/null ) \
+ || \
+ (netstat -an 2>&1 | grep $SVNSERVE_PORT | grep 'LISTEN' > /dev/null ) \
+ do
SVNSERVE_PORT=$(random_port)
done