From d1f9da828afa0cb293faf1f4b872677c87ccbb5d Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Wed, 28 Feb 2018 09:42:12 -0700 Subject: [PATCH] autotest.sh: create cleanup function This function consolidates cleanup behaviors that the pool should follow in the event of a failure. Change-Id: I8623f065146292b29a38eb199dcbeac5787723e7 Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/401857 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- autotest.sh | 10 ++-------- test/common/autotest_common.sh | 13 +++++++++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/autotest.sh b/autotest.sh index 613b834fa..f3de76e49 100755 --- a/autotest.sh +++ b/autotest.sh @@ -16,7 +16,7 @@ if [ $(uname -s) = Linux ]; then echo "core" > /proc/sys/kernel/core_pattern fi -trap "process_core; $rootdir/scripts/setup.sh reset; exit 1" SIGINT SIGTERM EXIT +trap "process_core; autotest_cleanup; exit 1" SIGINT SIGTERM EXIT timing_enter autotest @@ -205,13 +205,7 @@ if [ $SPDK_TEST_NVML -eq 1 ]; then fi timing_enter cleanup -if [ $SPDK_TEST_RBD -eq 1 ]; then - rbd_cleanup -fi -./scripts/setup.sh reset -if [ $SPDK_BUILD_IOAT_KMOD -eq 1 ]; then - ./scripts/build_kmod.sh clean -fi +autotest_cleanup timing_exit cleanup timing_exit autotest diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 37ce52b38..fdb1e4083 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -538,5 +538,18 @@ function get_bdev_size() echo "$bdev_size" } +function autotest_cleanup() +{ + if [ $SPDK_TEST_RBD -eq 1 ]; then + rbd_cleanup + fi + + $rootdir/scripts/setup.sh reset + + if [ $SPDK_BUILD_IOAT_KMOD -eq 1 ]; then + $rootdir/scripts/build_kmod.sh clean + fi +} + set -o errtrace trap "trap - ERR; print_backtrace >&2" ERR