test/bdev: improper check of mkfs.ext4 return

Before this fix, nbd_with_lvol_verify() would compare the string output
of mkfs.ext4 ("Dicarding device blocks...") with 0. If the shell does
not cast an invalid number to 0, test in the if statement will evaluate
to false.

The intent of the test in the if statement seems to be to check the exit
code from mkfs.ext4. This commit implements that assumed intent.
Additionally, mkfs_ret is now a local variable.

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: I6c0de7b3f70674fb442abbcc9164f65a1ad55d40
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15276
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Xinrui Mao <xinrui.mao@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Mike Gerdts 2022-11-03 23:48:28 -05:00 committed by Jim Harris
parent bf253bf6f0
commit c6ffad06fa

View File

@ -125,13 +125,15 @@ function nbd_rpc_start_stop_verify() {
function nbd_with_lvol_verify() {
local rpc_server=$1
local nbd_list=($2)
local mkfs_ret
$rootdir/scripts/rpc.py -s $rpc_server bdev_malloc_create -b malloc_lvol_verify 16 512
$rootdir/scripts/rpc.py -s $rpc_server bdev_lvol_create_lvstore malloc_lvol_verify lvs
$rootdir/scripts/rpc.py -s $rpc_server bdev_lvol_create lvol 4 -l lvs
$rootdir/scripts/rpc.py -s $rpc_server nbd_start_disk lvs/lvol "${nbd_list[0]}"
mkfs_ret=$(mkfs.ext4 ${nbd_list[0]})
mkfs.ext4 ${nbd_list[0]}
mkfs_ret=$?
nbd_stop_disks $rpc_server "${nbd_list[0]}"
if [ $mkfs_ret -ne 0 ]; then
return 1