#!/bin/sh

# Smoke test to install mumble and mumble-server to insure that the binaries
# are built and installed, then get some simple text output

set -e

# Generic path environment variables setup
cd $AUTOPKGTEST_TMP
export HOME=$PWD/home
mkdir -p $HOME
export TMP=$PWD
export TMPDIR=$PWD

echo "Starting basic smoke test."

# Mumble test currently causes a QT error:
##   qt.qpa.xcb: could not connect to display
## This test is commented out until the required test dependencies are found
##
echo "Executing /usr/bin/mumble --version"
MUMBLE_VERSION=$(/usr/bin/xvfb-run -a /usr/bin/mumble --version | grep "Mumble version [0-9]\.[0-9]\.[0-9]")
if [ -n "$MUMBLE_VERSION" ] ; then
   echo "Found: $MUMBLE_VERSION"
else
   echo "Error: Mumble version found: $MUMBLE_VERSION" >&2
   exit 1
fi

echo "Executing /usr/bin/mumble-server --version"
SERVER_VERSION=$(/usr/bin/mumble-server --version | grep "Mumble server version [0-9]\.[0-9]\.[0-9]")
if [ -n "$SERVER_VERSION" ] ; then
   echo "Found: $SERVER_VERSION"
else
   echo "Error: mumble-server version found: $SERVER_VERSION" >&2
   exit 1
fi
# If script gets to this point, smoke tests pass
echo "Smoke test passed."
exit 0
