Commit d546e5ba authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

test/vhost: Do proper cleanup in shared test suite



Otherwise, in case first fio fails (i.e. the one that is being put
into a background job), the error_exit() kills the vhost app,
leaving the second fio hanging for indefinite amount of time.

Instead, kill it immediately when the trap is raised.

Also, simply trap on EXIT, don't overwrite the ERR trap that's set
from autotest_common.sh.

Change-Id: Icfe851235ff78024b3f288c91e4a2e122502bd4b
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19892


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
parent fcc31eef
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -11,6 +11,12 @@ source $rootdir/test/vhost/common.sh
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
vhost_name="0"

cleanup() {
	[[ -n $run_fio_pid ]] && killprocess "$run_fio_pid"
	vhost_kill 0
	vhosttestfini
}

bdev_conf=$(
	cat <<- JSON
		{
@@ -48,7 +54,7 @@ function run_spdk_fio() {

vhosttestinit "--no_vm"

trap 'error_exit "${FUNCNAME}" "${LINENO}"' ERR SIGTERM SIGABRT
trap 'cleanup' EXIT

vhost_run -n "$vhost_name"

@@ -60,6 +66,3 @@ run_fio_pid=$!
sleep 1
run_spdk_fio --size=50% --offset=50% --filename=VirtioBlk0
wait $run_fio_pid
vhost_kill 0

vhosttestfini