scripts: use -n instead of ! -z

Changing according to styling check done by ShellCheck.
Removing from check_format.sh exclusion list:
SC2236 - Use -n instead of ! -z
SC2070 - -n doesn't work with unquoted arguments. Quote or use [[ ]]

Change-Id: Ia9d645b9d0ce31b67c4de682395cf36f4ddc8d1f
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463180
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Karol Latecki 2019-07-25 15:01:09 +02:00 committed by Jim Harris
parent 73c7452835
commit 1ccc878e7f
35 changed files with 69 additions and 69 deletions

View File

@ -209,7 +209,7 @@ elif hash pep8 2>/dev/null; then
PEP8=pep8 PEP8=pep8
fi fi
if [ ! -z ${PEP8} ]; then if [ -n "${PEP8}" ]; then
echo -n "Checking Python style..." echo -n "Checking Python style..."
PEP8_ARGS+=" --max-line-length=140" PEP8_ARGS+=" --max-line-length=140"
@ -243,11 +243,11 @@ if hash shellcheck 2>/dev/null; then
SC1083,SC1087,SC1090,SC1091,SC1113,SC2001,SC2002,SC2003,SC2004,SC2005,\ SC1083,SC1087,SC1090,SC1091,SC1113,SC2001,SC2002,SC2003,SC2004,SC2005,\
SC2007,SC2009,SC2010,SC2012,SC2013,SC2015,SC2016,SC2018,SC2019,SC2022,SC2026,\ SC2007,SC2009,SC2010,SC2012,SC2013,SC2015,SC2016,SC2018,SC2019,SC2022,SC2026,\
SC2027,SC2030,SC2031,SC2034,SC2035,SC2039,SC2043,SC2044,SC2045,SC2046,SC2048,\ SC2027,SC2030,SC2031,SC2034,SC2035,SC2039,SC2043,SC2044,SC2045,SC2046,SC2048,\
SC2059,SC2064,SC2068,SC2070,SC2074,SC2086,SC2088,SC2089,SC2090,SC2091,SC2094,\ SC2059,SC2064,SC2068,SC2074,SC2086,SC2088,SC2089,SC2090,SC2091,SC2094,\
SC2097,SC2098,SC2103,SC2115,SC2116,SC2119,SC2120,SC2121,SC2124,SC2126,SC2128,\ SC2097,SC2098,SC2103,SC2115,SC2116,SC2119,SC2120,SC2121,SC2124,SC2126,SC2128,\
SC2129,SC2140,SC2142,SC2143,SC2145,SC2146,SC2148,SC2152,SC2153,SC2154,SC2155,\ SC2129,SC2140,SC2142,SC2143,SC2145,SC2146,SC2148,SC2152,SC2153,SC2154,SC2155,\
SC2162,SC2164,SC2165,SC2166,SC2167,SC2174,SC2178,SC2181,SC2191,SC2192,SC2195,\ SC2162,SC2164,SC2165,SC2166,SC2167,SC2174,SC2178,SC2181,SC2191,SC2192,SC2195,\
SC2199,SC2206,SC2207,SC2209,SC2214,SC2219,SC2220,SC2223,SC2230,SC2231,SC2233,SC2235,SC2236" SC2199,SC2206,SC2207,SC2209,SC2214,SC2219,SC2220,SC2223,SC2230,SC2231,SC2233,SC2235"
SHCK_FORMAT="diff" SHCK_FORMAT="diff"
SHCK_APPLY=true SHCK_APPLY=true

View File

@ -120,7 +120,7 @@ if [ "$LTO" = "y" ]; then
fi fi
fi fi
if [ ! -z "$CROSS_PREFIX" ]; then if [ -n "$CROSS_PREFIX" ]; then
expected_prefix=$($CC -dumpmachine) expected_prefix=$($CC -dumpmachine)
if [ ! "$expected_prefix" = "$CROSS_PREFIX" ]; then if [ ! "$expected_prefix" = "$CROSS_PREFIX" ]; then
@ -182,6 +182,6 @@ echo "CCAR=$CCAR"
echo "CC_TYPE=$CC_TYPE" echo "CC_TYPE=$CC_TYPE"
echo "LD_TYPE=$LD_TYPE" echo "LD_TYPE=$LD_TYPE"
if [ ! -z "$CROSS_PREFIX" ]; then if [ -n "$CROSS_PREFIX" ]; then
echo "CROSS_PREFIX=$CROSS_PREFIX" echo "CROSS_PREFIX=$CROSS_PREFIX"
fi fi

View File

@ -18,7 +18,7 @@ if [ ${#qat_pci_bdfs[@]} -eq 0 ]; then
exit 0 exit 0
fi fi
if [ ! -z $1 ]; then if [ -n "$1" ]; then
driver_to_bind=$1 driver_to_bind=$1
fi fi

View File

@ -13,7 +13,7 @@ function usage()
options="[config|reset|help]" options="[config|reset|help]"
fi fi
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Helper script for allocating hugepages and binding NVMe, I/OAT, VMD and Virtio devices" echo "Helper script for allocating hugepages and binding NVMe, I/OAT, VMD and Virtio devices"
echo "to a generic VFIO kernel driver. If VFIO is not available on the system, this script" echo "to a generic VFIO kernel driver. If VFIO is not available on the system, this script"
echo "will fall back to UIO. NVMe and Virtio devices with active mountpoints will be ignored." echo "will fall back to UIO. NVMe and Virtio devices with active mountpoints will be ignored."

View File

@ -15,7 +15,7 @@ mkdir -vp "${VAGRANT_TARGET}/${VAGRANT_DISTRO}"
cp "${testdir}/Vagrantfile_openstack_vm" "${VAGRANT_TARGET}/${VAGRANT_DISTRO}/Vagrantfile" cp "${testdir}/Vagrantfile_openstack_vm" "${VAGRANT_TARGET}/${VAGRANT_DISTRO}/Vagrantfile"
pushd "${VAGRANT_TARGET}/${VAGRANT_DISTRO}" pushd "${VAGRANT_TARGET}/${VAGRANT_DISTRO}"
if [ ! -z "${http_proxy}" ]; then if [ -n "${http_proxy}" ]; then
export http_proxy export http_proxy
fi fi

View File

@ -207,7 +207,7 @@ if [ ${DRY_RUN} != 1 ]; then
mkdir -vp "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}-${SPDK_VAGRANT_PROVIDER}" mkdir -vp "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}-${SPDK_VAGRANT_PROVIDER}"
cp ${DIR}/Vagrantfile ${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}-${SPDK_VAGRANT_PROVIDER} cp ${DIR}/Vagrantfile ${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}-${SPDK_VAGRANT_PROVIDER}
pushd "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}-${SPDK_VAGRANT_PROVIDER}" pushd "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}-${SPDK_VAGRANT_PROVIDER}"
if [ ! -z "${http_proxy}" ]; then if [ -n "${http_proxy}" ]; then
export http_proxy export http_proxy
export https_proxy export https_proxy
if vagrant plugin list | grep -q vagrant-proxyconf; then if vagrant plugin list | grep -q vagrant-proxyconf; then

View File

@ -100,7 +100,7 @@ fi
export SPDK_VAGRANT_SSH_KEY="${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/ssh_keys/spdk_vhost_id_rsa" export SPDK_VAGRANT_SSH_KEY="${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/ssh_keys/spdk_vhost_id_rsa"
pushd "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}" pushd "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}"
if [ ! -z "${http_proxy}" ]; then if [ -n "${http_proxy}" ]; then
export http_proxy export http_proxy
export https_proxy export https_proxy
if vagrant plugin list | grep -q vagrant-proxyconf; then if vagrant plugin list | grep -q vagrant-proxyconf; then

View File

@ -49,7 +49,7 @@ function raid_unmap_data_verify() {
} }
function on_error_exit() { function on_error_exit() {
if [ ! -z $raid_pid ]; then if [ -n "$raid_pid" ]; then
killprocess $raid_pid killprocess $raid_pid
fi fi

View File

@ -14,7 +14,7 @@ base_bdev2=$2
echo echo
echo "[crypto]" echo "[crypto]"
if [ -n $base_bdev ]; then if [ -n "$base_bdev" ]; then
if [ $(lspci -d:37c8 | wc -l) -eq 0 ]; then if [ $(lspci -d:37c8 | wc -l) -eq 0 ]; then
echo " CRY $base_bdev crypto_ram 0123456789123456 crypto_aesni_mb" echo " CRY $base_bdev crypto_ram 0123456789123456 crypto_aesni_mb"
else else
@ -22,6 +22,6 @@ if [ -n $base_bdev ]; then
fi fi
fi fi
if [ -n $base_bdev2 ]; then if [ -n "$base_bdev2" ]; then
echo " CRY $base_bdev2 crypto_ram2 9012345678912345 crypto_aesni_mb" echo " CRY $base_bdev2 crypto_ram2 9012345678912345 crypto_aesni_mb"
fi fi

View File

@ -213,7 +213,7 @@ fi
# By default, --with-dpdk is not set meaning the SPDK build will use the DPDK submodule. # By default, --with-dpdk is not set meaning the SPDK build will use the DPDK submodule.
# If a DPDK installation is found in a well-known location though, WITH_DPDK_DIR will be # If a DPDK installation is found in a well-known location though, WITH_DPDK_DIR will be
# set which will override the default and use that DPDK installation instead. # set which will override the default and use that DPDK installation instead.
if [ ! -z "$WITH_DPDK_DIR" ]; then if [ -n "$WITH_DPDK_DIR" ]; then
config_params+=" --with-dpdk=$WITH_DPDK_DIR" config_params+=" --with-dpdk=$WITH_DPDK_DIR"
fi fi
@ -306,7 +306,7 @@ function process_core() {
exe=$(eu-readelf -n "$core" | grep -oP -m1 "$exe.+") exe=$(eu-readelf -n "$core" | grep -oP -m1 "$exe.+")
fi fi
echo "exe for $core is $exe" echo "exe for $core is $exe"
if [[ ! -z "$exe" ]]; then if [[ -n "$exe" ]]; then
if hash gdb &>/dev/null; then if hash gdb &>/dev/null; then
gdb -batch -ex "thread apply all bt full" $exe $core gdb -batch -ex "thread apply all bt full" $exe $core
fi fi
@ -816,7 +816,7 @@ function freebsd_update_contigmem_mod()
{ {
if [ $(uname) = FreeBSD ]; then if [ $(uname) = FreeBSD ]; then
kldunload contigmem.ko || true kldunload contigmem.ko || true
if [ ! -z "$WITH_DPDK_DIR" ]; then if [ -n "$WITH_DPDK_DIR" ]; then
echo "Warning: SPDK only works on FreeBSD with patches that only exist in SPDK's dpdk submodule" echo "Warning: SPDK only works on FreeBSD with patches that only exist in SPDK's dpdk submodule"
cp -f "$WITH_DPDK_DIR/kmod/contigmem.ko" /boot/modules/ cp -f "$WITH_DPDK_DIR/kmod/contigmem.ko" /boot/modules/
cp -f "$WITH_DPDK_DIR/kmod/contigmem.ko" /boot/kernel/ cp -f "$WITH_DPDK_DIR/kmod/contigmem.ko" /boot/kernel/

View File

@ -354,7 +354,7 @@ while getopts 'iuht:c:-:' optchar; do
esac esac
done done
if [ ! -z "$CONF_PATH" ]; then if [ -n "$CONF_PATH" ]; then
if [ ! -f "$CONF_PATH" ]; then if [ ! -f "$CONF_PATH" ]; then
echo Configuration file does not exist: "$CONF_PATH" echo Configuration file does not exist: "$CONF_PATH"
exit 1 exit 1

View File

@ -66,7 +66,7 @@ function cleanup_veth_interfaces() {
function iscsitestinit() { function iscsitestinit() {
if [ "$1" == "iso" ]; then if [ "$1" == "iso" ]; then
$rootdir/scripts/setup.sh $rootdir/scripts/setup.sh
if [ ! -z "$2" ]; then if [ -n "$2" ]; then
create_veth_interfaces $2 create_veth_interfaces $2
else else
# default to posix # default to posix
@ -92,7 +92,7 @@ function waitforiscsidevices() {
function iscsitestfini() { function iscsitestfini() {
if [ "$1" == "iso" ]; then if [ "$1" == "iso" ]; then
if [ ! -z "$2" ]; then if [ -n "$2" ]; then
cleanup_veth_interfaces $2 cleanup_veth_interfaces $2
else else
# default to posix # default to posix

View File

@ -22,7 +22,7 @@ ISCSI_TGT_CM=0x02
# Performance test for iscsi_tgt, run on devices with proper hardware support (target and inititator) # Performance test for iscsi_tgt, run on devices with proper hardware support (target and inititator)
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Usage: $(basename $1) [options]" echo "Usage: $(basename $1) [options]"
echo "-h, --help Print help and exit" echo "-h, --help Print help and exit"
echo " --fiopath=PATH Path to fio directory on initiator. [default=$FIO_PATH]" echo " --fiopath=PATH Path to fio directory on initiator. [default=$FIO_PATH]"

View File

@ -104,7 +104,7 @@ function json_config_test_start_app() {
local app=$1 local app=$1
shift shift
[[ ! -z "${#app_socket[$app]}" ]] # Check app type [[ -n "${#app_socket[$app]}" ]] # Check app type
[[ -z "${app_pid[$app]}" ]] # Assert if app is not running [[ -z "${app_pid[$app]}" ]] # Assert if app is not running
local app_extra_params="" local app_extra_params=""
@ -126,8 +126,8 @@ function json_config_test_shutdown_app() {
local app=$1 local app=$1
# Check app type && assert app was started # Check app type && assert app was started
[[ ! -z "${#app_socket[$app]}" ]] [[ -n "${#app_socket[$app]}" ]]
[[ ! -z "${app_pid[$app]}" ]] [[ -n "${app_pid[$app]}" ]]
# kill_instance RPC will trigger ASAN # kill_instance RPC will trigger ASAN
kill -SIGINT ${app_pid[$app]} kill -SIGINT ${app_pid[$app]}
@ -140,7 +140,7 @@ function json_config_test_shutdown_app() {
sleep 0.5 sleep 0.5
done done
if [[ ! -z "${app_pid[$app]}" ]]; then if [[ -n "${app_pid[$app]}" ]]; then
echo "SPDK $app shutdown timeout" echo "SPDK $app shutdown timeout"
return 1 return 1
fi fi
@ -262,7 +262,7 @@ function cleanup_bdev_subsystem_config() {
rm -f /tmp/sample_aio rm -f /tmp/sample_aio
fi fi
if [[ $SPDK_TEST_PMDK -eq 1 && ! -z "$pmem_pool_file" && -f "$pmem_pool_file" ]]; then if [[ $SPDK_TEST_PMDK -eq 1 && -n "$pmem_pool_file" && -f "$pmem_pool_file" ]]; then
tgt_rpc delete_pmem_bdev pmem1 tgt_rpc delete_pmem_bdev pmem1
tgt_rpc delete_pmem_pool $pmem_pool_file tgt_rpc delete_pmem_pool $pmem_pool_file
rm -f $pmem_pool_file rm -f $pmem_pool_file
@ -384,7 +384,7 @@ function json_config_test_fini() {
timing_enter $FUNCNAME timing_enter $FUNCNAME
local ret=0 local ret=0
if [[ ! -z "${app_pid[initiator]}" ]]; then if [[ -n "${app_pid[initiator]}" ]]; then
if ! json_config_test_shutdown_app initiator; then if ! json_config_test_shutdown_app initiator; then
kill -9 ${app_pid[initiator]} kill -9 ${app_pid[initiator]}
app_pid[initiator]= app_pid[initiator]=
@ -392,7 +392,7 @@ function json_config_test_fini() {
fi fi
fi fi
if [[ ! -z "${app_pid[target]}" ]]; then if [[ -n "${app_pid[target]}" ]]; then
# Remove any artifacts we created (files, lvol etc) # Remove any artifacts we created (files, lvol etc)
cleanup_bdev_subsystem_config cleanup_bdev_subsystem_config
@ -412,7 +412,7 @@ function json_config_test_fini() {
} }
function json_config_clear() { function json_config_clear() {
[[ ! -z "${#app_socket[$1]}" ]] # Check app type [[ -n "${#app_socket[$1]}" ]] # Check app type
$rootdir/test/json_config/clear_config.py -s ${app_socket[$1]} clear_config $rootdir/test/json_config/clear_config.py -s ${app_socket[$1]} clear_config
# Check if config is clean. # Check if config is clean.

View File

@ -12,7 +12,7 @@ x=""
rpc_py="$rootdir/scripts/rpc.py " rpc_py="$rootdir/scripts/rpc.py "
function usage() { function usage() {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Shortcut script for doing automated lvol tests" echo "Shortcut script for doing automated lvol tests"
echo "Usage: $(basename $1) [OPTIONS]" echo "Usage: $(basename $1) [OPTIONS]"
echo echo

View File

@ -304,7 +304,7 @@ function run_bdevperf(){
function usage() function usage()
{ {
set +x set +x
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Run NVMe PMD/BDEV performance test. Change options for easier debug and setup configuration" echo "Run NVMe PMD/BDEV performance test. Change options for easier debug and setup configuration"
echo "Usage: $(basename $1) [options]" echo "Usage: $(basename $1) [options]"
echo "-h, --help Print help and exit" echo "-h, --help Print help and exit"

View File

@ -39,7 +39,7 @@ else
fi fi
echo "test case2: host connect to nvmf target in multiple paths" echo "test case2: host connect to nvmf target in multiple paths"
if [ ! -z $NVMF_SECOND_TARGET_IP ]; then if [ -n "$NVMF_SECOND_TARGET_IP" ]; then
$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_SECOND_TARGET_IP -s $NVMF_PORT $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_SECOND_TARGET_IP -s $NVMF_PORT
nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"

View File

@ -21,7 +21,7 @@ bdev_name=pmem0
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Shortcut script for automated RPC tests for PMEM" echo "Shortcut script for automated RPC tests for PMEM"
echo "For test details, check test_plan.md or" echo "For test details, check test_plan.md or"
echo "https://review.gerrithub.io/#/c/378618/18/test/pmem/test_plan.md" echo "https://review.gerrithub.io/#/c/378618/18/test/pmem/test_plan.md"

View File

@ -3,16 +3,16 @@ spdk_clear_config_py="$rootdir/test/json_config/clear_config.py"
function on_error_exit() { function on_error_exit() {
set +e set +e
if [ ! -z $spdk_tgt_pid ]; then if [ -n "$spdk_tgt_pid" ]; then
killprocess $spdk_tgt_pid killprocess $spdk_tgt_pid
fi fi
if [ ! -z $nvmf_tgt_pid ]; then if [ -n "$nvmf_tgt_pid" ]; then
killprocess $nvmf_tgt_pid killprocess $nvmf_tgt_pid
fi fi
if [ ! -z $iscsi_tgt_pid ]; then if [ -n "$iscsi_tgt_pid" ]; then
killprocess $iscsi_tgt_pid killprocess $iscsi_tgt_pid
fi fi
if [ ! -z $vhost_tgt_pid ]; then if [ -n "$vhost_tgt_pid" ]; then
killprocess $vhost_tgt_pid killprocess $vhost_tgt_pid
fi fi
rm -f $testdir/${MATCH_FILE} $testdir/match_files/spdkcli_details_vhost.test /tmp/sample_aio /tmp/sample_pmem rm -f $testdir/${MATCH_FILE} $testdir/match_files/spdkcli_details_vhost.test /tmp/sample_aio /tmp/sample_pmem

View File

@ -23,11 +23,11 @@ $spdkcli_job "'/bdevs/malloc create 32 512 Malloc0' 'Malloc0' True
'/bdevs/malloc create 32 512 Malloc1' 'Malloc1' True '/bdevs/malloc create 32 512 Malloc1' 'Malloc1' True
" "
pci_blk=$(lspci -nn -D | grep '1af4:1001' | head -1 | awk '{print $1;}') pci_blk=$(lspci -nn -D | grep '1af4:1001' | head -1 | awk '{print $1;}')
if [ ! -z $pci_blk ]; then if [ -n "$pci_blk" ]; then
$spdkcli_job "'/bdevs/virtioblk_disk create virtioblk_pci pci $pci_blk' 'virtioblk_pci' True" $spdkcli_job "'/bdevs/virtioblk_disk create virtioblk_pci pci $pci_blk' 'virtioblk_pci' True"
fi fi
pci_scsi=$(lspci -nn -D | grep '1af4:1004' | head -1 | awk '{print $1;}') pci_scsi=$(lspci -nn -D | grep '1af4:1004' | head -1 | awk '{print $1;}')
if [ ! -z $pci_scsi ]; then if [ -n "$pci_scsi" ]; then
$spdkcli_job "'/bdevs/virtioscsi_disk create virtioscsi_pci pci $pci_scsi' 'virtioscsi_pci' True" $spdkcli_job "'/bdevs/virtioscsi_disk create virtioscsi_pci pci $pci_scsi' 'virtioscsi_pci' True"
fi fi
$spdkcli_job "'/vhost/scsi create sample_scsi' 'sample_scsi' True $spdkcli_job "'/vhost/scsi create sample_scsi' 'sample_scsi' True
@ -37,7 +37,7 @@ $spdkcli_job "'/vhost/scsi create sample_scsi' 'sample_scsi' True
timing_exit spdkcli_create_virtio_pci_config timing_exit spdkcli_create_virtio_pci_config
timing_enter spdkcli_check_match timing_enter spdkcli_check_match
if [ ! -z $pci_blk ] && [ ! -z $pci_scsi ]; then if [ -n "$pci_blk" ] && [ -n "$pci_scsi" ]; then
MATCH_FILE="spdkcli_virtio_pci.test" MATCH_FILE="spdkcli_virtio_pci.test"
SPDKCLI_BRANCH="/bdevs" SPDKCLI_BRANCH="/bdevs"
check_match check_match
@ -64,10 +64,10 @@ $spdkcli_job "'/vhost/block delete sample_block' 'sample_block'
'/vhost/scsi/sample_scsi remove_target 0' 'Malloc0' '/vhost/scsi/sample_scsi remove_target 0' 'Malloc0'
'/vhost/scsi delete sample_scsi' 'sample_scsi' '/vhost/scsi delete sample_scsi' 'sample_scsi'
" "
if [ ! -z $pci_blk ]; then if [ -n "$pci_blk" ]; then
$spdkcli_job "'/bdevs/virtioblk_disk delete virtioblk_pci' 'virtioblk_pci'" $spdkcli_job "'/bdevs/virtioblk_disk delete virtioblk_pci' 'virtioblk_pci'"
fi fi
if [ ! -z $pci_scsi ]; then if [ -n "$pci_scsi" ]; then
$spdkcli_job "'/bdevs/virtioscsi_disk delete virtioscsi_pci' 'virtioscsi_pci'" $spdkcli_job "'/bdevs/virtioscsi_disk delete virtioscsi_pci' 'virtioscsi_pci'"
fi fi
$spdkcli_job "'/bdevs/malloc delete Malloc0' 'Malloc0' $spdkcli_job "'/bdevs/malloc delete Malloc0' 'Malloc0'

View File

@ -438,7 +438,7 @@ function vm_kill()
function vm_list_all() function vm_list_all()
{ {
local vms="$(shopt -s nullglob; echo $VM_DIR/[0-9]*)" local vms="$(shopt -s nullglob; echo $VM_DIR/[0-9]*)"
if [[ ! -z "$vms" ]]; then if [[ -n "$vms" ]]; then
basename --multiple $vms basename --multiple $vms
fi fi
} }
@ -547,7 +547,7 @@ function vm_setup()
done done
# Find next directory we can use # Find next directory we can use
if [[ ! -z $force_vm ]]; then if [[ -n $force_vm ]]; then
vm_num=$force_vm vm_num=$force_vm
vm_num_is_valid $vm_num || return 1 vm_num_is_valid $vm_num || return 1
@ -571,18 +571,18 @@ function vm_setup()
return 1 return 1
fi fi
if [[ ! -z "$vm_migrate_to" && ! -z "$vm_incoming" ]]; then if [[ -n "$vm_migrate_to" && -n "$vm_incoming" ]]; then
error "'--incoming' and '--migrate-to' cannot be used together" error "'--incoming' and '--migrate-to' cannot be used together"
return 1 return 1
elif [[ ! -z "$vm_incoming" ]]; then elif [[ -n "$vm_incoming" ]]; then
if [[ ! -z "$os_mode" || ! -z "$os_img" ]]; then if [[ -n "$os_mode" || -n "$os_img" ]]; then
error "'--incoming' can't be used together with '--os' nor '--os-mode'" error "'--incoming' can't be used together with '--os' nor '--os-mode'"
return 1 return 1
fi fi
os_mode="original" os_mode="original"
os="$VM_DIR/$vm_incoming/os.qcow2" os="$VM_DIR/$vm_incoming/os.qcow2"
elif [[ ! -z "$vm_migrate_to" ]]; then elif [[ -n "$vm_migrate_to" ]]; then
[[ "$os_mode" != "backing" ]] && warning "Using 'backing' mode for OS since '--migrate-to' is used" [[ "$os_mode" != "backing" ]] && warning "Using 'backing' mode for OS since '--migrate-to' is used"
os_mode=backing os_mode=backing
fi fi
@ -666,7 +666,7 @@ function vm_setup()
cmd+="-m $guest_memory --enable-kvm -cpu host -smp $cpu_num -vga std -vnc :$vnc_socket -daemonize ${eol}" cmd+="-m $guest_memory --enable-kvm -cpu host -smp $cpu_num -vga std -vnc :$vnc_socket -daemonize ${eol}"
cmd+="-object memory-backend-file,id=mem,size=${guest_memory}M,mem-path=/dev/hugepages,share=on,prealloc=yes,host-nodes=$node_num,policy=bind ${eol}" cmd+="-object memory-backend-file,id=mem,size=${guest_memory}M,mem-path=/dev/hugepages,share=on,prealloc=yes,host-nodes=$node_num,policy=bind ${eol}"
[[ $os_mode == snapshot ]] && cmd+="-snapshot ${eol}" [[ $os_mode == snapshot ]] && cmd+="-snapshot ${eol}"
[[ ! -z "$vm_incoming" ]] && cmd+=" -incoming tcp:0:$migration_port ${eol}" [[ -n "$vm_incoming" ]] && cmd+=" -incoming tcp:0:$migration_port ${eol}"
cmd+="-monitor telnet:127.0.0.1:$monitor_port,server,nowait ${eol}" cmd+="-monitor telnet:127.0.0.1:$monitor_port,server,nowait ${eol}"
cmd+="-numa node,memdev=mem ${eol}" cmd+="-numa node,memdev=mem ${eol}"
cmd+="-pidfile $qemu_pid_file ${eol}" cmd+="-pidfile $qemu_pid_file ${eol}"
@ -697,7 +697,7 @@ function vm_setup()
local raw_name="RAWSCSI" local raw_name="RAWSCSI"
local raw_disk=$vm_dir/test.img local raw_disk=$vm_dir/test.img
if [[ ! -z $disk ]]; then if [[ -n $disk ]]; then
[[ ! -b $disk ]] && touch $disk [[ ! -b $disk ]] && touch $disk
local raw_disk=$(readlink -f $disk) local raw_disk=$(readlink -f $disk)
fi fi
@ -764,7 +764,7 @@ function vm_setup()
return 1 return 1
fi fi
[[ ! -z $qemu_args ]] && cmd+=" $qemu_args ${eol}" [[ -n $qemu_args ]] && cmd+=" $qemu_args ${eol}"
# remove last $eol # remove last $eol
cmd="${cmd%\\\\\\n }" cmd="${cmd%\\\\\\n }"
@ -1046,7 +1046,7 @@ function run_fio()
esac esac
done done
if [[ ! -z "$fio_bin" && ! -r "$fio_bin" ]]; then if [[ -n "$fio_bin" && ! -r "$fio_bin" ]]; then
error "FIO binary '$fio_bin' does not exist" error "FIO binary '$fio_bin' does not exist"
return 1 return 1
fi fi
@ -1067,7 +1067,7 @@ function run_fio()
vm_exec $vm_num cat /root/$job_fname vm_exec $vm_num cat /root/$job_fname
if ! $run_server_mode; then if ! $run_server_mode; then
if [[ ! -z "$fio_bin" ]]; then if [[ -n "$fio_bin" ]]; then
cat $fio_bin | vm_exec $vm_num 'cat > /root/fio; chmod +x /root/fio' cat $fio_bin | vm_exec $vm_num 'cat > /root/fio; chmod +x /root/fio'
fi fi
@ -1083,7 +1083,7 @@ function run_fio()
fi fi
$rootdir/test/vhost/common/run_fio.py --job-file=/root/$job_fname \ $rootdir/test/vhost/common/run_fio.py --job-file=/root/$job_fname \
$([[ ! -z "$fio_bin" ]] && echo "--fio-bin=$fio_bin") \ $([[ -n "$fio_bin" ]] && echo "--fio-bin=$fio_bin") \
--out=$out $json ${fio_disks%,} --out=$out $json ${fio_disks%,}
} }

View File

@ -18,7 +18,7 @@ x=""
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Shortcut script for doing automated test" echo "Shortcut script for doing automated test"
echo "Usage: $(basename $1) [OPTIONS]" echo "Usage: $(basename $1) [OPTIONS]"
echo echo

View File

@ -18,7 +18,7 @@ blk_hot_remove_test=0
function usage() { function usage() {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Shortcut script for doing automated hotattach/hotdetach test" echo "Shortcut script for doing automated hotattach/hotdetach test"
echo "Usage: $(basename $1) [OPTIONS]" echo "Usage: $(basename $1) [OPTIONS]"
echo echo

View File

@ -12,7 +12,7 @@ virtio_with_unmap=""
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Script for running vhost initiator tests." echo "Script for running vhost initiator tests."
echo "Usage: $(basename $1) [-h|--help] [--fiobin=PATH]" echo "Usage: $(basename $1) [-h|--help] [--fiobin=PATH]"
echo "-h, --help Print help and exit" echo "-h, --help Print help and exit"

View File

@ -10,7 +10,7 @@ vm_fs="ext4"
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Shortcut script for doing automated test" echo "Shortcut script for doing automated test"
echo "Usage: $(basename $1) [OPTIONS]" echo "Usage: $(basename $1) [OPTIONS]"
echo echo

View File

@ -17,7 +17,7 @@ distribute_cores=false
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Shortcut script for doing automated test" echo "Shortcut script for doing automated test"
echo "Usage: $(basename $1) [OPTIONS]" echo "Usage: $(basename $1) [OPTIONS]"
echo echo

View File

@ -9,7 +9,7 @@ function migration_tc2_cleanup_nvmf_tgt()
return return
fi fi
if [[ ! -z "$1" ]]; then if [[ -n "$1" ]]; then
trap 'error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT trap 'error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT
pkill --signal $1 -F $nvmf_dir/nvmf_tgt.pid || true pkill --signal $1 -F $nvmf_dir/nvmf_tgt.pid || true
sleep 5 sleep 5

View File

@ -69,7 +69,7 @@ function check_rdma_connection()
function host1_cleanup_nvmf() function host1_cleanup_nvmf()
{ {
notice "Shutting down nvmf_tgt on local server" notice "Shutting down nvmf_tgt on local server"
if [[ ! -z "$1" ]]; then if [[ -n "$1" ]]; then
pkill --signal $1 -F $nvmf_dir/nvmf_tgt.pid pkill --signal $1 -F $nvmf_dir/nvmf_tgt.pid
else else
pkill -F $nvmf_dir/nvmf_tgt.pid pkill -F $nvmf_dir/nvmf_tgt.pid

View File

@ -20,7 +20,7 @@ RDMA_TARGET_IP=""
RDMA_INITIATOR_IP="" RDMA_INITIATOR_IP=""
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Shortcut script for doing automated test of live migration." echo "Shortcut script for doing automated test of live migration."
echo "Usage: $(basename $1) [OPTIONS]" echo "Usage: $(basename $1) [OPTIONS]"
echo echo
@ -58,7 +58,7 @@ done
vhosttestinit vhosttestinit
[[ ! -z "$test_cases" ]] || fail "Need '--test-cases=' parameter" [[ -n "$test_cases" ]] || fail "Need '--test-cases=' parameter"
trap 'error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT trap 'error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT
@ -69,7 +69,7 @@ function vm_monitor_send()
local vm_dir="$VM_DIR/$1" local vm_dir="$VM_DIR/$1"
local vm_monitor_port=$(cat $vm_dir/monitor_port) local vm_monitor_port=$(cat $vm_dir/monitor_port)
[[ ! -z "$vm_monitor_port" ]] || fail "No monitor port!" [[ -n "$vm_monitor_port" ]] || fail "No monitor port!"
shift 2 shift 2
nc 127.0.0.1 $vm_monitor_port "$@" > $cmd_result_file nc 127.0.0.1 $vm_monitor_port "$@" > $cmd_result_file

View File

@ -7,7 +7,7 @@ source $rootdir/test/vhost/common.sh
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Shortcut script for running vhost app." echo "Shortcut script for running vhost app."
echo "Usage: $(basename $1) [-x] [-h|--help] [--clean-build]" echo "Usage: $(basename $1) [-x] [-h|--help] [--clean-build]"
echo "-h, --help print help and exit" echo "-h, --help print help and exit"

View File

@ -28,7 +28,7 @@ precond_fio_bin="/usr/src/fio/fio"
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Shortcut script for doing automated test" echo "Shortcut script for doing automated test"
echo "Usage: $(basename $1) [OPTIONS]" echo "Usage: $(basename $1) [OPTIONS]"
echo echo

View File

@ -13,7 +13,7 @@ x=""
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Shortcut script for automated readonly test for vhost-block" echo "Shortcut script for automated readonly test for vhost-block"
echo "For test details check test_plan.md" echo "For test details check test_plan.md"
echo echo

View File

@ -27,7 +27,7 @@ function err_clean
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Usage: $(basename $1) vm_image=PATH [-h|--help]" echo "Usage: $(basename $1) vm_image=PATH [-h|--help]"
echo "-h, --help Print help and exit" echo "-h, --help Print help and exit"
echo " --vm_image=PATH Path to VM image used in these tests" echo " --vm_image=PATH Path to VM image used in these tests"

View File

@ -13,7 +13,7 @@ vm_image="/home/sys_sgsw/windows_server.qcow2"
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Windows Server automated test" echo "Windows Server automated test"
echo "Usage: $(basename $1) [OPTIONS]" echo "Usage: $(basename $1) [OPTIONS]"
echo "--vm-ssh-pass=PASSWORD Text password for the VM" echo "--vm-ssh-pass=PASSWORD Text password for the VM"

View File

@ -18,7 +18,7 @@ rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
function usage() function usage()
{ {
[[ ! -z $2 ]] && ( echo "$2"; echo ""; ) [[ -n $2 ]] && ( echo "$2"; echo ""; )
echo "Windows Server scsi compliance test" echo "Windows Server scsi compliance test"
echo "Usage: $(basename $1) [OPTIONS]" echo "Usage: $(basename $1) [OPTIONS]"
echo " --vm-ssh-pass=PASSWORD Text password for the VM" echo " --vm-ssh-pass=PASSWORD Text password for the VM"