The test case block/041 tests PI metadata capability in the block layer. At this moment, nvme is the only one block device that supports the capability. To check that the test target nvme devices fulfills the requirement, the test case calls 'nvme ns-id' command via _test_dev_disable_extended_lba(). However, since the test case is in the block group, TEST_DEVS can specify non-nvme devices. Even though the test case is skipped by _require_test_dev_is_nvme() check, the 'nvme ns-id' is called for the non-nvme device and fails. It spits out unnecessary error messages. To avoid the error message, check if the test device is nvme before calling 'nvme ns-id'. For the check, factor out a helper function _test_dev_is_nvme(). While at it, replace short command options -q and -f with long options --quiet and --canonicalize for readability. Signed-off-by: Shin'ichiro Kawasaki --- common/nvme | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/nvme b/common/nvme index a419cd3..bb4896a 100644 --- a/common/nvme +++ b/common/nvme @@ -1121,8 +1121,12 @@ _nvmet_target_cleanup() { fi } +_test_dev_is_nvme() { + readlink --canonicalize "$TEST_DEV_SYSFS/device" | grep --quiet nvme +} + _require_test_dev_is_nvme() { - if ! readlink -f "$TEST_DEV_SYSFS/device" | grep -q nvme; then + if ! _test_dev_is_nvme; then SKIP_REASONS+=("$TEST_DEV is not a NVMe device") return 1 fi @@ -1150,8 +1154,8 @@ _test_dev_has_no_metadata() { _test_dev_disables_extended_lba() { local flbas - if ! flbas=$(nvme id-ns "$TEST_DEV" | grep flbas | \ - sed --quiet 's/.*: \(.*\)/\1/p'); then + if ! _test_dev_is_nvme || ! flbas=$(nvme id-ns "$TEST_DEV" | \ + grep flbas | sed --quiet 's/.*: \(.*\)/\1/p'); then SKIP_REASONS+=("$TEST_DEV does not have namespace flbas field") return 1 fi -- 2.53.0