#!/bin/sh
# autopkgtest check: build and run with default test data
# Author: Tatiana Malygina <merlettaia@gmail.com>

set -e

pkg=profphd-utils

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

cd $ADTTMP

cp -a /usr/share/doc/${pkg}/examples/* .
find . -type f -name "*.gz" -exec gunzip \{\} \;
for lnk in `find . -type l -name "*.gz"` ; do
    ln -s `basename $(readlink $lnk) .gz` `echo $lnk | sed 's/\.gz$//'`
    rm $lnk
done

# NOTE: following commands were used because filter_hssp works in interactive 
# mode. Each `\n` means enter and corresponds to moving forward to next 
# command.
# Thus, following calls emulate interactive mode.
# As stated in man page, program writes output to STDOUT.
# It means that in normal situation no errors should be produced.

#metric_path="/usr/share/profphd/prof/mat/Maxhom_GCG.metric"
metric_path="Maxhom_GCG.metric"
echo "1ppt.hssp\n1ppt_filtered.hssp\n${metric_path}\n\n\n\n" | filter_hssp
[ -s 1ppt_filtered.hssp ]
