Remove bash specific code
Use case pattern matching instead of multiline split, given there is
only the well formatted PIDs to match on this should be safe.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh
index 2aad39c..d49f3f5 100755
--- a/tests/ssl-opt.sh
+++ b/tests/ssl-opt.sh
@@ -559,6 +559,8 @@
# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
if type lsof >/dev/null 2>/dev/null; then
wait_app_start() {
+ newline='
+'
START_TIME=$(date +%s)
if [ "$DTLS" -eq 1 ]; then
proto=UDP
@@ -567,20 +569,14 @@
fi
# Make a tight loop, server normally takes less than 1s to start.
while true; do
- SERVER_PIDS=$(lsof -a -n -b -i "$proto:$1" -F p | cut -c2-)
- SERVER_FOUND=false
- # When proxies are used, more than one PID can be listening on
- # the same port. Each PID will be on its own line.
- while read -r PID; do
- if [[ $PID == $2 ]]; then
- SERVER_FOUND=true
- break
- fi
- done <<< "$SERVER_PIDS"
-
- if ($SERVER_FOUND == true); then
- break
- fi
+ SERVER_PIDS=$(lsof -a -n -b -i "$proto:$1" -F p)
+ # When we use a proxy, it will be listening on the same port we
+ # are checking for as well as the server and lsof will list both.
+ # If multiple PIDs are returned, each one will be on a separate
+ # line, each prepended with 'p'.
+ case ${newline}${SERVER_PIDS}${newline} in
+ *${newline}p${2}${newline}*) break;;
+ esac
if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
echo "$3 START TIMEOUT"
echo "$3 START TIMEOUT" >> $4