#!/bin/bash
set -e

pkg=cppnumericalsolvers
CUR_DIR=`pwd`

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

cd "${AUTOPKGTEST_TMP}"
cp ${CUR_DIR}/examples/* .

samtools view -S -b toy.sam > toy.bam

echo "Test 1 -- calDepth"
gcc calDepth.c -o calDepth -I/usr/include/samtools -lbam -lm -lz -lpthread
./calDepth toy.bam
echo "=============== PASS ================"

echo "Test 2 -- chk_indel"
gcc chk_indel.c -o chk_indel -I/usr/include/samtools -lbam -lm -lz -lpthread
./chk_indel toy.bam
echo "=============== PASS ================"


echo "Test 3 -- bam2bed"
gcc bam2bed.c -o bam2bed -I/usr/include/samtools -lbam -lm -lz -lpthread
./bam2bed toy.bam
echo "=============== PASS ================"

rm -f toy.bam
