2 # NOTE: Not a script, to be included by scripts
5 BASEDIR=rundir/${TESTNAME}/
9 rm -f ${BASEDIR}cokebank.db
11 # Template configuration (disables door and the coke machine)
12 cat << EOF > ${BASEDIR}cfg_server.conf
13 # AUTOGENERATED Test ${TESTNAME}
15 cokebank_database ${BASEDIR}cokebank.db
16 items_file ${BASEDIR}cfg_items.conf
17 door_serial_port /dev/null
19 coke_modbus_address 0.0.0.0
27 echo "# AUTOGENERATED Test ${TESTNAME}" > ${BASEDIR}cfg_items.conf
30 echo "TEST ${TESTNAME}: "$*
33 echo "TEST ${TESTNAME} FAIL: "$*
40 FAIL "Command \`$cmd\` failed"
44 DISPENSE="../dispense -H localhost -P ${PORT}"
46 LD_LIBRARY_PATH=.. ../dispsrv -f ${BASEDIR}cfg_server.conf --dont-daemonise > ${BASEDIR}server.log 2>&1 &
50 if pidof dispsrv | grep ${server_pid}; then
51 LOG "Killing ${server_pid}"
52 kill ${server_pid}; true
54 LOG "Server already terminated"
59 LOG "Server running on PID ${server_pid}"
61 # - Make sure that the server started
62 if ! (echo "" | nc localhost ${PORT}); then
63 LOG "Server not responding on ${PORT}"
64 LOG "Server log contents:"
65 cat ${BASEDIR}server.log