#!/bin/sh
# autopkgtest check based on upstream longcheck check ($ make longcheck)
# written for Debian by Jerome Benoit <calculus@rezozer.net> on behalf of the Debian Science Team
# copyright: 2015 Jerome Benoit <calculus@rezozer.net>
# distributed under the terms and conditions of GPL version 3 or later

# comments:
#  bugreport #804408: constant failure of the make-longcheck autopkgtest test:
#   1] valgrind check is temporarily neutralized;
#   2] a bugreport has been submit for allowing long autopkgtest tests, #804406 .
#   -- Jerome Benoit <calculus@rezozer.net>  Sun, 08 Nov 2015

set -ue

cat << EOF > $ADTTMP/Makefile

abs_top_pkgdir = $PWD

GMPECM = /usr/bin/ecm
##VALGRIND = /usr/bin/valgrind --quiet --error-exitcode=1


LISTOFMETHODS = pp1 pm1 ecm
LISTOFVARIANTS = + -no-ntt -modmuln -redc -mpzmod


default:

longcheck: \$(foreach _m,\$(LISTOFMETHODS),\$(foreach _v,\$(LISTOFVARIANTS),longcheck+\$(_m)+\$(_v)))
	@

longcheck+%:
	\$(abs_top_pkgdir)/test.\$(word 2,\$(subst +, ,\$@)) "\$(VALGRIND) \$(GMPECM) \$(word 3,\$(subst +, ,\$@))"

EOF

NJOBS=$(getconf _NPROCESSORS_ONLN)

LLAVG=$(( $NJOBS * 175 ))
LLAVG=$(( $LLAVG / 100 ))

make -C $ADTTMP -k -j $NJOBS -l $LLAVG longcheck

exit 0
