From f2f1060ed27a167c796bf9dd547ff8e952937d11 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Mon, 8 Jun 2020 11:16:41 -0400 Subject: [PATCH] test/cuse: run namespace managment test if device supports it In case when no device supporting Namespace Managment was found, the test case exits without producing an error. For example QEMU NVMe emulated device does not support it, thus only physical devices have to be used right now. This goes against design of "run_test" function, that when executed should always run and never silently skip. This patch adds check whether there is a device support and triggers the test case only then. Note that original code for selecting the device is still in original script. This is to enable running nvme_ns_manage_cuse.sh on its own. Right now CUSE tests are only enabled on VMs so nvme_ns_manage_cuse, was added to exception list. This will soon be reverted as the tests are moved to job that runs on physical machines. Signed-off-by: Tomasz Zawadzki Change-Id: Ie784696c2628b5fe45ce751b3978abcc03118cd9 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2828 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Ben Walker Reviewed-by: Karol Latecki --- test/common/skipped_tests.txt | 3 +++ test/nvme/cuse/nvme_cuse.sh | 29 ++++++++++++++++++++++++++- test/nvme/cuse/nvme_ns_manage_cuse.sh | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/test/common/skipped_tests.txt b/test/common/skipped_tests.txt index e0713205b..d96957f2b 100644 --- a/test/common/skipped_tests.txt +++ b/test/common/skipped_tests.txt @@ -24,6 +24,9 @@ spdkcli_nvmf_fc unittest_nvmf_fc unittest_nvmf_fc_ls +# Enable after cuse tests switch to physical devices +nvme_ns_manage_cuse + # These tests are currently only run manually vhost_blk_fs_integrity vhost_blk_hot_remove diff --git a/test/nvme/cuse/nvme_cuse.sh b/test/nvme/cuse/nvme_cuse.sh index b28ebf794..699cd5ac8 100755 --- a/test/nvme/cuse/nvme_cuse.sh +++ b/test/nvme/cuse/nvme_cuse.sh @@ -15,5 +15,32 @@ run_test "nvme_cuse_app" $testdir/cuse run_test "nvme_cuse_rpc" $testdir/nvme_cuse_rpc.sh run_test "nvme_cli_cuse" $testdir/spdk_nvme_cli_cuse.sh run_test "nvme_smartctl_cuse" $testdir/spdk_smartctl_cuse.sh -run_test "nvme_ns_manage_cuse" $testdir/nvme_ns_manage_cuse.sh + +# Only run Namespace managment test case when such device is present +bdfs=$(get_nvme_bdfs) + +$rootdir/scripts/setup.sh reset +sleep 1 + +# Find bdf that supports Namespace managment +for bdf in $bdfs; do + nvme_name=$(get_nvme_ctrlr_from_bdf ${bdf}) + if [[ -z "$nvme_name" ]]; then + continue + fi + + # Check Optional Admin Command Support for Namespace Management + oacs=$(nvme id-ctrl /dev/${nvme_name} | grep oacs | cut -d: -f2) + oacs_ns_manage=$((oacs & 0x8)) + + if [[ "$oacs_ns_manage" -ne 0 ]]; then + break + fi +done + +if [[ "$oacs_ns_manage" -ne 0 ]]; then + run_test "nvme_ns_manage_cuse" $testdir/nvme_ns_manage_cuse.sh +fi +$rootdir/scripts/setup.sh + rmmod cuse diff --git a/test/nvme/cuse/nvme_ns_manage_cuse.sh b/test/nvme/cuse/nvme_ns_manage_cuse.sh index feb8b8a07..dae0baee0 100755 --- a/test/nvme/cuse/nvme_ns_manage_cuse.sh +++ b/test/nvme/cuse/nvme_ns_manage_cuse.sh @@ -36,7 +36,7 @@ done if [[ "${nvme_name}" == "" ]] || [[ "$oacs_ns_manage" -eq 0 ]]; then echo "No NVMe device supporting Namespace managment found" $rootdir/scripts/setup.sh - exit 0 + exit 1 fi nvme_dev=/dev/${nvme_name}