test/spdkcli: Test for virtio bdevs.
Change-Id: Id6ecc0960e21e22c8705f28affcffad7a7001665 Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com> Reviewed-on: https://review.gerrithub.io/418679 Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
ef468ff71b
commit
68c4df0f02
@ -216,6 +216,7 @@ fi
|
||||
if [ $SPDK_TEST_VHOST_INIT -eq 1 ]; then
|
||||
run_test ./test/vhost/initiator/blockdev.sh
|
||||
run_test ./test/vhost/initiator/json_config.sh
|
||||
run_test ./test/spdkcli/virtio.sh
|
||||
report_test_completion "vhost_initiator"
|
||||
fi
|
||||
|
||||
|
18
test/spdkcli/match_files/spdkcli_virtio_pci.test.match
Normal file
18
test/spdkcli/match_files/spdkcli_virtio_pci.test.match
Normal file
@ -0,0 +1,18 @@
|
||||
o- bdevs ..................................................................................................................... [...]
|
||||
o- aio ................................................................................................................ [Bdevs: 0]
|
||||
o- error .............................................................................................................. [Bdevs: 0]
|
||||
o- iscsi .............................................................................................................. [Bdevs: 0]
|
||||
o- logical_volume ..................................................................................................... [Bdevs: 0]
|
||||
o- malloc ............................................................................................................. [Bdevs: 2]
|
||||
| o- Malloc0 ........................................................................................... [Size=32.0M, Not claimed]
|
||||
| o- Malloc1 ........................................................................................... [Size=32.0M, Not claimed]
|
||||
o- null ............................................................................................................... [Bdevs: 0]
|
||||
o- nvme ............................................................................................................... [Bdevs: 0]
|
||||
o- pmemblk ............................................................................................................ [Bdevs: 0]
|
||||
o- rbd ................................................................................................................ [Bdevs: 0]
|
||||
o- split_disk ......................................................................................................... [Bdevs: 0]
|
||||
o- virtioblk_disk ..................................................................................................... [Bdevs: 1]
|
||||
| o- virtioblk_pci $(S) [Size=$(FP)M, Not claimed]
|
||||
o- virtioscsi_disk .................................................................................................... [Bdevs: 1]
|
||||
o- virtioscsi_pci ............................................................................................... [$(S)]
|
||||
o- virtioscsi_pcit0 $(S) [Size=$(FP)M, Not claimed]
|
8
test/spdkcli/match_files/spdkcli_virtio_user.test.match
Normal file
8
test/spdkcli/match_files/spdkcli_virtio_user.test.match
Normal file
@ -0,0 +1,8 @@
|
||||
o- vhost ..................................................................................................................... [...]
|
||||
o- block ................................................................................................................... [...]
|
||||
| o- sample_block $(S) [$(S)]
|
||||
| o- Malloc1 ............................................................................................................. [...]
|
||||
o- scsi .................................................................................................................... [...]
|
||||
o- sample_scsi $(S) [$(S)]
|
||||
o- Target_0 ............................................................................................ [LUNs: 1,TargetID: 0]
|
||||
o- Malloc0 ........................................................................................................... [...]
|
@ -7,7 +7,6 @@ import sys
|
||||
def execute_command(cmd, element=None, element_exists=False):
|
||||
child.sendline(cmd)
|
||||
child.expect("/>")
|
||||
print("before: %s" % child.before.decode())
|
||||
if "error response" in child.before.decode():
|
||||
print("Error in cmd: %s" % cmd)
|
||||
exit(1)
|
||||
@ -27,10 +26,13 @@ def execute_command(cmd, element=None, element_exists=False):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
socket = "/var/tmp/spdk.sock"
|
||||
if len(sys.argv) == 5:
|
||||
socket = sys.argv[4]
|
||||
testdir = os.path.dirname(os.path.realpath(sys.argv[0]))
|
||||
child = pexpect.spawn(os.path.join(testdir, "../../scripts/spdkcli.py"))
|
||||
child = pexpect.spawn(os.path.join(testdir, "../../scripts/spdkcli.py") + " -s %s" % socket)
|
||||
child.expect(">")
|
||||
child.sendline("cd /")
|
||||
child.expect("/>")
|
||||
|
||||
execute_command(*sys.argv[1:])
|
||||
execute_command(*sys.argv[1:4])
|
||||
|
74
test/spdkcli/virtio.sh
Executable file
74
test/spdkcli/virtio.sh
Executable file
@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
set -xe
|
||||
|
||||
testdir=$(readlink -f $(dirname $0))
|
||||
. $testdir/common.sh
|
||||
|
||||
trap 'killprocess $virtio_pid; on_error_exit' ERR
|
||||
timing_enter spdk_cli_vhost
|
||||
|
||||
timing_enter run_spdk_tgt
|
||||
run_spdk_tgt
|
||||
timing_exit run_spdk_tgt
|
||||
|
||||
timing_enter run_spdk_virtio
|
||||
$SPDKCLI_BUILD_DIR/app/spdk_tgt/spdk_tgt -m 0x4 -p 0 -g -u -s 1024 -r /var/tmp/virtio.sock &
|
||||
virtio_pid=$!
|
||||
waitforlisten $virtio_pid /var/tmp/virtio.sock
|
||||
timing_exit run_spdk_virtio
|
||||
|
||||
timing_enter spdkcli_create_virtio_pci_config
|
||||
$spdkcli_job "/bdevs/malloc create 32 512 Malloc0" "Malloc0" True
|
||||
$spdkcli_job "/bdevs/malloc create 32 512 Malloc1" "Malloc1" True
|
||||
pci_blk=$(lspci -nn -D | grep '1af4:1001' | head -1 | awk '{print $1;}')
|
||||
if [ ! -z $pci_blk ]; then
|
||||
$spdkcli_job "/bdevs/virtioblk_disk create virtioblk_pci pci $pci_blk" "virtioblk_pci" True
|
||||
fi
|
||||
pci_scsi=$(lspci -nn -D | grep '1af4:1004' | head -1 | awk '{print $1;}')
|
||||
if [ ! -z $pci_scsi ]; then
|
||||
$spdkcli_job "/bdevs/virtioscsi_disk create virtioscsi_pci pci $pci_scsi" "virtioscsi_pci" True
|
||||
fi
|
||||
$spdkcli_job "/vhost/scsi create sample_scsi" "sample_scsi" True
|
||||
$spdkcli_job "/vhost/scsi/sample_scsi add_lun 0 Malloc0" "Malloc0" True
|
||||
$spdkcli_job "/vhost/block create sample_block Malloc1" "Malloc1" True
|
||||
timing_exit spdkcli_create_virtio_pci_config
|
||||
|
||||
timing_enter spdkcli_check_match
|
||||
if [ ! -z $pci_blk ] && [ ! -z $pci_scsi ]; then
|
||||
MATCH_FILE="spdkcli_virtio_pci.test"
|
||||
SPDKCLI_BRANCH="/bdevs"
|
||||
check_match
|
||||
fi
|
||||
timing_exit spdkcli_check_match
|
||||
|
||||
timing_exit spdkcli_create_virtio_user_config
|
||||
$spdkcli_job "/bdevs/virtioblk_disk create virtioblk_user user $testdir/../../sample_block" "virtioblk_user" True "/var/tmp/virtio.sock"
|
||||
$spdkcli_job "/bdevs/virtioscsi_disk create virtioscsi_user user $testdir/../../sample_scsi" "virtioscsi_user" True "/var/tmp/virtio.sock"
|
||||
timing_exit spdkcli_create_virtio_user_config
|
||||
|
||||
timing_enter spdkcli_check_match
|
||||
MATCH_FILE="spdkcli_virtio_user.test"
|
||||
SPDKCLI_BRANCH="/vhost"
|
||||
check_match
|
||||
timing_exit spdkcli_check_match
|
||||
|
||||
timing_enter spdkcli_clear_virtio_config
|
||||
$spdkcli_job "/bdevs/virtioscsi_disk delete virtioscsi_user" "" False "/var/tmp/virtio.sock"
|
||||
$spdkcli_job "/bdevs/virtioblk_disk delete virtioblk_user" "" False "/var/tmp/virtio.sock"
|
||||
$spdkcli_job "/vhost/block delete sample_block" "sample_block"
|
||||
$spdkcli_job "/vhost/scsi/sample_scsi remove_target 0" "Malloc0"
|
||||
$spdkcli_job "/vhost/scsi delete sample_scsi" " sample_scsi"
|
||||
if [ ! -z $pci_blk ]; then
|
||||
$spdkcli_job "/bdevs/virtioblk_disk delete virtioblk_pci" "virtioblk_pci"
|
||||
fi
|
||||
if [ ! -z $pci_scsi ]; then
|
||||
$spdkcli_job "/bdevs/virtioscsi_disk delete virtioscsi_pci" "virtioscsi_pci"
|
||||
fi
|
||||
$spdkcli_job "/bdevs/malloc delete Malloc0" "Malloc0"
|
||||
$spdkcli_job "/bdevs/malloc delete Malloc1" "Malloc1"
|
||||
timing_exit spdkcli_clear_virtio_config
|
||||
|
||||
killprocess $virtio_pid
|
||||
killprocess $spdk_tgt_pid
|
||||
|
||||
timing_exit spdk_cli_vhost
|
Loading…
Reference in New Issue
Block a user