#!/bin/bash
set -e

pkg=skewer

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

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

cd "${AUTOPKGTEST_TMP}"

skewer -x TCGTATGCCGTCTTCTGCTTGT -l 16 -L 30 -d 0 -o output data.fastq.gz
skewer -Q 9 -t 2 -x adapters.fa data.fastq.gz -o trimmed
if [ $(dpkg-architecture -qDEB_BUILD_ARCH) = "amd64" ]
then
	echo "52d871b7c71f7e931ba8b1cee489e210  trimmed-trimmed.fastq" >> checksums
    	md5sum --check checksums
	echo "Expected output and generated output are same!"
else
	[ -s "trimmed-trimmed.fastq" ] || exit 1
fi

# Check that logging happens
for f in *.log
do
	echo "$f"
	[ -s $f ] || exit 1
done

echo "PASS"
