#!/bin/sh
# Execute upstream's testsuite against the installed binaries.

set -e

if [ -z "$AUTOPKGTEST_TMP" ]
then
	echo "Temporary directory \$AUTOPKGTEST_TMP is not set. Aborting" >&2
	exit 1
fi

# Work from $AUTOPKGTEST_TMP as we need to treat the original source as read-only
cp -a test Makefile* ?_check cpuid* ctest* getarch* param.h "$AUTOPKGTEST_TMP"/
cd "$AUTOPKGTEST_TMP"/test

# Make tests use the installed binaries instead of using the build result path
sed -i -e 's,\.\./\$(LIBNAME),,g' Makefile
sed -i -e '3i CEXTRALIB += -lopenblas' Makefile

# Execute tests
make
