set -e

pkg=openslide-tools

if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
  AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
fi

mkdir -p ${AUTOPKGTEST_TMP}/data
cp debian-tests-data/* -a "${AUTOPKGTEST_TMP}/"

cd "${AUTOPKGTEST_TMP}"

echo "80617723e7f5f25e6b07762279c27e17  properties" >> checksums
echo "76dfe28f4cad05a9b9d2c4f1404bc143  output-openslide.png" >> checksums

echo -e "\e[93m\e[1mRunning Tests\e[0m"

echo "Test 1"
openslide-show-properties CMU-1-Small-Region.tiff > properties

echo "Test 2"
openslide-write-png CMU-1-Small-Region.tiff 256 256 0 100 100 output-openslide.png

echo "Test 3"
openslide-quickhash1sum CMU-1-Small-Region.tiff

md5sum --check checksums
echo -e "\e[92m\e[1mPASS\e[0m"


