#!/bin/sh

set -e

# apparmor will interfere with tests.  On armhf, this command might
# fail but the tests will still pass.  See LP #1991141 for more
# details.
aa-disable slapd || true

if [ -z "${AUTOPKGTEST_NORMAL_USER}" ]; then
    adduser --disabled-password --gecos "" test
    AUTOPKGTEST_NORMAL_USER="test"
fi

chown "${AUTOPKGTEST_NORMAL_USER}" -R "${AUTOPKGTEST_TMP}"
runuser -u "${AUTOPKGTEST_NORMAL_USER}" -- cp -r tests ${AUTOPKGTEST_TMP}
cd ${AUTOPKGTEST_TMP}
for p in $(py3versions -s); do
    runuser -u "${AUTOPKGTEST_NORMAL_USER}" -- $p -m django test --settings tests.settings
done
