From b1e850cd10e24201ec68714a75eaba80d14a6917 Mon Sep 17 00:00:00 2001 From: Pawel Wodkowski Date: Thu, 16 Nov 2017 15:33:09 +0100 Subject: [PATCH] test/vhost: small fixes to common.sh file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7dd452a3e9535ad8e2612d8e9d99cf4f7f41b7d5 Signed-off-by: Pawel Wodkowski Reviewed-on: https://review.gerrithub.io/387798 Tested-by: SPDK Automated Test System Reviewed-by: Karol Latecki Reviewed-by: Paweł Niedźwiecki Reviewed-by: Dariusz Stojaczyk Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- test/vhost/common/common.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/vhost/common/common.sh b/test/vhost/common/common.sh index 181d8d094..63363b824 100644 --- a/test/vhost/common/common.sh +++ b/test/vhost/common/common.sh @@ -12,7 +12,7 @@ SPDK_BUILD_DIR=$BASE_DIR/../../../ SPDK_VHOST_SCSI_TEST_DIR=$TEST_DIR/vhost # SSH key file -[[ -z "$SPDK_VHOST_SSH_KEY_FILE" ]] && SPDK_VHOST_SSH_KEY_FILE="$HOME/.ssh/spdk_vhost_id_rsa" +: ${SPDK_VHOST_SSH_KEY_FILE="$HOME/.ssh/spdk_vhost_id_rsa"} if [[ ! -e "$SPDK_VHOST_SSH_KEY_FILE" ]]; then echo "Could not find SSH key file $SPDK_VHOST_SSH_KEY_FILE" exit 1 @@ -42,7 +42,8 @@ function error() echo "===========" echo -e "ERROR: $@" echo "===========" - return 1 + # Don't 'return 1' since the stack trace will be incomplete (why?) missing upper command. + false } function spdk_vhost_run() @@ -145,7 +146,7 @@ function assert_number() # function vm_num_is_valid() { - [[ "$1" =~ [0-9]+ ]] && return 0 + [[ "$1" =~ ^[0-9]+$ ]] && return 0 echo "${FUNCNAME[1]}() - ${BASH_LINENO[1]}: ERROR Invalid or missing paramter: vm number '$1'" > /dev/stderr return 1; @@ -317,7 +318,7 @@ function vm_kill() echo "INFO: process $vm_pid killed" rm $vm_dir/qemu.pid elif vm_is_running $1; then - erorr "Process $vm_pid NOT killed" + error "Process $vm_pid NOT killed" return 1 fi }