#!/bin/sh
# start a server, connect the pygame client to it, and check that the
# client gets the game and keeps playing it
set -e
cd "$AUTOPKGTEST_TMP"
export HOME="$AUTOPKGTEST_TMP" SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy
timeout 25 bubbros-server /usr/share/games/bubbros/bubbob/levels/Levels.bin \
    --port LISTEN=29801 --port HTTP=29802 > server.log 2>&1 &
sleep 3
status=0
timeout 15 bubbros-client 127.0.0.1:29801 > client.log 2>&1 || status=$?
wait || true
cat server.log client.log
# the client was still playing when timeout stopped it
test "$status" = 124
grep -q "^connected to 'Bub & Bob Levels'" client.log
grep -q "images per second" client.log
