test/vhost Add three negative tests for vhost_scsi_controller_add_target

Need one more malloc bdev.

Change-Id: I9884829e1683bfa0e9653f2edbb020d002b7b060
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1055
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Michal Berger <michalx.berger@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Pawel Kaminski 2020-02-28 05:23:22 -05:00 committed by Tomasz Zawadzki
parent dc3be4c8c1
commit 7b128ee46b

View File

@ -71,6 +71,8 @@ notice ""
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock" rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
$rpc_py bdev_malloc_create -b Malloc0 128 4096 $rpc_py bdev_malloc_create -b Malloc0 128 4096
$rpc_py bdev_malloc_create -b Malloc1 128 4096 $rpc_py bdev_malloc_create -b Malloc1 128 4096
$rpc_py bdev_malloc_create -b Malloc2 128 4096
$rpc_py bdev_split_create Malloc2 8
# Try to get nonexistent vhost controller # Try to get nonexistent vhost controller
if $rpc_py vhost_get_controllers -n nonexistent; then if $rpc_py vhost_get_controllers -n nonexistent; then
@ -122,9 +124,30 @@ if $rpc_py vhost_scsi_controller_add_target naa.0 0 nonexistent_bdev; then
error "Adding nonexistent device to scsi controller succeeded, but it shouldn't" error "Adding nonexistent device to scsi controller succeeded, but it shouldn't"
fi fi
notice "Adding device to naa.0 with slot number exceeding max"
if $rpc_py vhost_scsi_controller_add_target naa.0 8 Malloc0; then
error "Adding device to naa.0 should fail but succeeded"
fi
for i in $(seq 0 7); do
$rpc_py vhost_scsi_controller_add_target naa.0 -1 Malloc2p$i
done
notice "All slots are occupied. Try to add one more device to naa.0"
if $rpc_py vhost_scsi_controller_add_target naa.0 -1 Malloc0; then
error "Adding device to naa.0 should fail but succeeded"
fi
for i in $(seq 0 7); do
$rpc_py vhost_scsi_controller_remove_target naa.0 $i
done
notice "Adding initial device (0) to naa.0" notice "Adding initial device (0) to naa.0"
$rpc_py vhost_scsi_controller_add_target naa.0 0 Malloc0 $rpc_py vhost_scsi_controller_add_target naa.0 0 Malloc0
notice "Adding device to naa.0 with slot number 0"
if $rpc_py vhost_scsi_controller_add_target naa.0 0 Malloc1; then
error "Adding device to naa.0 occupied slot should fail but succeeded"
fi
notice "Trying to remove nonexistent device on existing controller" notice "Trying to remove nonexistent device on existing controller"
if $rpc_py vhost_scsi_controller_remove_target naa.0 1 > /dev/null; then if $rpc_py vhost_scsi_controller_remove_target naa.0 1 > /dev/null; then
error "Removing nonexistent device (1) from controller naa.0 succeeded, but it shouldn't" error "Removing nonexistent device (1) from controller naa.0 succeeded, but it shouldn't"