Commit efbcd259 authored by Tomasz Kulasek's avatar Tomasz Kulasek Committed by Tomasz Zawadzki
Browse files

lib/nvme: nvme character device tests



This patch adds new script to verify CUSE functionality for NVMe
devices:

 1) Starts spdk_tgt application
 2) Attaches first found controller
 3) Enables NVMe cuse devices for a controller and namespaces
 4) Retrieves CUSE device names for controller and namespaces
 4) Tests operations on exposed namespace devices
 5) Tests operations on controller devices

NOTE: These tests requires at least one NVMe device with at least one
      namespace available.


Change-Id: I5f5a7c86f8aefa73f12f4727f7520f16a599985b
Signed-off-by: default avatarTomasz Kulasek <tomaszx.kulasek@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468828


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent eafc447e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -176,9 +176,12 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then

	if [ $SPDK_TEST_NVME -eq 1 ]; then
		run_test suite test/nvme/nvme.sh
		if [ $SPDK_TEST_NVME_CLI -eq 1 ]; then
		if [[ $SPDK_TEST_NVME_CLI -eq 1 ]]; then
			run_test suite test/nvme/spdk_nvme_cli.sh
		fi
		if [[ $SPDK_TEST_NVME_CUSE -eq 1 ]]; then
			run_test suite test/nvme/spdk_nvme_cli_cuse.sh
		fi
		# Only test hotplug without ASAN enabled. Since if it is
		# enabled, it catches SEGV earlier than our handler which
		# breaks the hotplug logic.
+5 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ export RUN_NIGHTLY_FAILING
: ${SPDK_TEST_ISCSI_INITIATOR=0}; export SPDK_TEST_ISCSI_INITIATOR
: ${SPDK_TEST_NVME=0}; export SPDK_TEST_NVME
: ${SPDK_TEST_NVME_CLI=0}; export SPDK_TEST_NVME_CLI
: ${SPDK_TEST_NVME_CUSE=0}; export SPDK_TEST_NVME_CUSE
: ${SPDK_TEST_NVMF=0}; export SPDK_TEST_NVMF
: ${SPDK_TEST_NVMF_TRANSPORT="rdma"}; export SPDK_TEST_NVMF_TRANSPORT
: ${SPDK_TEST_RBD=0}; export SPDK_TEST_RBD
@@ -162,6 +163,10 @@ if [ -d /usr/include/iscsi ]; then
	fi
fi

if [ $SPDK_TEST_NVME_CUSE -eq 1 ]; then
	config_params+=' --with-nvme-cuse'
fi

# for options with both dependencies and a test flag, set them here
if [ -f /usr/include/libpmemblk.h ] && [ $SPDK_TEST_PMDK -eq 1 ]; then
	config_params+=' --with-pmdk'
+50 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../..)
source $rootdir/scripts/common.sh
source $rootdir/test/common/autotest_common.sh

timing_enter nvme_cli_cuse

NVME_CMD=/usr/local/src/nvme-cli/nvme
rpc_py=$rootdir/scripts/rpc.py

$rootdir/app/spdk_tgt/spdk_tgt -m 0x3 &
spdk_tgt_pid=$!
trap 'kill -9 ${spdk_tgt_pid}; exit 1' SIGINT SIGTERM EXIT

waitforlisten $spdk_tgt_pid

bdf=$(iter_pci_class_code 01 08 02 | head -1)

$rpc_py bdev_nvme_attach_controller -b Nvme0 -t PCIe -a ${bdf}
$rpc_py bdev_nvme_cuse_register -n Nvme0 -p spdk/nvme0

sleep 5

$rpc_py bdev_get_bdevs
$rpc_py bdev_nvme_get_controllers

for ns in $(ls /dev/spdk/nvme?n?); do
	${NVME_CMD} get-ns-id $ns
	${NVME_CMD} id-ns $ns
	${NVME_CMD} list-ns $ns
done

for ctrlr in $(ls /dev/spdk/nvme?); do
	${NVME_CMD} id-ctrl $ctrlr
	${NVME_CMD} list-ctrl $ctrlr
	${NVME_CMD} fw-log $ctrlr
	${NVME_CMD} smart-log $ctrlr
	${NVME_CMD} error-log $ctrlr
	${NVME_CMD} get-feature $ctrlr -f 1 -s 1 -l 100
	${NVME_CMD} get-log $ctrlr -i 1 -l 100
	${NVME_CMD} reset $ctrlr
done

trap - SIGINT SIGTERM EXIT
kill $spdk_tgt_pid

report_test_completion spdk_nvme_cli_cuse
timing_exit nvme_cli_cuse