In order to ensure tests properly clean themselves up, even if
they are subject to interruption, add the ability to call a test
specified function at cleanup time.
Any test can call _register_test_cleanup with the first argument
as a function to call after the test ends or is interrupted
(similar to using 'trap <func> EXIT').
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
) | column -t -s $'\t'
}
+_register_test_cleanup() {
+ TEST_CLEANUP=$1
+}
+
_cleanup() {
+ if [[ -v TEST_CLEANUP ]]; then
+ ${TEST_CLEANUP}
+ fi
+
if [[ "${TMPDIR:-}" ]]; then
rm -rf "$TMPDIR"
unset TMPDIR
fi
$LOGGER_PROG "run blktests $TEST_NAME"
+ unset TEST_CLEANUP
trap _cleanup EXIT
if ! TMPDIR="$(mktemp --tmpdir -p "$OUTPUT" -d "tmpdir.${TEST_NAME//\//.}.XXX")"; then
return