test/opal: add a trap for opal_revert_and_init()

When opal_revert_and_init() is interrupted for some reason,
the spdk_tgt still exists, but it should be killed at the same time.

Change-Id: I8546d3b0b4d6a0fda1687558a664decb535ef2b4
Signed-off-by: WANGHAILIANG <hailiangx.e.wang@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3830
Community-CI: Mellanox Build Bot
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
WANGHAILIANG 2020-08-18 13:40:39 +08:00 committed by Tomasz Zawadzki
parent c4e1d35c13
commit f6727316d7

View File

@ -20,6 +20,7 @@ bdf=${bdfs[0]}
function opal_revert_and_init() {
$SPDK_BIN_DIR/spdk_tgt &
spdk_tgt_pid=$!
trap 'killprocess $spdk_tgt_pid; exit 1' SIGINT SIGTERM EXIT
waitforlisten $spdk_tgt_pid
$rootdir/scripts/rpc.py bdev_nvme_attach_controller -b "nvme0" -t "pcie" -a ${bdf}