test/vhost: shell_restore_x -> xtrace_restore

The shell_Restore_x variable and xtrace_restore were attempting to
accomplish the exact same thing. However, when assigning
shell_restore_x, if -x was not set, then the assignment would result in
an error causing the scripts to fail.
So just get rid of that variable entirely and replace it with the more
robust xtrace_disable, xtrace_restore mechanism.

Change-Id: Ic823ad8433bd3dc181aaa0930297cd9d74bcf528
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477966
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Seth Howell 2019-12-13 09:20:12 -07:00 committed by Tomasz Zawadzki
parent 190b2245c5
commit 34ae11720d
3 changed files with 15 additions and 26 deletions

View File

@ -10,12 +10,10 @@ if [ -z "${DEPENDENCY_DIR}" ]; then
fi fi
function ssh_vm() { function ssh_vm() {
local shell_restore_x xtrace_disable
shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )"
set +x
sshpass -p "$password" ssh -o PubkeyAuthentication=no \ sshpass -p "$password" ssh -o PubkeyAuthentication=no \
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 10022 root@localhost "$@" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 10022 root@localhost "$@"
$shell_restore_x xtrace_restore
} }
function monitor_cmd() { function monitor_cmd() {

View File

@ -480,10 +480,8 @@ function vm_kill_all()
# #
function vm_shutdown_all() function vm_shutdown_all()
{ {
local shell_restore_x # XXX: temporarily disable to debug shutdown issue
shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )" # xtrace_disable
# XXX: temporally disable to debug shutdown issue
# set +x
local vms local vms
vms=$(vm_list_all) vms=$(vm_list_all)
@ -506,7 +504,7 @@ function vm_shutdown_all()
if [[ $all_vms_down == 1 ]]; then if [[ $all_vms_down == 1 ]]; then
notice "All VMs successfully shut down" notice "All VMs successfully shut down"
$shell_restore_x xtrace_restore
return 0 return 0
fi fi
@ -516,15 +514,12 @@ function vm_shutdown_all()
rm -rf $VM_DIR rm -rf $VM_DIR
$shell_restore_x xtrace_restore
error "Timeout waiting for some VMs to shutdown"
return 1
} }
function vm_setup() function vm_setup()
{ {
local shell_restore_x xtrace_disable
shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )"
local OPTIND optchar vm_num local OPTIND optchar vm_num
local os="" local os=""
@ -586,7 +581,7 @@ function vm_setup()
local vm_dir="$VM_DIR/$i" local vm_dir="$VM_DIR/$i"
[[ ! -d $vm_dir ]] && break [[ ! -d $vm_dir ]] && break
done done
$shell_restore_x xtrace_restore
vm_num=$i vm_num=$i
fi fi
@ -683,7 +678,7 @@ function vm_setup()
queue_number=$cpu_num queue_number=$cpu_num
fi fi
$shell_restore_x xtrace_restore
local node_num=${!qemu_numa_node_param} local node_num=${!qemu_numa_node_param}
local boot_disk_present=false local boot_disk_present=false
@ -913,9 +908,7 @@ function vm_wait_for_boot()
{ {
assert_number $1 assert_number $1
local shell_restore_x xtrace_disable
shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )"
set +x
local all_booted=false local all_booted=false
local timeout_time=$1 local timeout_time=$1
@ -943,14 +936,14 @@ function vm_wait_for_boot()
if ! vm_is_running $vm_num; then if ! vm_is_running $vm_num; then
warning "VM $vm_num is not running" warning "VM $vm_num is not running"
vm_print_logs $vm_num vm_print_logs $vm_num
$shell_restore_x xtrace_restore
return 1 return 1
fi fi
if [[ $(date +%s) -gt $timeout_time ]]; then if [[ $(date +%s) -gt $timeout_time ]]; then
warning "timeout waiting for machines to boot" warning "timeout waiting for machines to boot"
vm_print_logs $vm_num vm_print_logs $vm_num
$shell_restore_x xtrace_restore
return 1 return 1
fi fi
if (( i > 30 )); then if (( i > 30 )); then
@ -972,7 +965,7 @@ function vm_wait_for_boot()
done done
notice "all VMs ready" notice "all VMs ready"
$shell_restore_x xtrace_restore
return 0 return 0
} }

View File

@ -127,9 +127,7 @@ function vm_migrate()
function is_fio_running() function is_fio_running()
{ {
local shell_restore_x xtrace_disable
shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )"
set +x
if vm_exec $1 'kill -0 $(cat /root/fio.pid)'; then if vm_exec $1 'kill -0 $(cat /root/fio.pid)'; then
local ret=0 local ret=0
@ -137,7 +135,7 @@ function is_fio_running()
local ret=1 local ret=1
fi fi
$shell_restore_x xtrace_restore
return $ret return $ret
} }