Skip to content

Commit

Permalink
Add a simple smoketest to check whether a commit completely breaks LM…
Browse files Browse the repository at this point in the history
…S startup. More sophisticated tests to follow.
  • Loading branch information
mherger committed Sep 7, 2020
1 parent 5f29ff3 commit 6f349db
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/00_smoketest.yaml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions t/00_smoketest.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6f349db

Please sign in to comment.