| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Make sure $AUTOPKGTEST_TMP is available |
| 4 |
if [ "${AUTOPKGTEST_TMP}"F = "F" ]; then |
| 5 |
echo "Error: expected environment variable AUTOPKGTEST_TMP is not set." |
| 6 |
exit 1 |
| 7 |
fi |
| 8 |
|
| 9 |
# Make sure $AUTOPKGTEST_ARTIFACTS is available |
| 10 |
if [ "${AUTOPKGTEST_ARTIFACTS}"F = "F" ]; then |
| 11 |
echo "Error: expected environment variable AUTOPKGTEST_ARTIFACTS is not set." |
| 12 |
exit 1 |
| 13 |
fi |
| 14 |
|
| 15 |
# Determine the test execution mode |
| 16 |
if [ "${1}"F = "F" ]; then |
| 17 |
MODE="autopkgtest" |
| 18 |
elif [ "${1}" = "-r" ]; then |
| 19 |
MODE="debian/rules" |
| 20 |
else |
| 21 |
echo "usage: $0 [-r]\n-r Run in debian/rules mode instead of autopkgtest mode" |
| 22 |
exit 2 |
| 23 |
fi |
| 24 |
|
| 25 |
# Determine locations of required tools |
| 26 |
SOURCE_TREE="${PWD}" |
| 27 |
if [ "${MODE}" = "debian/rules" ]; then |
| 28 |
# In debian/rules mode, use the library code from the source tree |
| 29 |
PYTHON="/usr/bin/python3" |
| 30 |
export PYTHONPATH="${SOURCE_TREE}/src" |
| 31 |
else |
| 32 |
# In autopkgtest mode, use the installed library code in the system path |
| 33 |
PYTHON="/usr/bin/python3" |
| 34 |
fi |
| 35 |
|
| 36 |
# Print a test summary |
| 37 |
echo "" |
| 38 |
echo "=========================================================================" |
| 39 |
echo "Running ${0} in mode: ${MODE}" |
| 40 |
echo "=========================================================================" |
| 41 |
echo "SOURCE_TREE..........: ${SOURCE_TREE}" |
| 42 |
echo "AUTOPKGTEST_TMP......: ${AUTOPKGTEST_TMP}" |
| 43 |
echo "AUTOPKGTEST_ARTIFACTS: ${AUTOPKGTEST_ARTIFACTS}" |
| 44 |
echo "PYTHON...............: ${PYTHON}" |
| 45 |
echo "PYTHONPATH...........: ${PYTHONPATH}" |
| 46 |
echo "=========================================================================" |
| 47 |
echo "" |
| 48 |
|
| 49 |
# Always run tests from within $AUTOPKGTEST_TMP |
| 50 |
cd ${AUTOPKGTEST_TMP} |
| 51 |
|
| 52 |
# Copy the test suite into the working directory |
| 53 |
cp -r ${SOURCE_TREE}/tests . |
| 54 |
|
| 55 |
# Run the test suite |
| 56 |
${PYTHON} -m unittest discover -s tests -t tests |
| 57 |
if [ $? != 0 ]; then |
| 58 |
exit 1 |
| 59 |
fi |
| 60 |
|
| 61 |
# Close the test |
| 62 |
echo "" |
| 63 |
|