#!/bin/bash
set -e

# limit thread parallelisation to no more than 4 cpus
# but respect any existing value of QUTIP_NUM_PROCESSES
ncpu=${QUTIP_NUM_PROCESSES}
if [ "x${ncpu}" = "x" ]; then
    ncpu=$(nproc)
    ncpu=$(( ncpu > 4 ? 4 : ncpu ))
fi
export QUTIP_NUM_PROCESSES=${ncpu}

DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH)

if [ "${DEB_HOST_ARCH}" = "amd64" ]; then
    cp -r qutip/tests "$AUTOPKGTEST_TMP"
    for py in $(py3versions -s 2>/dev/null); do
	cd "$AUTOPKGTEST_TMP"
	echo "Testing with $py:"
	$py -mpytest tests -k "not test_simdiag"
    done
else
    echo "qutip tests are performed for amd64 only"
fi
