numam-spdk/test/spdkcli/common.sh
Darek Stojaczyk b5bdc850cc test/spdkcli: cleanup common.sh
Functions in this file already expect some variables
to be set by the calling script, so do the same with
$testdir and functions from autotest_common. We'll start
using `set -u` soon, so that variable expansion failure
will produce a clear error message (and will trigger ERR).

Change-Id: I3795af498639ad73a99cd03c6b5e72717fe5fd75
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458177
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-06-19 03:54:58 +00:00

52 lines
1.3 KiB
Bash

spdkcli_job="$rootdir/test/spdkcli/spdkcli_job.py"
spdk_clear_config_py="$rootdir/test/json_config/clear_config.py"
function on_error_exit() {
set +e
if [ ! -z $spdk_tgt_pid ]; then
killprocess $spdk_tgt_pid
fi
if [ ! -z $nvmf_tgt_pid ]; then
killprocess $nvmf_tgt_pid
fi
if [ ! -z $iscsi_tgt_pid ]; then
killprocess $iscsi_tgt_pid
fi
if [ ! -z $vhost_tgt_pid ]; then
killprocess $vhost_tgt_pid
fi
rm -f $testdir/${MATCH_FILE} $testdir/match_files/spdkcli_details_vhost.test /tmp/sample_aio /tmp/sample_pmem
print_backtrace
exit 1
}
function run_spdk_tgt() {
$rootdir/app/spdk_tgt/spdk_tgt -m 0x3 -p 0 -s 4096 &
spdk_tgt_pid=$!
waitforlisten $spdk_tgt_pid
}
function run_nvmf_tgt() {
$rootdir/app/nvmf_tgt/nvmf_tgt -m 0x3 -p 0 -s 4096 &
nvmf_tgt_pid=$!
waitforlisten $nvmf_tgt_pid
}
function run_iscsi_tgt() {
$rootdir/app/iscsi_tgt/iscsi_tgt -m 0x3 -p 0 -s 4096 &
iscsi_tgt_pid=$!
waitforlisten $iscsi_tgt_pid
}
function run_vhost_tgt() {
$rootdir/app/vhost/vhost -m 0x3 -p 0 -s 4096 &
vhost_tgt_pid=$!
waitforlisten $vhost_tgt_pid
}
function check_match() {
$rootdir/scripts/spdkcli.py ll $SPDKCLI_BRANCH > $testdir/match_files/${MATCH_FILE}
$rootdir/test/app/match/match -v $testdir/match_files/${MATCH_FILE}.match
rm -f $testdir/match_files/${MATCH_FILE}
}