diff --git a/scripts/check_format.sh b/scripts/check_format.sh index 856f2ba88..7f0e7603f 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -241,7 +241,7 @@ if hash shellcheck 2>/dev/null; then # Error descriptions can also be found at: https://github.com/koalaman/shellcheck/wiki # This SHCK_EXCLUDE list is out "to do" and we work to fix all of this errors. SHCK_EXCLUDE="SC1083,SC2002,\ -SC2010,SC2012,SC2016,SC2034,SC2045,SC2046,SC2068,SC2086,SC2089,SC2090,\ +SC2010,SC2012,SC2016,SC2034,SC2045,SC2046,SC2086,SC2089,SC2090,\ SC2097,SC2098,SC2119,SC2120" # 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 diff --git a/scripts/qat_setup.sh b/scripts/qat_setup.sh index 5491694e9..ceb707904 100755 --- a/scripts/qat_setup.sh +++ b/scripts/qat_setup.sh @@ -22,7 +22,7 @@ if [ -n "$1" ]; then driver_to_bind=$1 fi -for driver in ${allowed_drivers[@]}; do +for driver in "${allowed_drivers[@]}"; do if [ $driver == $driver_to_bind ]; then bad_driver=false fi @@ -40,7 +40,7 @@ if service qat_service start; then fi # configure virtual functions for the QAT cards. -for qat_bdf in ${qat_pci_bdfs[@]}; do +for qat_bdf in "${qat_pci_bdfs[@]}"; do echo "$num_vfs" > /sys/bus/pci/drivers/c6xx/$qat_bdf/sriov_numvfs num_vfs=$(cat /sys/bus/pci/drivers/c6xx/$qat_bdf/sriov_numvfs) echo "$qat_bdf set to $num_vfs VFs" @@ -55,7 +55,7 @@ if (( ${#qat_vf_bdfs[@]} != ${#qat_pci_bdfs[@]}*num_vfs )); then fi # Unbind old driver if necessary. -for vf in ${qat_vf_bdfs[@]}; do +for vf in "${qat_vf_bdfs[@]}"; do old_driver=$(basename $(readlink -f /sys/bus/pci/devices/${vf}/driver)) if [ $old_driver != "driver" ]; then echo "unbinding driver $old_driver from qat VF at BDF $vf" @@ -81,7 +81,7 @@ else fi echo -n "8086 37c9" > /sys/bus/pci/drivers/$driver_to_bind/new_id -for vf in ${qat_vf_bdfs[@]}; do +for vf in "${qat_vf_bdfs[@]}"; do if ! ls -l /sys/bus/pci/devices/$vf/driver | grep -q $driver_to_bind; then echo "unable to bind the driver to the device at bdf $vf" if [ "$driver_to_bind" == "uio_pci_generic" ]; then diff --git a/scripts/setup.sh b/scripts/setup.sh index a71c18956..cdf00ed40 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -224,7 +224,7 @@ function configure_linux_pci { if ! $mount; then linux_bind_driver "$bdf" "$driver_name" else - for name in ${blknames[@]}; do + for name in "${blknames[@]}"; do pci_dev_echo "$bdf" "Active mountpoints on /dev/$name, so not binding PCI dev" done fi diff --git a/test/bdev/nbd_common.sh b/test/bdev/nbd_common.sh index a7041f742..533845c0d 100644 --- a/test/bdev/nbd_common.sh +++ b/test/bdev/nbd_common.sh @@ -45,7 +45,7 @@ function nbd_stop_disks() { local nbd_list=($2) local i - for i in ${nbd_list[@]}; do + for i in "${nbd_list[@]}"; do $rootdir/scripts/rpc.py -s $rpc_server nbd_stop_disk $i waitfornbd_exit $(basename $i) done @@ -69,12 +69,12 @@ function nbd_dd_data_verify() { if [ "$operation" = "write" ]; then # data write dd if=/dev/urandom of=$tmp_file bs=4096 count=256 - for i in ${nbd_list[@]}; do + for i in "${nbd_list[@]}"; do dd if=$tmp_file of=$i bs=4096 count=256 oflag=direct done elif [ "$operation" = "verify" ]; then # data read and verify - for i in ${nbd_list[@]}; do + for i in "${nbd_list[@]}"; do cmp -b -n 1M $tmp_file $i done rm $tmp_file diff --git a/test/ftl/fio.sh b/test/ftl/fio.sh index d36314386..f43796bc0 100755 --- a/test/ftl/fio.sh +++ b/test/ftl/fio.sh @@ -31,7 +31,7 @@ else $rootdir/scripts/gen_ftl.sh -a $device -n nvme0 -l 0-3 -u $uuid > $FTL_BDEV_CONF fi -for test in ${tests[@]}; do +for test in "${tests[@]}"; do timing_enter $test fio_bdev $testdir/config/fio/$test.fio timing_exit $test diff --git a/test/fuzz/autofuzz.sh b/test/fuzz/autofuzz.sh index bde591979..5170fce20 100755 --- a/test/fuzz/autofuzz.sh +++ b/test/fuzz/autofuzz.sh @@ -39,7 +39,7 @@ else exit 1 fi -for transport in ${allowed_transports[@]}; do +for transport in "${allowed_transports[@]}"; do if [ $transport == "$TEST_TRANSPORT" ]; then bad_transport=false fi diff --git a/test/make/check_so_deps.sh b/test/make/check_so_deps.sh index 308161d87..09662ad61 100755 --- a/test/make/check_so_deps.sh +++ b/test/make/check_so_deps.sh @@ -73,11 +73,11 @@ function confirm_deps() { done IFS=$'\n' # Ignore any event_* dependencies. Those are based on the subsystem configuration and not readelf. - lib_make_deps=( $(printf "%s\n" ${lib_make_deps[@]} | sort | grep -v "event_") ) + lib_make_deps=( $(printf "%s\n" "${lib_make_deps[@]}" | sort | grep -v "event_") ) # Ignore the env_dpdk readelf dependency. We don't want people explicitly linking against it. - dep_names=( $(printf "%s\n" ${dep_names[@]} | sort | uniq | grep -v "env_dpdk") ) + dep_names=( $(printf "%s\n" "${dep_names[@]}" | sort | uniq | grep -v "env_dpdk") ) unset IFS - diff=$(echo ${dep_names[@]} ${lib_make_deps[@]} | tr ' ' '\n' | sort | uniq -u) + diff=$(echo "${dep_names[@]}" "${lib_make_deps[@]}" | tr ' ' '\n' | sort | uniq -u) if [ "$diff" != "" ]; then touch $fail_file echo "there was a dependency mismatch in the library $lib_shortname" @@ -86,7 +86,7 @@ function confirm_deps() { echo "---------------------------------------------------------------------" elif [ ${#missing_syms[@]} -ne 0 ]; then echo "There are still undefined symbols in the library $lib_shortname" - printf "%s\n" ${missing_syms[@]} + printf "%s\n" "${missing_syms[@]}" echo "---------------------------------------------------------------------" fi } diff --git a/test/nvmf/common.sh b/test/nvmf/common.sh index 0824ed526..6925ee7de 100644 --- a/test/nvmf/common.sh +++ b/test/nvmf/common.sh @@ -261,7 +261,7 @@ function nvme_connect() local init_count init_count=$(nvme list | wc -l) - if ! nvme connect $@; then return $?; fi + if ! nvme connect "$@"; then return $?; fi for i in $(seq 1 10); do if [ $(nvme list | wc -l) -gt $init_count ]; then diff --git a/test/nvmf/host/perf.sh b/test/nvmf/host/perf.sh index d67cf1fc4..2b01819f1 100755 --- a/test/nvmf/host/perf.sh +++ b/test/nvmf/host/perf.sh @@ -74,8 +74,8 @@ if [ $RUN_NIGHTLY -eq 1 ]; then # Test perf as host with different io_size and qd_depth in nightly qd_depth=("1" "128") io_size=("512" "131072") - for qd in ${qd_depth[@]}; do - for o in ${io_size[@]}; do + for qd in "${qd_depth[@]}"; do + for o in "${io_size[@]}"; do $rootdir/examples/nvme/perf/perf -q $qd -o $o -w randrw -M 50 -t 10 -r "trtype:$TEST_TRANSPORT adrfam:IPv4 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT" done done diff --git a/test/ocf/integrity/fio-modes.sh b/test/ocf/integrity/fio-modes.sh index d766208c0..ff6e475c2 100755 --- a/test/ocf/integrity/fio-modes.sh +++ b/test/ocf/integrity/fio-modes.sh @@ -7,7 +7,7 @@ plugindir=$rootdir/examples/bdev/fio_plugin source $rootdir/test/common/autotest_common.sh function fio_verify(){ - fio_bdev $curdir/test.fio --aux-path=/tmp/ --ioengine=spdk_bdev $@ + fio_bdev $curdir/test.fio --aux-path=/tmp/ --ioengine=spdk_bdev "$@" } function cleanup(){ diff --git a/test/ocf/ocf.sh b/test/ocf/ocf.sh index 820b0f5f4..060eff2c6 100755 --- a/test/ocf/ocf.sh +++ b/test/ocf/ocf.sh @@ -7,9 +7,9 @@ source $rootdir/test/common/autotest_common.sh function suite() { - timing_enter $(basename $@) + timing_enter $(basename "$@") run_test suite "$@" - timing_exit $(basename $@) + timing_exit $(basename "$@") } timing_enter ocf diff --git a/test/vhost/common.sh b/test/vhost/common.sh index f264a8a5a..cbfd91822 100644 --- a/test/vhost/common.sh +++ b/test/vhost/common.sh @@ -245,7 +245,7 @@ function vhost_rpc fi shift - $rootdir/scripts/rpc.py -s $(get_vhost_dir $vhost_name)/rpc.sock $@ + $rootdir/scripts/rpc.py -s $(get_vhost_dir $vhost_name)/rpc.sock "$@" } ### @@ -854,7 +854,7 @@ function vm_run() vms_to_run="$(vm_list_all)" else shift $((OPTIND-1)) - for vm in $@; do + for vm in "$@"; do vm_num_is_valid $1 || return 1 if [[ ! -x $VM_DIR/$vm/run.sh ]]; then error "VM$vm not defined - setup it first" @@ -927,7 +927,7 @@ function vm_wait_for_boot() local vms_to_check="$VM_DIR/[0-9]*" else local vms_to_check="" - for vm in $@; do + for vm in "$@"; do vms_to_check+=" $VM_DIR/$vm" done fi @@ -992,7 +992,7 @@ function vm_start_fio_server() done shift $(( OPTIND - 1 )) - for vm_num in $@; do + for vm_num in "$@"; do notice "Starting fio server on VM$vm_num" if [[ $fio_bin != "" ]]; then cat $fio_bin | vm_exec $vm_num 'cat > /root/fio; chmod +x /root/fio' @@ -1056,7 +1056,7 @@ function run_fio() local vm local run_server_mode=true - for arg in $@; do + for arg in "$@"; do case "$arg" in --job-file=*) local job_file="${arg#*=}" ;; --fio-bin=*) local fio_bin="${arg#*=}" ;; @@ -1087,7 +1087,7 @@ function run_fio() local job_fname job_fname=$(basename "$job_file") # prepare job file for each VM - for vm in ${vms[@]}; do + for vm in "${vms[@]}"; do local vm_num=${vm%%:*} local vmdisks=${vm#*:} diff --git a/test/vhost/fiotest/fio.sh b/test/vhost/fiotest/fio.sh index 4f9e0854d..2cf75a0f5 100755 --- a/test/vhost/fiotest/fio.sh +++ b/test/vhost/fiotest/fio.sh @@ -96,7 +96,7 @@ notice "" rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock" -for vm_conf in ${vms[@]}; do +for vm_conf in "${vms[@]}"; do IFS=',' read -ra conf <<< "$vm_conf" if [[ x"${conf[0]}" == x"" ]] || ! assert_number ${conf[0]}; then fail "invalid VM configuration syntax $vm_conf" @@ -155,7 +155,7 @@ vm_run $used_vms vm_wait_for_boot 300 $used_vms if [[ $test_type == "spdk_vhost_scsi" ]]; then - for vm_conf in ${vms[@]}; do + for vm_conf in "${vms[@]}"; do IFS=',' read -ra conf <<< "$vm_conf" while IFS=':' read -ra disks; do for disk in "${disks[@]}"; do @@ -232,7 +232,7 @@ if ! $no_shutdown; then sleep 2 if [[ $test_type =~ "spdk_vhost" ]]; then notice "Removing vhost devices & controllers via RPC ..." - for vm_conf in ${vms[@]}; do + for vm_conf in "${vms[@]}"; do IFS=',' read -ra conf <<< "$vm_conf" while IFS=':' read -ra disks; do diff --git a/test/vhost/hotplug/common.sh b/test/vhost/hotplug/common.sh index 85bd822b9..1619ebba8 100644 --- a/test/vhost/hotplug/common.sh +++ b/test/vhost/hotplug/common.sh @@ -82,7 +82,7 @@ function print_test_fio_header() { } function vms_setup() { - for vm_conf in ${vms[@]}; do + for vm_conf in "${vms[@]}"; do IFS=',' read -ra conf <<< "$vm_conf" if [[ x"${conf[0]}" == x"" ]] || ! assert_number ${conf[0]}; then fail "invalid VM configuration syntax $vm_conf" @@ -105,13 +105,13 @@ function vms_setup() { } function vm_run_with_arg() { - vm_run $@ - vm_wait_for_boot 300 $@ + vm_run "$@" + vm_wait_for_boot 300 "$@" } function vms_setup_and_run() { vms_setup - vm_run_with_arg $@ + vm_run_with_arg "$@" } function vms_prepare() {