From 76a2663e434b31c85a5fa4c48808d66836a5ee8d Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Mon, 31 Oct 2022 10:13:47 +0100 Subject: [PATCH] test/common: use vhost's at_app_exit() during cleanup This function can be used to kill all lingering vhost and qemu processes that might have been left behind by vfio-user|vhost tests. Signed-off-by: Michal Berger Change-Id: I17121f416e26732d53b5dfec0f010e5db8bd369f Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15186 Reviewed-by: Krzysztof Karas Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Konrad Sztyber --- test/common/autotest_common.sh | 7 +++++++ test/vhost/common.sh | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index f82408c7d..515531f37 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -1332,12 +1332,19 @@ function autotest_cleanup() { local autotest_es=$? xtrace_disable + # Slurp at_app_exit() so we can kill all lingering vhost and qemu processes + # in one swing. We do this in a subshell as vhost/common.sh is too eager to + # do some extra work which we don't care about in this context. + # shellcheck source=/dev/null + vhost_reap() (source "$rootdir/test/vhost/common.sh" || return 0 && at_app_exit) + # catch any stray core files and kill all remaining SPDK processes. Update # autotest_es in case autotest reported success but cores and/or processes # were left behind regardless. process_core || autotest_es=1 reap_spdk_processes || autotest_es=1 + vhost_reap || autotest_es=1 $rootdir/scripts/setup.sh reset $rootdir/scripts/setup.sh cleanup diff --git a/test/vhost/common.sh b/test/vhost/common.sh index ff2403cbf..720fb91e1 100644 --- a/test/vhost/common.sh +++ b/test/vhost/common.sh @@ -21,7 +21,7 @@ WORKDIR=$(readlink -f "$(dirname "$0")") if ! hash $QEMU_IMG_BIN $QEMU_BIN; then echo 'ERROR: QEMU is not installed on this system. Unable to run vhost tests.' >&2 - exit 1 + return 1 fi mkdir -p $VHOST_DIR