From 742f04b3f751fa29dbbfc98409b1ad521b9a8ebb Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Thu, 24 Jun 2021 17:05:38 +0200 Subject: [PATCH] check_format: Fixes for shellcheck's SC2251 directive SC2251: This ! is not on a condition and skips errexit. Use && exit 1 instead, or make sure $? is checked. This is critical since our test suites heavily depend on errexit to catch all abnormal conditions. Replace ! foo ... with a call to NOT() wherever possible. For the test/ocf pieces, use [[ ]] instead to define the condition for the existance of the ocf bdev. Signed-off-by: Michal Berger Change-Id: Ied3f99b9f1dc0594e4aef64fc21e51498f19ac23 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8504 Tested-by: SPDK CI Jenkins Reviewed-by: Karol Latecki Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- test/iscsi_tgt/rpc_config/rpc_config.sh | 4 ++-- test/nvmf/target/rpc.sh | 4 ++-- test/ocf/management/remove.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/iscsi_tgt/rpc_config/rpc_config.sh b/test/iscsi_tgt/rpc_config/rpc_config.sh index 1d27c7867..f35ff419d 100755 --- a/test/iscsi_tgt/rpc_config/rpc_config.sh +++ b/test/iscsi_tgt/rpc_config/rpc_config.sh @@ -32,13 +32,13 @@ $rpc_py framework_start_init echo "iscsi_tgt is listening. Running tests..." # RPC framework_wait_init should be already returned, so its process must be non-existed -! ps $rpc_wait_pid +NOT ps $rpc_wait_pid # RPC framework_wait_init will directly returned after subsystem initialized. $rpc_py framework_wait_init & rpc_wait_pid=$! sleep 1 -! ps $rpc_wait_pid +NOT ps $rpc_wait_pid timing_exit start_iscsi_tgt diff --git a/test/nvmf/target/rpc.sh b/test/nvmf/target/rpc.sh index d715e4b4f..0c2be78d0 100755 --- a/test/nvmf/target/rpc.sh +++ b/test/nvmf/target/rpc.sh @@ -59,7 +59,7 @@ $rpc_py nvmf_subsystem_allow_any_host -d nqn.2016-06.io.spdk:cnode1 $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT # This connect should fail - the host NQN is not allowed -! nvme connect -t $TEST_TRANSPORT -n nqn.2016-06.io.spdk:cnode1 -q nqn.2016-06.io.spdk:host1 -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" +NOT nvme connect -t $TEST_TRANSPORT -n nqn.2016-06.io.spdk:cnode1 -q nqn.2016-06.io.spdk:host1 -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" # Add the host NQN and verify that the connect succeeds $rpc_py nvmf_subsystem_add_host nqn.2016-06.io.spdk:cnode1 nqn.2016-06.io.spdk:host1 @@ -69,7 +69,7 @@ nvme disconnect -n nqn.2016-06.io.spdk:cnode1 # Remove the host and verify that the connect fails $rpc_py nvmf_subsystem_remove_host nqn.2016-06.io.spdk:cnode1 nqn.2016-06.io.spdk:host1 -! nvme connect -t $TEST_TRANSPORT -n nqn.2016-06.io.spdk:cnode1 -q nqn.2016-06.io.spdk:host1 -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" +NOT nvme connect -t $TEST_TRANSPORT -n nqn.2016-06.io.spdk:cnode1 -q nqn.2016-06.io.spdk:host1 -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" # Allow any host and verify that the connect succeeds $rpc_py nvmf_subsystem_allow_any_host -e nqn.2016-06.io.spdk:cnode1 diff --git a/test/ocf/management/remove.sh b/test/ocf/management/remove.sh index c06234080..b07f1a0ab 100755 --- a/test/ocf/management/remove.sh +++ b/test/ocf/management/remove.sh @@ -60,7 +60,7 @@ $rpc_py bdev_ocf_delete ocfWT # Check that ocfWT was deleted properly -! $rpc_py bdev_ocf_get_bdevs | jq -r '.[] .name' | grep -qw ocfWT +[[ -z $("$rpc_py" bdev_ocf_get_bdevs | jq -r '.[] | select(.name == "ocfWT") | .name') ]] trap - SIGINT SIGTERM EXIT @@ -76,7 +76,7 @@ waitforlisten $spdk_pid # Check that ocfWT was not loaded on app start -! $rpc_py bdev_ocf_get_bdevs | jq -r '.[] .name' | grep -qw ocfWT +[[ -z $("$rpc_py" bdev_ocf_get_bdevs | jq -r '.[] | select(name == "ocfWT") | .name') ]] trap - SIGINT SIGTERM EXIT