Commit 0af5182e authored by Karol Latecki's avatar Karol Latecki Committed by Jim Harris
Browse files

test/vhost: move negative tests to separate file



fiotest/autotest.sh is a I/O integrity test, so negative cases
should belond to a separate script file

Change-Id: Ie0728ce1eadba9687d1f40b3fdfb26c50ab34055
Signed-off-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/413643


Reviewed-by: default avatarPaweł Niedźwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 4404da7c
Loading
Loading
Loading
Loading
+1 −56
Original line number Diff line number Diff line
@@ -119,68 +119,13 @@ for vm_conf in ${vms[@]}; do
					notice "Creating vhost block controller naa.$disk.${conf[0]} with device $disk"
					$rpc_py construct_vhost_blk_controller naa.$disk.${conf[0]} $disk
				else
					notice "Trying to remove nonexistent controller"
					if $rpc_py remove_vhost_controller unk0 > /dev/null; then
						error "Removing nonexistent controller succeeded, but it shouldn't"
					fi
					notice "Creating controller naa.$disk.${conf[0]}"
					$rpc_py construct_vhost_scsi_controller naa.$disk.${conf[0]}

					notice "Adding initial device (0) to naa.$disk.${conf[0]}"
					$rpc_py add_vhost_scsi_lun naa.$disk.${conf[0]} 0 $disk

					notice "Trying to remove nonexistent device on existing controller"
					if $rpc_py remove_vhost_scsi_target naa.$disk.${conf[0]} 1 > /dev/null; then
						error "Removing nonexistent device (1) from controller naa.$disk.${conf[0]} succeeded, but it shouldn't"
					fi

					notice "Trying to remove existing device from a controller"
					$rpc_py remove_vhost_scsi_target naa.$disk.${conf[0]} 0

					notice "Trying to remove a just-deleted device from a controller again"
					if $rpc_py remove_vhost_scsi_target naa.$disk.${conf[0]} 0 > /dev/null; then
						error "Removing device 0 from controller naa.$disk.${conf[0]} succeeded, but it shouldn't"
					fi

					notice "Re-adding device 0 to naa.$disk.${conf[0]}"
					notice "Adding device (0) to naa.$disk.${conf[0]}"
					$rpc_py add_vhost_scsi_lun naa.$disk.${conf[0]} 0 $disk
				fi
			done

			notice "Trying to create scsi controller with incorrect cpumask"
			if $rpc_py construct_vhost_scsi_controller vhost.invalid.cpumask --cpumask 0x2; then
				error "Creating scsi controller with incorrect cpumask succeeded, but it shouldn't"
			fi

			notice "Trying to remove device from nonexistent scsi controller"
			if $rpc_py remove_vhost_scsi_target vhost.nonexistent.name 0; then
				error "Removing device from nonexistent scsi controller succeeded, but it shouldn't"
			fi

			notice "Trying to add device to nonexistent scsi controller"
			if $rpc_py add_vhost_scsi_lun vhost.nonexistent.name 0 Malloc0; then
				error "Adding device to nonexistent scsi controller succeeded, but it shouldn't"
			fi

			notice "Trying to create scsi controller with incorrect name"
			if $rpc_py construct_vhost_scsi_controller .; then
				error "Creating scsi controller with incorrect name succeeded, but it shouldn't"
			fi

			notice "Trying to create block controller with incorrect cpumask"
			if $rpc_py construct_vhost_blk_controller vhost.invalid.cpumask  Malloc0 --cpumask 0x2; then
				error "Creating block controller with incorrect cpumask succeeded, but it shouldn't"
			fi

			notice "Trying to remove nonexistent block controller"
			if $rpc_py remove_vhost_controller vhost.nonexistent.name; then
				error "Removing nonexistent block controller succeeded, but it shouldn't"
			fi

			notice "Trying to create block controller with incorrect name"
			if $rpc_py construct_vhost_blk_controller . Malloc0; then
				error "Creating block controller with incorrect name succeeded, but it shouldn't"
			fi
		done <<< "${conf[2]}"
		unset IFS;
		$rpc_py get_vhost_controllers
+43 −0
Original line number Diff line number Diff line
{
  "subsystems": [
    {
      "subsystem": "copy",
      "config": null
    },
    {
      "subsystem": "interface",
      "config": null
    },
    {
      "subsystem": "net_framework",
      "config": null
    },
    {
      "subsystem": "bdev",
      "config": [
        {
          "params": {
            "block_size": 4096,
            "num_blocks": 32768
          },
          "method": "construct_malloc_bdev"
        },
        {
          "params": {
            "block_size": 4096,
            "num_blocks": 32768
          },
          "method": "construct_malloc_bdev"
        }
      ]
    },
    {
      "subsystem": "nbd",
      "config": []
    },
    {
      "subsystem": "scsi",
      "config": null
    }
  ]
}
+84 −0
Original line number Diff line number Diff line
@@ -58,3 +58,87 @@ fi
if ! $VHOST_APP -t vhost_scsi -h;  then
	warning "vhost did not started with trace flags enabled but ignoring this as it might not be a debug build"
fi

if [[ $RUN_NIGHTLY -eq 1 ]]; then
	# Run with valid config and try some negative rpc calls
	notice "==============="
	notice ""
	notice "running SPDK"
	notice ""
	spdk_vhost_run --json-path=$NEGATIVE_BASE_DIR
	notice ""

	rpc_py="python $SPDK_BUILD_DIR/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"

	# General commands
	notice "Trying to remove nonexistent controller"
	if $rpc_py remove_vhost_controller unk0 > /dev/null; then
		error "Removing nonexistent controller succeeded, but it shouldn't"
	fi

	# SCSI
	notice "Trying to create scsi controller with incorrect cpumask"
	if $rpc_py construct_vhost_scsi_controller vhost.invalid.cpumask --cpumask 0x2; then
		error "Creating scsi controller with incorrect cpumask succeeded, but it shouldn't"
	fi

	notice "Trying to remove device from nonexistent scsi controller"
	if $rpc_py remove_vhost_scsi_target vhost.nonexistent.name 0; then
		error "Removing device from nonexistent scsi controller succeeded, but it shouldn't"
	fi

	notice "Trying to add device to nonexistent scsi controller"
	if $rpc_py add_vhost_scsi_lun vhost.nonexistent.name 0 Malloc0; then
		error "Adding device to nonexistent scsi controller succeeded, but it shouldn't"
	fi

	notice "Trying to create scsi controller with incorrect name"
	if $rpc_py construct_vhost_scsi_controller .; then
		error "Creating scsi controller with incorrect name succeeded, but it shouldn't"
	fi

	notice "Creating controller naa.0"
	$rpc_py construct_vhost_scsi_controller naa.0

	notice "Adding initial device (0) to naa.0"
	$rpc_py add_vhost_scsi_lun naa.0 0 Malloc0

	notice "Trying to remove nonexistent device on existing controller"
	if $rpc_py remove_vhost_scsi_target naa.0 1 > /dev/null; then
		error "Removing nonexistent device (1) from controller naa.0 succeeded, but it shouldn't"
	fi

	notice "Trying to remove existing device from a controller"
	$rpc_py remove_vhost_scsi_target naa.0 0

	notice "Trying to remove a just-deleted device from a controller again"
	if $rpc_py remove_vhost_scsi_target naa.0 0 > /dev/null; then
		error "Removing device 0 from controller naa.0 succeeded, but it shouldn't"
	fi

	notice "Re-adding device 0 to naa.0"
	$rpc_py add_vhost_scsi_lun naa.0 0 Malloc0

	# BLK
	notice "Trying to create block controller with incorrect cpumask"
	if $rpc_py construct_vhost_blk_controller vhost.invalid.cpumask  Malloc0 --cpumask 0x2; then
		error "Creating block controller with incorrect cpumask succeeded, but it shouldn't"
	fi

	notice "Trying to remove nonexistent block controller"
	if $rpc_py remove_vhost_controller vhost.nonexistent.name; then
		error "Removing nonexistent block controller succeeded, but it shouldn't"
	fi

	notice "Trying to create block controller with incorrect name"
	if $rpc_py construct_vhost_blk_controller . Malloc0; then
		error "Creating block controller with incorrect name succeeded, but it shouldn't"
	fi

	notice "Testing done -> shutting down"
	notice "killing vhost app"
	spdk_vhost_kill

	notice "EXIT DONE"
	notice "==============="
fi