#!/bin/sh
set -e

# Name of this script
script=`basename "$0"`

# Handle case of manually running this script
if [ "$AUTOPKGTEST_TMP" = "" ]; then
    AUTOPKGTEST_TMP=`mktemp -d --tmpdir "$script"-XXX`;
    echo "AUTOPKGTEST_TMP is $ADTTMP";
fi
if [ "$ADT_ARTIFACTS" = "" ] ; then
    ADT_ARTIFACTS=${AUTOPKGTEST_TMP}/artifacts
fi
mkdir -p "${AUTOPKGTEST_TMP}"
mkdir -p "${ADT_ARTIFACTS}"

# Save current directory (must be top of source tree)
SRC_ROOT=`pwd`

# Get list of non-Lorene examples
EXAMPLES_DIR=${SRC_ROOT}/doc/examples
BASE_NAMES=`basename -s.xml ${EXAMPLES_DIR}/*.xml | sed 's/example-[^ ]*-rotstar3_1//'`

# Build Gyoto command line
GYOTO="/usr/bin/gyoto --nprocesses=0 --nthreads=4 --resolution=32 --plugins=stdplug"
# Run each example in this environment
for base in ${BASE_NAMES} ; do
    ${GYOTO} \
		  ${EXAMPLES_DIR}/${base}.xml \
		  \!${ADT_ARTIFACTS}/${base}.fits ;
done

exit 0
