#!/bin/sh

set -euf

cp -a tests "$AUTOPKGTEST_TMP"
cd "$AUTOPKGTEST_TMP"

DEB_HOST_ARCH=$(dpkg-architecture -qDEB_HOST_ARCH)
if [ "$DEB_HOST_ARCH" != "i386" ] && [ "$DEB_HOST_ARCH" != "armel" ] && [ "$DEB_HOST_ARCH" != "armhf" ]; then
	export MPI_OVERSUBSCRIBE="--oversubscribe"
fi
if [ "$DEB_HOST_ARCH" = "riscv64" ]; then
	# tests run slower on riscv64 compared to other arches
	export DEFAULT_TIMEOUT="60"
fi

for python in $(py3versions -s); do
	echo "== $python =="
	$python -m pytest -p pytester \
	    --cov=/usr/lib/python3/dist-packages/pytest_mpi \
	    --runpytest=subprocess \
	    tests/
done
