#!/bin/bash
set -e

pkg=prime-phylo

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}"

treesize treefile > treesize_output 
tree2leafnames treefile > leaf_names
showtree treefile > show_tree

if [ $(dpkg-architecture -qDEB_BUILD_ARCH) = "amd64" ]
then
	echo "48a24b70a0b376535542b996af517398  treesize_output" >> checksums
	echo "13c9f6064385b0e429d9c42e8ce1ccfd  leaf_names" >> checksums
	echo "d517fa198ef97a8d42a3af5f493326c1  show_tree" >> checksums
    md5sum --check checksums
	echo "Expected output and generated output are same: PASS Test 1"
else
	[ -s "treesize_output" ] && [ -s "leaf_names" ] && [ -s "show_tree" ] || exit 1
	echo "PASS Test 1"
fi

primeDLRS -i 1 seqfile hostfile gse > DLRS_output
[ -s "DLRS_output" ] && echo "PASS Test 2"



