tests - Support running as `root` (for CI)
[tpg/opendispense2.git] / tests / _common.sh
index cb31ac7..04d1657 100644 (file)
@@ -1,6 +1,7 @@
 #
 # NOTE: Not a script, to be included by scripts
 #
+USER=$(id -un)
 BASEDIR=rundir/${TESTNAME}/
 PORT=22222
 
@@ -34,19 +35,24 @@ FAIL() {
 }
 TRY_COMMAND() {
        cmd="$*"
+       echo ">> $cmd"
        if ! $cmd ; then
                FAIL "Command \`$cmd\` failed"
        fi
 }
 
-DISPENSE="../dispense -H localhost -P ${PORT}"
+DISPENSE="../dispense -f /dev/null -H localhost -P ${PORT}"
 
 LD_LIBRARY_PATH=.. ../dispsrv -f ${BASEDIR}cfg_server.conf --dont-daemonise > ${BASEDIR}server.log 2>&1 &
 server_pid=$!
 
 cleanup() {
-       LOG "Killing ${server_pid}"
-       kill ${server_pid}; true
+       if pidof dispsrv | grep ${server_pid} > /dev/null; then
+               LOG "Killing ${server_pid}"
+               kill ${server_pid}; true
+       else
+               LOG "Server already terminated"
+       fi
 }
 trap cleanup EXIT
 
@@ -57,4 +63,5 @@ if ! (echo "" | nc localhost ${PORT}); then
        LOG "Server not responding on ${PORT}"
        LOG "Server log contents:"
        cat ${BASEDIR}server.log
+       exit 1
 fi

UCC git Repository :: git.ucc.asn.au