test/common: add NOT() utility function

Change-Id: Idde98fbbf7ff1f66caf4e46d217baf62b78a2e2a
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1152
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Darek Stojaczyk 2020-03-05 13:12:55 +01:00 committed by Tomasz Zawadzki
parent 52330a6b60
commit c29329fe21
2 changed files with 10 additions and 3 deletions

View File

@ -378,6 +378,13 @@ function rpc_cmd_simple_data_json() {
(( ${#jq_out[@]} > 0 )) || return 1
}
# invert error code of any command and also trigger ERR on 0 (unlike bash ! prefix)
function NOT() {
if "$@"; then
return 1
fi
}
function timing() {
direction="$1"
testname="$2"

View File

@ -17,7 +17,7 @@ function test_construct_lvs() {
# try to destroy inexistent lvs, this should obviously fail
dummy_uuid="00000000-0000-0000-0000-000000000000"
rpc_cmd bdev_lvol_delete_lvstore -u "$dummy_uuid" && false
NOT rpc_cmd bdev_lvol_delete_lvstore -u "$dummy_uuid"
# our lvs should not be impacted
rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid"
@ -35,9 +35,9 @@ function test_construct_lvs() {
# remove the lvs and verify it's gone
rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid"
rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid" && false
NOT rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid"
# make sure we can't delete the same lvs again
rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid" && false
NOT rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid"
rpc_cmd bdev_malloc_delete "$malloc_name"
check_leftover_devices