#!/bin/bash

# A thin wrapper that sets up an environment, runs a test, and exits with an
# error if the test does not write a file indicating success.
# Copyright Canonical, 2013.   Author: Chad MILLER <chad.miller@canonical.com>

set -o nounset

SRCDIR=$(pwd)
WORKDIR=$(mktemp -d)
trap "rm -rf ${WORKDIR}" EXIT INT QUIT ABRT PIPE TERM

ulimit -c unlimited

script=$(readlink -m -- ${0}-actual)

cd ${WORKDIR}
LC_ALL=C HOME=${WORKDIR} xvfb-run ${script} ${SRCDIR} 2>&1

if test -f ${WORKDIR}/result-success; then
	echo PASS
	exit 0
else
	echo FAIL
	exit 0  # FIXME Debug conditions to discover timeout error in 
fi
