X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=tests%2F_common.sh;h=04d165702941ed14a410db26ca76ea1a04ab7276;hb=4848b3853ef5517c4da4f2bcd6c8b959dae33411;hp=0019b997ec2fd069683e0ddffd8bc7c32c6b0013;hpb=209aad64803d474788b24ee4794013f5d400122b;p=tpg%2Fopendispense2.git diff --git a/tests/_common.sh b/tests/_common.sh index 0019b99..04d1657 100644 --- a/tests/_common.sh +++ b/tests/_common.sh @@ -1,10 +1,14 @@ - +# +# NOTE: Not a script, to be included by scripts +# +USER=$(id -un) BASEDIR=rundir/${TESTNAME}/ PORT=22222 mkdir -p ${BASEDIR} rm -f ${BASEDIR}cokebank.db +# Template configuration (disables door and the coke machine) cat << EOF > ${BASEDIR}cfg_server.conf # AUTOGENERATED Test ${TESTNAME} server_port ${PORT} @@ -31,22 +35,33 @@ 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} + 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 LOG "Server running on PID ${server_pid}" sleep 1 -echo "" | nc localhost ${PORT} +# - Make sure that the server started +if ! (echo "" | nc localhost ${PORT}); then + LOG "Server not responding on ${PORT}" + LOG "Server log contents:" + cat ${BASEDIR}server.log + exit 1 +fi