summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Rühsen <tim.ruehsen@gmx.de>2018-11-16 12:08:06 +0100
committerTim Rühsen <tim.ruehsen@gmx.de>2018-12-18 10:39:06 +0100
commit5893fde5b5533e3ee644a347493d92fb7e17d855 (patch)
tree0bf32d365199079610102e93715b146944015dfe
parent0b03bec946b28cb60d71e647d1597322689e8bb0 (diff)
downloadgnutls-5893fde5b5533e3ee644a347493d92fb7e17d855.tar.gz
tests/scripts/common.sh: Make random port value work on busybox
On busybox 'date +%N' returns an empty value. On 'dash' (Debian shell) $RANDOM doesn't work. This commit works first tries $RANDOM and then falls back to 'date +%N'. Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
-rw-r--r--tests/scripts/common.sh9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/scripts/common.sh b/tests/scripts/common.sh
index 1567d8e614..fcad3d7af0 100644
--- a/tests/scripts/common.sh
+++ b/tests/scripts/common.sh
@@ -59,7 +59,10 @@ check_if_port_listening() {
}
# Find a port number not currently in use.
-GETPORT='rc=0; myrandom=$(date +%N | sed s/^0*//)
+GETPORT='rc=0; unset myrandom
+ 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
while test $rc = 0;do
PORT="$(((($$<<15)|$myrandom) % 63001 + 2000))"
check_if_port_in_use $PORT;rc=$?
@@ -117,7 +120,7 @@ wait_for_port()
{
local ret
local PORT="$1"
- sleep 4
+ sleep 1
for i in 1 2 3 4 5 6;do
check_if_port_listening ${PORT}
@@ -144,7 +147,7 @@ wait_for_free_port()
if test $ret != 0;then
break
else
- sleep 20
+ sleep 2
fi
done
return $ret