From 074df1d89656555da48017f11ad379dc93e2dfaf Mon Sep 17 00:00:00 2001 From: Pawel Kaminski Date: Thu, 24 Oct 2019 13:58:04 +0000 Subject: [PATCH] test: Shellcheck - apply rule SC2155 Declare and assign separately to avoid masking return values. Signed-off-by: Pawel Kaminski Change-Id: Ib90598e4268911a3056e8a0baa7d541edaa29b91 Signed-off-by: Pawel Kaminski Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472287 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- scripts/check_format.sh | 2 +- scripts/common.sh | 15 +++-- scripts/setup.sh | 9 ++- test/bdev/bdev_raid.sh | 3 +- test/common/autotest_common.sh | 27 +++++--- test/ftl/common.sh | 9 ++- test/iscsi_tgt/qos/qos.sh | 15 +++-- test/nvme/hotplug.sh | 3 +- test/nvme/perf/common.sh | 27 +++++--- test/nvmf/common.sh | 3 +- test/pmem/common.sh | 3 +- test/vhost/common.sh | 87 ++++++++++++++++---------- test/vhost/hotplug/common.sh | 3 +- test/vhost/migration/migration-tc2.sh | 6 +- test/vhost/migration/migration-tc3a.sh | 3 +- test/vhost/migration/migration.sh | 15 +++-- test/vhost/perf_bench/vhost_perf.sh | 3 +- test/vhost/windows/windows.sh | 3 +- 18 files changed, 152 insertions(+), 84 deletions(-) diff --git a/scripts/check_format.sh b/scripts/check_format.sh index 24be8c654..b0e2c4340 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -243,7 +243,7 @@ if hash shellcheck 2>/dev/null; then SHCK_EXCLUDE="SC1083,SC2002,\ SC2010,SC2012,SC2016,SC2034,SC2045,SC2046,SC2068,SC2086,SC2089,SC2090,\ SC2097,SC2098,SC2119,SC2120,SC2128,\ -SC2129,SC2140,SC2142,SC2143,SC2154,SC2155" +SC2129,SC2140,SC2142,SC2143,SC2154" # SPDK fails some error checks which have been deprecated in later versions of shellcheck. # We will not try to fix these error checks, but instead just leave the error types here # so that we can still run with older versions of shellcheck. diff --git a/scripts/common.sh b/scripts/common.sh index b22106da0..7948d68e8 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -30,9 +30,12 @@ function pci_can_use() { # This function will ignore PCI PCI_WHITELIST and PCI_BLACKLIST function iter_all_pci_class_code() { - local class="$(printf %02x $((0x$1)))" - local subclass="$(printf %02x $((0x$2)))" - local progif="$(printf %02x $((0x$3)))" + local class + local subclass + local progif + class="$(printf %02x $((0x$1)))" + subclass="$(printf %02x $((0x$2)))" + progif="$(printf %02x $((0x$3)))" if hash lspci &>/dev/null; then if [ "$progif" != "00" ]; then @@ -57,8 +60,10 @@ function iter_all_pci_class_code() { # This function will ignore PCI PCI_WHITELIST and PCI_BLACKLIST function iter_all_pci_dev_id() { - local ven_id="$(printf %04x $((0x$1)))" - local dev_id="$(printf %04x $((0x$2)))" + local ven_id + local dev_id + ven_id="$(printf %04x $((0x$1)))" + dev_id="$(printf %04x $((0x$2)))" if hash lspci &>/dev/null; then lspci -mm -n -D | awk -v ven="\"$ven_id\"" -v dev="\"${dev_id}\"" -F " " \ diff --git a/scripts/setup.sh b/scripts/setup.sh index 0bfd57beb..7ff8356f4 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -79,8 +79,10 @@ function check_for_driver { function pci_dev_echo() { local bdf="$1" - local vendor="$(cat /sys/bus/pci/devices/$bdf/vendor)" - local device="$(cat /sys/bus/pci/devices/$bdf/device)" + local vendor + local device + vendor="$(cat /sys/bus/pci/devices/$bdf/vendor)" + device="$(cat /sys/bus/pci/devices/$bdf/device)" shift echo "$bdf (${vendor#0x} ${device#0x}): $*" } @@ -118,7 +120,8 @@ function linux_bind_driver() { function linux_unbind_driver() { local bdf="$1" - local ven_dev_id=$(lspci -n -s $bdf | cut -d' ' -f3 | sed 's/:/ /') + local ven_dev_id + ven_dev_id=$(lspci -n -s $bdf | cut -d' ' -f3 | sed 's/:/ /') local old_driver_name="no driver" if [ -e "/sys/bus/pci/devices/$bdf/driver" ]; then diff --git a/test/bdev/bdev_raid.sh b/test/bdev/bdev_raid.sh index c9e94a9d8..a5f0d346d 100755 --- a/test/bdev/bdev_raid.sh +++ b/test/bdev/bdev_raid.sh @@ -13,7 +13,8 @@ function raid_unmap_data_verify() { if hash blkdiscard; then local nbd=$1 local rpc_server=$2 - local blksize=$(lsblk -o LOG-SEC $nbd | grep -v LOG-SEC | cut -d ' ' -f 5) + local blksize + blksize=$(lsblk -o LOG-SEC $nbd | grep -v LOG-SEC | cut -d ' ' -f 5) local rw_blk_num=4096 local rw_len=$((blksize * rw_blk_num)) local unmap_blk_offs=(0 1028 321) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 4a12d28d6..830cb2691 100644 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -462,7 +462,8 @@ function killprocess() { if [ "$(ps --no-headers -o comm= $1)" = "sudo" ]; then # kill the child process, which is the actual app # (assume $1 has just one child) - local child="$(pgrep -P $1)" + local child + child="$(pgrep -P $1)" echo "killing process with pid $child" kill $child else @@ -559,7 +560,8 @@ function kill_stub() { function run_test() { xtrace_disable - local test_type="$(echo $1 | tr '[:lower:]' '[:upper:]')" + local test_type + test_type="$(echo $1 | tr '[:lower:]' '[:upper:]')" shift echo "************************************" echo "START TEST $test_type $*" @@ -806,7 +808,8 @@ function fio_bdev() local bdev_plugin="$rootdir/examples/bdev/fio_plugin/fio_plugin" # Preload AddressSanitizer library to fio if fio_plugin was compiled with it - local asan_lib=$(ldd $bdev_plugin | grep libasan | awk '{print $3}') + local asan_lib + asan_lib=$(ldd $bdev_plugin | grep libasan | awk '{print $3}') LD_PRELOAD="$asan_lib $bdev_plugin" "$fio_dir"/fio "$@" } @@ -826,9 +829,12 @@ function fio_nvme() function get_lvs_free_mb() { local lvs_uuid=$1 - local lvs_info=$($rpc_py bdev_lvol_get_lvstores) - local fc=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .free_clusters" <<< "$lvs_info") - local cs=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .cluster_size" <<< "$lvs_info") + local lvs_info + local fc + local cs + lvs_info=$($rpc_py bdev_lvol_get_lvstores) + fc=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .free_clusters" <<< "$lvs_info") + cs=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .cluster_size" <<< "$lvs_info") # Change to MB's free_mb=$((fc*cs/1024/1024)) @@ -838,9 +844,12 @@ function get_lvs_free_mb() function get_bdev_size() { local bdev_name=$1 - local bdev_info=$($rpc_py bdev_get_bdevs -b $bdev_name) - local bs=$(jq ".[] .block_size" <<< "$bdev_info") - local nb=$(jq ".[] .num_blocks" <<< "$bdev_info") + local bdev_info + local bs + local nb + bdev_info=$($rpc_py bdev_get_bdevs -b $bdev_name) + bs=$(jq ".[] .block_size" <<< "$bdev_info") + nb=$(jq ".[] .num_blocks" <<< "$bdev_info") # Change to MB's bdev_size=$((bs*nb/1024/1024)) diff --git a/test/ftl/common.sh b/test/ftl/common.sh index 9f3cffab4..73ffc8835 100644 --- a/test/ftl/common.sh +++ b/test/ftl/common.sh @@ -6,7 +6,8 @@ function get_chunk_size() { } function has_separate_md() { - local md_type=$($rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:$1" | \ + local md_type + md_type=$($rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:$1" | \ grep 'Metadata Transferred' | cut -d: -f2) if [[ "$md_type" =~ Separate ]]; then return 0 @@ -22,7 +23,8 @@ function create_nv_cache_bdev() { local num_punits=$4 local bytes_to_mb=$((1024 * 1024)) - local chunk_size=$(get_chunk_size $ocssd_bdf) + local chunk_size + chunk_size=$(get_chunk_size $ocssd_bdf) # We need at least 2 bands worth of data + 1 block local size=$((2 * 4096 * chunk_size * num_punits + 1)) @@ -30,6 +32,7 @@ function create_nv_cache_bdev() { local size=$(((size + bytes_to_mb) / bytes_to_mb)) # Create NVMe bdev on specified device and split it so that it has the desired size - local nvc_bdev=$($rootdir/scripts/rpc.py bdev_nvme_attach_controller -b $name -t PCIe -a $cache_bdf) + local nvc_bdev + nvc_bdev=$($rootdir/scripts/rpc.py bdev_nvme_attach_controller -b $name -t PCIe -a $cache_bdf) $rootdir/scripts/rpc.py bdev_split_create $nvc_bdev -s $size 1 } diff --git a/test/iscsi_tgt/qos/qos.sh b/test/iscsi_tgt/qos/qos.sh index fd5a24bb0..a61dd0d9f 100755 --- a/test/iscsi_tgt/qos/qos.sh +++ b/test/iscsi_tgt/qos/qos.sh @@ -11,17 +11,22 @@ iscsitestinit $1 $2 function run_fio() { local bdev_name=$1 - local iostats=$($rpc_py bdev_get_iostat -b $bdev_name) + local iostats + local start_io_count + local start_bytes_read + local end_io_count + local end_bytes_read local run_time=5 - local start_io_count=$(jq -r '.bdevs[0].num_read_ops' <<< "$iostats") - local start_bytes_read=$(jq -r '.bdevs[0].bytes_read' <<< "$iostats") + iostats=$($rpc_py bdev_get_iostat -b $bdev_name) + start_io_count=$(jq -r '.bdevs[0].num_read_ops' <<< "$iostats") + start_bytes_read=$(jq -r '.bdevs[0].bytes_read' <<< "$iostats") $fio_py -p iscsi -i 1024 -d 128 -t randread -r $run_time iostats=$($rpc_py bdev_get_iostat -b $bdev_name) - local end_io_count=$(jq -r '.bdevs[0].num_read_ops' <<< "$iostats") - local end_bytes_read=$(jq -r '.bdevs[0].bytes_read' <<< "$iostats") + end_io_count=$(jq -r '.bdevs[0].num_read_ops' <<< "$iostats") + end_bytes_read=$(jq -r '.bdevs[0].bytes_read' <<< "$iostats") IOPS_RESULT=$(((end_io_count-start_io_count)/run_time)) BANDWIDTH_RESULT=$(((end_bytes_read-start_bytes_read)/run_time)) diff --git a/test/nvme/hotplug.sh b/test/nvme/hotplug.sh index b0da49751..fbdb14884 100755 --- a/test/nvme/hotplug.sh +++ b/test/nvme/hotplug.sh @@ -10,7 +10,8 @@ if [ -z "${DEPENDENCY_DIR}" ]; then fi function ssh_vm() { - local shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )" + local shell_restore_x + shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )" set +x sshpass -p "$password" ssh -o PubkeyAuthentication=no \ -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 10022 root@localhost "$@" diff --git a/test/nvme/perf/common.sh b/test/nvme/perf/common.sh index bf72b289f..d2f0c34de 100755 --- a/test/nvme/perf/common.sh +++ b/test/nvme/perf/common.sh @@ -28,8 +28,10 @@ NOIOSCALING=false function is_bdf_not_mounted() { local bdf=$1 - local blkname=$(ls -l /sys/block/ | grep $bdf | awk '{print $9}') - local mountpoints=$(lsblk /dev/$blkname --output MOUNTPOINT -n | wc -w) + local blkname + local mountpoints + blkname=$(ls -l /sys/block/ | grep $bdf | awk '{print $9}') + mountpoints=$(lsblk /dev/$blkname --output MOUNTPOINT -n | wc -w) return $mountpoints } @@ -52,16 +54,19 @@ function get_numa_node(){ local disks=$2 if [ "$plugin" = "nvme" ]; then for bdf in $disks; do - local driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent |awk -F"=" '{print $2}') + local driver + driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent |awk -F"=" '{print $2}') # Use this check to ommit blacklisted devices ( not binded to driver with setup.sh script ) if [ "$driver" = "vfio-pci" ] || [ "$driver" = "uio_pci_generic" ]; then cat /sys/bus/pci/devices/$bdf/numa_node fi done elif [ "$plugin" = "bdev" ] || [ "$plugin" = "bdevperf" ]; then - local bdevs=$(discover_bdevs $ROOT_DIR $BASE_DIR/bdev.conf) + local bdevs + bdevs=$(discover_bdevs $ROOT_DIR $BASE_DIR/bdev.conf) for name in $disks; do - local bdev_bdf=$(jq -r ".[] | select(.name==\"$name\").driver_specific.nvme.pci_address" <<< $bdevs) + local bdev_bdf + bdev_bdf=$(jq -r ".[] | select(.name==\"$name\").driver_specific.nvme.pci_address" <<< $bdevs) cat /sys/bus/pci/devices/$bdev_bdf/numa_node done else @@ -84,13 +89,15 @@ function get_disks(){ fi done elif [ "$plugin" = "bdev" ] || [ "$plugin" = "bdevperf" ]; then - local bdevs=$(discover_bdevs $ROOT_DIR $BASE_DIR/bdev.conf) + local bdevs + bdevs=$(discover_bdevs $ROOT_DIR $BASE_DIR/bdev.conf) jq -r '.[].name' <<< $bdevs else # Only target not mounted NVMes for bdf in $(iter_pci_class_code 01 08 02); do if is_bdf_not_mounted $bdf; then - local blkname=$(ls -l /sys/block/ | grep $bdf | awk '{print $9}') + local blkname + blkname=$(ls -l /sys/block/ | grep $bdf | awk '{print $9}') echo $blkname fi done @@ -123,7 +130,8 @@ function create_fio_config(){ local no_cores=${#cores[@]} local filename="" - local cores_numa=($(get_cores_numa_node "$5")) + local cores_numa + cores_numa=($(get_cores_numa_node "$5")) local disks_per_core=$((disk_no/no_cores)) local disks_per_core_mod=$((disk_no%no_cores)) @@ -202,7 +210,8 @@ function preconditioning(){ # We only want to target NVMes not bound to nvme driver. # If they're still bound to nvme that means they were skipped by # setup.sh on purpose. - local nvme_list=$(get_disks nvme) + local nvme_list + nvme_list=$(get_disks nvme) for nvme in $nvme_list; do dev_name='trtype=PCIe traddr='${nvme//:/.}' ns=1' filename+=$(printf %s":" "$dev_name") diff --git a/test/nvmf/common.sh b/test/nvmf/common.sh index 49a09d180..bc4c0998e 100644 --- a/test/nvmf/common.sh +++ b/test/nvmf/common.sh @@ -258,7 +258,8 @@ function check_ip_is_soft_roce() function nvme_connect() { - local init_count=$(nvme list | wc -l) + local init_count + init_count=$(nvme list | wc -l) if ! nvme connect $@; then return $?; fi diff --git a/test/pmem/common.sh b/test/pmem/common.sh index 656e9cf60..4c6b6077d 100644 --- a/test/pmem/common.sh +++ b/test/pmem/common.sh @@ -79,7 +79,8 @@ function vhost_start() function vhost_kill() { local vhost_pid_file="$testdir/vhost.pid" - local vhost_pid="$(cat $vhost_pid_file)" + local vhost_pid + vhost_pid="$(cat $vhost_pid_file)" if [[ ! -f $vhost_pid_file ]]; then echo -e "ERROR: No vhost pid file found!" diff --git a/test/vhost/common.sh b/test/vhost/common.sh index 4048a9aa9..10f05c792 100644 --- a/test/vhost/common.sh +++ b/test/vhost/common.sh @@ -55,12 +55,13 @@ function vhosttestfini() function message() { + local verbose_out if ! $SPDK_VHOST_VERBOSE; then - local verbose_out="" + verbose_out="" elif [[ ${FUNCNAME[2]} == "source" ]]; then - local verbose_out=" (file $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[1]})" + verbose_out=" (file $(basename ${BASH_SOURCE[1]}):${BASH_LINENO[1]})" else - local verbose_out=" (function ${FUNCNAME[2]}:${BASH_LINENO[1]})" + verbose_out=" (function ${FUNCNAME[2]}:${BASH_LINENO[1]})" fi local msg_type="$1" @@ -124,7 +125,8 @@ function vhost_run() shift fi - local vhost_dir="$(get_vhost_dir $vhost_name)" + local vhost_dir + vhost_dir="$(get_vhost_dir $vhost_name)" local vhost_app="$rootdir/app/vhost/vhost" local vhost_log_file="$vhost_dir/vhost.log" local vhost_pid_file="$vhost_dir/vhost.pid" @@ -166,7 +168,8 @@ function vhost_load_config() { local vhost_num="$1" local vhost_json_conf="$2" - local vhost_dir="$(get_vhost_dir $vhost_num)" + local vhost_dir + vhost_dir="$(get_vhost_dir $vhost_num)" $rootdir/scripts/rpc.py -s $vhost_dir/rpc.sock load_config < "$vhost_json_conf" } @@ -181,7 +184,8 @@ function vhost_kill() return 0 fi - local vhost_dir="$(get_vhost_dir $vhost_name)" + local vhost_dir + vhost_dir="$(get_vhost_dir $vhost_name)" local vhost_pid_file="$vhost_dir/vhost.pid" if [[ ! -r $vhost_pid_file ]]; then @@ -190,7 +194,8 @@ function vhost_kill() fi timing_enter vhost_kill - local vhost_pid="$(cat $vhost_pid_file)" + local vhost_pid + vhost_pid="$(cat $vhost_pid_file)" notice "killing vhost (PID $vhost_pid) app" if kill -INT $vhost_pid > /dev/null; then @@ -263,7 +268,8 @@ function vm_sshpass() { vm_num_is_valid $1 || return 1 - local ssh_cmd="sshpass -p $2 ssh \ + local ssh_cmd + ssh_cmd="sshpass -p $2 ssh \ -o UserKnownHostsFile=/dev/null \ -o StrictHostKeyChecking=no \ -o User=root \ @@ -353,7 +359,8 @@ function vm_is_running() return 1 fi - local vm_pid="$(cat $vm_dir/qemu.pid)" + local vm_pid + vm_pid="$(cat $vm_dir/qemu.pid)" if /bin/kill -0 $vm_pid; then return 0 @@ -429,7 +436,8 @@ function vm_kill() return 0 fi - local vm_pid="$(cat $vm_dir/qemu.pid)" + local vm_pid + vm_pid="$(cat $vm_dir/qemu.pid)" notice "Killing virtual machine $vm_dir (pid=$vm_pid)" # First kill should fail, second one must fail @@ -447,7 +455,8 @@ function vm_kill() # function vm_list_all() { - local vms="$(shopt -s nullglob; echo $VM_DIR/[0-9]*)" + local vms + vms="$(shopt -s nullglob; echo $VM_DIR/[0-9]*)" if [[ -n "$vms" ]]; then basename --multiple $vms fi @@ -469,11 +478,13 @@ function vm_kill_all() # function vm_shutdown_all() { - local shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )" + local shell_restore_x + shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )" # XXX: temporally disable to debug shutdown issue # set +x - local vms=$(vm_list_all) + local vms + vms=$(vm_list_all) local vm for vm in $vms; do @@ -510,7 +521,8 @@ function vm_shutdown_all() function vm_setup() { - local shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )" + local shell_restore_x + shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )" local OPTIND optchar vm_num local os="" @@ -525,24 +537,25 @@ function vm_setup() local force_vm="" local guest_memory=1024 local queue_number="" - local vhost_dir="$(get_vhost_dir 0)" + local vhost_dir + vhost_dir="$(get_vhost_dir 0)" while getopts ':-:' optchar; do case "$optchar" in -) case "$OPTARG" in - os=*) local os="${OPTARG#*=}" ;; - os-mode=*) local os_mode="${OPTARG#*=}" ;; - qemu-args=*) local qemu_args="${qemu_args} ${OPTARG#*=}" ;; - disk-type=*) local disk_type_g="${OPTARG#*=}" ;; - read-only=*) local read_only="${OPTARG#*=}" ;; - disks=*) local disks="${OPTARG#*=}" ;; - raw-cache=*) local raw_cache=",cache${OPTARG#*=}" ;; - force=*) local force_vm=${OPTARG#*=} ;; - memory=*) local guest_memory=${OPTARG#*=} ;; - queue_num=*) local queue_number=${OPTARG#*=} ;; - incoming=*) local vm_incoming="${OPTARG#*=}" ;; - migrate-to=*) local vm_migrate_to="${OPTARG#*=}" ;; - vhost-name=*) local vhost_dir="$(get_vhost_dir ${OPTARG#*=})" ;; + os=*) os="${OPTARG#*=}" ;; + os-mode=*) os_mode="${OPTARG#*=}" ;; + qemu-args=*) qemu_args="${qemu_args} ${OPTARG#*=}" ;; + disk-type=*) disk_type_g="${OPTARG#*=}" ;; + read-only=*) read_only="${OPTARG#*=}" ;; + disks=*) disks="${OPTARG#*=}" ;; + raw-cache=*) raw_cache=",cache${OPTARG#*=}" ;; + force=*) force_vm=${OPTARG#*=} ;; + memory=*) guest_memory=${OPTARG#*=} ;; + queue_num=*) queue_number=${OPTARG#*=} ;; + incoming=*) vm_incoming="${OPTARG#*=}" ;; + migrate-to=*) vm_migrate_to="${OPTARG#*=}" ;; + vhost-name=*) vhost_dir="$(get_vhost_dir ${OPTARG#*=})" ;; spdk-boot=*) local boot_from="${OPTARG#*=}" ;; *) error "unknown argument $OPTARG" @@ -709,7 +722,8 @@ function vm_setup() if [[ -n $disk ]]; then [[ ! -b $disk ]] && touch $disk - local raw_disk=$(readlink -f $disk) + local raw_disk + raw_disk=$(readlink -f $disk) fi # Create disk file if it not exist or it is smaller than 1G @@ -897,13 +911,15 @@ function vm_wait_for_boot() { assert_number $1 - local shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )" + local shell_restore_x + shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )" set +x local all_booted=false local timeout_time=$1 [[ $timeout_time -lt 10 ]] && timeout_time=10 - local timeout_time=$(date -d "+$timeout_time seconds" +%s) + local timeout_time + timeout_time=$(date -d "+$timeout_time seconds" +%s) notice "Waiting for VMs to boot" shift @@ -917,7 +933,8 @@ function vm_wait_for_boot() fi for vm in $vms_to_check; do - local vm_num=$(basename $vm) + local vm_num + vm_num=$(basename $vm) local i=0 notice "waiting for VM$vm_num ($vm)" while ! vm_os_booted $vm_num; do @@ -945,7 +962,8 @@ function vm_wait_for_boot() notice "VM$vm_num ready" #Change Timeout for stopping services to prevent lengthy powerdowns #Check that remote system is not Cygwin in case of Windows VMs - local vm_os=$(vm_exec $vm_num "uname -o") + local vm_os + vm_os=$(vm_exec $vm_num "uname -o") if [[ "$vm_os" != "Cygwin" ]]; then vm_exec $vm_num "echo 'DefaultTimeoutStopSec=10' >> /etc/systemd/system.conf; systemctl daemon-reexec" fi @@ -1066,7 +1084,8 @@ function run_fio() return 1 fi - local job_fname=$(basename "$job_file") + local job_fname + job_fname=$(basename "$job_file") # prepare job file for each VM for vm in ${vms[@]}; do local vm_num=${vm%%:*} diff --git a/test/vhost/hotplug/common.sh b/test/vhost/hotplug/common.sh index fe2f9ed0b..c84273b15 100644 --- a/test/vhost/hotplug/common.sh +++ b/test/vhost/hotplug/common.sh @@ -199,7 +199,8 @@ function check_disks() { function get_traddr() { local nvme_name=$1 - local nvme="$( $rootdir/scripts/gen_nvme.sh )" + local nvme + nvme="$( $rootdir/scripts/gen_nvme.sh )" while read -r line; do if [[ $line == *"TransportID"* ]] && [[ $line == *$nvme_name* ]]; then local word_array=($line) diff --git a/test/vhost/migration/migration-tc2.sh b/test/vhost/migration/migration-tc2.sh index 216235a14..421c1e568 100644 --- a/test/vhost/migration/migration-tc2.sh +++ b/test/vhost/migration/migration-tc2.sh @@ -105,8 +105,10 @@ function migration_tc2_configure_vhost() vhost_run 0 "-m 0x1 -s 512 -u" vhost_run 1 "-m 0x2 -s 512 -u" - local rdma_ip_list=$(get_available_rdma_ips) - local nvmf_target_ip=$(echo "$rdma_ip_list" | head -n 1) + local rdma_ip_list + local nvmf_target_ip + rdma_ip_list=$(get_available_rdma_ips) + nvmf_target_ip=$(echo "$rdma_ip_list" | head -n 1) if [[ -z "$nvmf_target_ip" ]]; then fail "no NIC for nvmf target" diff --git a/test/vhost/migration/migration-tc3a.sh b/test/vhost/migration/migration-tc3a.sh index e45fd541c..445fce382 100644 --- a/test/vhost/migration/migration-tc3a.sh +++ b/test/vhost/migration/migration-tc3a.sh @@ -55,7 +55,8 @@ function wait_for_remote() function check_rdma_connection() { - local nic_name=$(ip -4 -o addr show to $RDMA_TARGET_IP up | cut -d' ' -f2) + local nic_name + nic_name=$(ip -4 -o addr show to $RDMA_TARGET_IP up | cut -d' ' -f2) if [[ -z $nic_name ]]; then error "There is no NIC with IP address $RDMA_TARGET_IP configured" fi diff --git a/test/vhost/migration/migration.sh b/test/vhost/migration/migration.sh index 95572b33c..0105e31e3 100755 --- a/test/vhost/migration/migration.sh +++ b/test/vhost/migration/migration.sh @@ -67,7 +67,8 @@ function vm_monitor_send() local vm_num=$1 local cmd_result_file="$2" local vm_dir="$VM_DIR/$1" - local vm_monitor_port=$(cat $vm_dir/monitor_port) + local vm_monitor_port + vm_monitor_port=$(cat $vm_dir/monitor_port) [[ -n "$vm_monitor_port" ]] || fail "No monitor port!" @@ -79,9 +80,12 @@ function vm_monitor_send() function vm_migrate() { local from_vm_dir="$VM_DIR/$1" - local target_vm_dir="$(readlink -e $from_vm_dir/vm_migrate_to)" - local target_vm="$(basename $target_vm_dir)" - local target_vm_migration_port="$(cat $target_vm_dir/migration_port)" + local target_vm_dir + local target_vm + local target_vm_migration_port + target_vm_dir="$(readlink -e $from_vm_dir/vm_migrate_to)" + target_vm="$(basename $target_vm_dir)" + target_vm_migration_port="$(cat $target_vm_dir/migration_port)" if [[ -n "$2" ]]; then local target_ip=$2 else @@ -123,7 +127,8 @@ function vm_migrate() function is_fio_running() { - local shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )" + local shell_restore_x + shell_restore_x="$( [[ "$-" =~ x ]] && echo 'set -x' )" set +x if vm_exec $1 'kill -0 $(cat /root/fio.pid)'; then diff --git a/test/vhost/perf_bench/vhost_perf.sh b/test/vhost/perf_bench/vhost_perf.sh index c0f1267bb..fa4240c16 100755 --- a/test/vhost/perf_bench/vhost_perf.sh +++ b/test/vhost/perf_bench/vhost_perf.sh @@ -95,7 +95,8 @@ function cleanup_split_cfg() function cleanup_parted_config() { - local disks=$(ls /dev/nvme*n1 | sort --version-sort) + local disks + disks=$(ls /dev/nvme*n1 | sort --version-sort) for disk in $disks; do parted -s $disk rm 1 done diff --git a/test/vhost/windows/windows.sh b/test/vhost/windows/windows.sh index f34743fcb..8c716e62a 100755 --- a/test/vhost/windows/windows.sh +++ b/test/vhost/windows/windows.sh @@ -57,7 +57,8 @@ function vm_sshpass() { vm_num_is_valid $1 || return 1 - local ssh_cmd="sshpass -p $2 ssh \ + local ssh_cmd + ssh_cmd="sshpass -p $2 ssh \ -o UserKnownHostsFile=/dev/null \ -o StrictHostKeyChecking=no \ -o User=root \