mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
tests: added session resumption test
Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
This commit is contained in:
@@ -215,4 +215,48 @@ cleanup() {
|
||||
return $ret
|
||||
}
|
||||
|
||||
# Check for a utility to list ports. Both ss and netstat will list
|
||||
# ports for normal users, and have similar semantics, so put the
|
||||
# command in the caller's PFCMD, or exit, indicating an unsupported
|
||||
# test. Prefer ss from iproute2 over the older netstat.
|
||||
have_port_finder() {
|
||||
for file in $(which ss 2> /dev/null) /*bin/ss /usr/*bin/ss /usr/local/*bin/ss;do
|
||||
if test -x "$file";then
|
||||
PFCMD="$file";return 0
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$PFCMD";then
|
||||
for file in $(which netstat 2> /dev/null) /bin/netstat /usr/bin/netstat /usr/local/bin/netstat;do
|
||||
if test -x "$file";then
|
||||
PFCMD="$file";return 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if test -z "$PFCMD";then
|
||||
echo "neither ss nor netstat found"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_if_port_in_use() {
|
||||
local PORT="$1"
|
||||
local PFCMD; have_port_finder
|
||||
$PFCMD -an|grep "[\:\.]$PORT" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Find a port number not currently in use.
|
||||
GETPORT='
|
||||
rc=0
|
||||
unset myrandom
|
||||
while test $rc = 0; do
|
||||
if test -n "$RANDOM"; then myrandom=$(($RANDOM + $RANDOM)); fi
|
||||
if test -z "$myrandom"; then myrandom=$(date +%N | sed s/^0*//); fi
|
||||
if test -z "$myrandom"; then myrandom=0; fi
|
||||
PORT="$(((($$<<15)|$myrandom) % 63001 + 2000))"
|
||||
check_if_port_in_use $PORT;rc=$?
|
||||
done
|
||||
'
|
||||
|
||||
trap "fail \"Failed to launch the server, aborting test... \"" 10
|
||||
|
||||
Reference in New Issue
Block a user