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

# this test needs package name as a parameter for execution 

set -e

pkg="$1"

if [ -z "$pkg" ] ; then
  echo "Provide correct package name as a parameter";
  exit 1;
fi

command=$(echo $pkg | sed -e "s/-/_/g") 
#this returns corresponding executable name

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

cd $AUTOPKGTEST_TMP

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

$command switch 385 55 10 46 100 PROFin.dat PROFacc_tst.jct none
echo "Test finished successfully"
