]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Cleanup remotebackend testrunner script
authorFred Morcos <fred.morcos@open-xchange.com>
Thu, 7 Mar 2024 13:39:01 +0000 (14:39 +0100)
committerFred Morcos <fred.morcos@open-xchange.com>
Mon, 18 Mar 2024 10:40:18 +0000 (11:40 +0100)
modules/remotebackend/testrunner.sh

index a33fc470cc21e236c44a2c4651f65880500ec6a8..947b71a8e1c1906b96b43674df4332c4600d5ade 100755 (executable)
@@ -24,19 +24,20 @@ socat=$(which socat)
 function start_web() {
   local service_logfile="${mode%\.test}_server.log"
 
-  ./unittest_${1}.rb >> ${service_logfile} 2>&1 &
+  ./unittest_"${1}".rb >> "${service_logfile}" 2>&1 &
   webrick_pid=$!
 
   local timeout=0
   while [ ${timeout} -lt 20 ]; do
-    local res=$(curl http://localhost:62434/ping 2>/dev/null)
-    if [ "x$res" == "xpong" ]; then
+    local res
+    res=$(curl http://localhost:62434/ping 2>/dev/null)
+    if [ "$res" == "pong" ]; then
       # server is up and running
       return 0
     fi
 
     sleep 1
-    let timeout=timeout+1
+    (( timeout=timeout+1 ))
   done
 
   if kill -0 ${webrick_pid} 2>/dev/null; then
@@ -73,7 +74,7 @@ function stop_web() {
     fi
 
     sleep 1
-    let timeout=timeout+1
+    (( timeout=timeout+1 ))
   done
 
   if kill -0 ${webrick_pid} 2>/dev/null; then
@@ -91,7 +92,7 @@ function start_zeromq() {
 
   local service_logfile="${mode%\.test}_server.log"
 
-  ./unittest_zeromq.rb >> ${service_logfile} 2>&1 &
+  ./unittest_zeromq.rb >> "${service_logfile}" 2>&1 &
   zeromq_pid=$!
 
   local timeout=0
@@ -102,7 +103,7 @@ function start_zeromq() {
     fi
 
     sleep 1
-    let timeout=timeout+1
+    (( timeout=timeout+1 ))
   done
 
   if kill -0 ${zeromq_pid} 2>/dev/null; then
@@ -138,7 +139,7 @@ function stop_zeromq() {
     fi
 
     sleep 1
-    let timeout=timeout+1
+    (( timeout=timeout+1 ))
   done
 
   if kill -0 ${zeromq_pid} 2>/dev/null; then
@@ -149,7 +150,7 @@ function stop_zeromq() {
 }
 
 function start_unix() {
-  if [ -z "$socat" -o ! -x "$socat" ]; then
+  if [ -z "$socat" ] || [ ! -x "$socat" ]; then
     echo "INFO: Skipping \"UNIX socket\" test because \"socat\" executable wasn't found!"
     exit 77
   fi
@@ -165,7 +166,7 @@ function start_unix() {
     fi
 
     sleep 1
-    let timeout=timeout+1
+    (( timeout=timeout+1 ))
   done
 
   if kill -0 ${socat_pid} 2>/dev/null; then
@@ -199,7 +200,7 @@ function stop_unix() {
     fi
 
     sleep 1
-    let timeout=timeout+1
+    (( timeout=timeout+1 ))
   done
 
   if kill -0 ${socat_pid} 2>/dev/null; then
@@ -211,13 +212,13 @@ function stop_unix() {
 
 function run_test() {
  if [ $new_api -eq 0 ]; then
-   ./$mode
+   ./"$mode"
  else
     $orig
  fi
 }
 
-mode=`basename "$mode"`
+mode=$(basename "$mode")
 
 case "$mode" in
   remotebackend_pipe.test)