#!/bin/bash
set -e

pkg=ncbi-seg

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
ncbi-seg prion.fa > test1.out
ncbi-seg prion.fa 45 3.4 3.75 > test2.out
ncbi-seg prion.fa -x > test3.out

# Output precomputed checksums to file
echo 40c4e4cdf4709b8ba57614d6997494f0  test1.out >> checksums
echo ec12511a16410778052761f4af9ae06b  test2.out >> checksums
echo 5d984bb25ff54f7a04c519fb878d68c1  test3.out >> checksums

# Check
md5sum --check checksums
echo -e "\e[92m\e[1mPassed\e[0m"
echo

