ostree/buildutil/tap-test
Simon McVittie c733e21a84 Terminate individual tests after (10 * $TEST_TIMEOUT_FACTOR) minutes
While using the Automake parallel test harness, if a test hangs for
long enough for an external watchdog to kill the entire build process
(as happens in Debian sbuild after 150 minutes with no activity on
stdout/stderr), the logs will not be shown. If we make an individual
test time out sooner, logs are more likely to be shown.

We use SIGABRT so that the process(es) under test will dump core,
allowing the point at which ostree is blocking to be analyzed.
After 1 minute, if any have not died, we kill them again with SIGKILL.

To support slow platforms and slow debugging tools, if
TEST_TIMEOUT_FACTOR is set, multiply the 10 minute timeout by that.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #607
Approved by: cgwalters
2016-12-01 18:22:51 +00:00

39 lines
820 B
Bash
Executable File

#! /bin/bash
#
# Run a test in tap mode, ensuring we have a temporary directory. We
# always use /var/tmp becuase we might want to use user xattrs, which
# aren't available on tmpfs.
#
# The test binary is passed as $1
srcd=$(cd $(dirname $1) && pwd)
bn=$(basename $1)
tempdir=$(mktemp -d /var/tmp/tap-test.XXXXXX)
touch ${tempdir}/.testtmp
function cleanup () {
if test -f ${tempdir}/.testtmp; then
rm "${tempdir}" -rf
fi
}
function skip_cleanup() {
echo "Skipping cleanup of ${tempdir}"
}
cd ${tempdir}
timeout \
--kill-after=60 \
--signal=ABRT \
$(( 600 * ${TEST_TIMEOUT_FACTOR:-1} )) \
${srcd}/${bn} -k --tap
rc=$?
case "${TEST_SKIP_CLEANUP:-}" in
no|"") cleanup ;;
err)
if test $rc != 0; then
skip_cleanup
else
cleanup
fi ;;
*) skip_cleanup ;;
esac
exit $rc