#!/bin/bash
set -e

pkg=roguenarok

export LC_ALL=C.UTF-8
if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
  AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
  # Double quote below to expand the temporary directory variable now versus
  # later is on purpose.
  # shellcheck disable=SC2064
  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
fi

cp -a /usr/share/doc/${pkg}/examples/* "${AUTOPKGTEST_TMP}"

cd "${AUTOPKGTEST_TMP}"

gunzip -r *

# Run tests
roguenarok-single -i 150.bs  -n id1
roguenarok-single -i 150.bs -t 150.tre -n id2

# Create file from precumputed checksums
echo f0547a4e189064404d64cf172c661987  RogueNaRok_droppedRogues.id1 >> checksums
echo b8cebb08d429143dfc1dd5dff6b33abb  RogueNaRok_droppedRogues.id2 >> checksums

md5sum --check checksums
