#!/bin/bash
set -e

pkg="loki"

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 *
set -x
cp test_seedfile seedfile
echo "========= prep control_jv ========"
prep control_jv
echo "========= prep control_jv1 ========"
prep control_jv1
echo "========= prep control_jv_cens ========"
prep control_jv_cens
echo "========= prep control_jv_lm ========"
prep control_jv_lm

echo "Check that loki.* files were created:"
ls .

echo "========= loki param_jv ========"
loki param_jv
echo "========= loki param_jv2 ========"
loki param_jv2
echo "========= loki param_jv_lm ========"
loki param_jv_lm
echo "========= loki param_jv_mg ========"
loki param_jv_mg
