diff --git a/.github/workflows/00_smoketest.yaml b/.github/workflows/00_smoketest.yaml new file mode 100644 index 00000000000..8951eb53170 --- /dev/null +++ b/.github/workflows/00_smoketest.yaml @@ -0,0 +1,12 @@ +name: 'Smoketest for Logitech Media Server' +on: [push, pull_request] +jobs: + linux: + name: Run LMS to see whether it crashes immediately... + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v1 + + - name: Run test + run: bash t/00_smoketest.sh diff --git a/t/00_smoketest.sh b/t/00_smoketest.sh new file mode 100755 index 00000000000..d95615f53cc --- /dev/null +++ b/t/00_smoketest.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +SERVER_LOG=$HOME/server.log +TIMEOUT=30 + +function wait_port() { + local wait_seconds="${1:-10}"; shift # 10 seconds as default timeout + + until test $((wait_seconds--)) -eq 0 ; do + if nc -z localhost 9000 ; then + break + else + sleep 1 + fi + done + + ((++wait_seconds)) +} + +function finish { + kill -9 $NODE_PID 2> /dev/null + cat $SERVER_LOG + rm $SERVER_LOG +} +trap finish EXIT + +./slimserver.pl --logfile=$SERVER_LOG & +NODE_PID=$! + +wait_port $TIMEOUT || { + echo "Timing out trying to connect to LMS" + exit 1; +} + +STATUS=$(curl -m1 -sX POST -d '{"id":0,"params":["",["serverstatus"]],"method":"slim.request"}' http://localhost:9000/jsonrpc.js) + +echo $STATUS | jq . + +RESULT=$(echo $STATUS | fgrep -q version) + +exit $RESULT \ No newline at end of file