]> www.infradead.org Git - users/hch/blktests.git/commitdiff
common/xfs: Create common helper to check for XFS support
authorLogan Gunthorpe <logang@deltatee.com>
Thu, 8 Oct 2020 16:40:15 +0000 (10:40 -0600)
committerOmar Sandoval <osandov@fb.com>
Thu, 22 Oct 2020 21:44:12 +0000 (14:44 -0700)
Two nvme tests create and mount XFS filesystems and check for mkfs.xfs.

They should also check for XFS support in the kernel so create a common
helper for this.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
common/rc
common/xfs [new file with mode: 0644]
tests/nvme/012
tests/nvme/013

index 0589431058a5e4b6e247859cae52a502b51110e6..0d7a3cd81adf556828ac3b300e860139d94bb07b 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -181,6 +181,14 @@ _have_tracepoint() {
        return 0
 }
 
+_have_fs() {
+       modprobe "$1" >/dev/null 2>&1
+       if [[ ! -d "/sys/fs/$1" ]]; then
+               SKIP_REASON="kernel does not support filesystem $1"
+               return 1
+       fi
+}
+
 _test_dev_is_rotational() {
        [[ $(cat "${TEST_DEV_SYSFS}/queue/rotational") -ne 0 ]]
 }
diff --git a/common/xfs b/common/xfs
new file mode 100644 (file)
index 0000000..d1a603b
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2017 Omar Sandoval
+#
+# fio helper functions.
+
+. common/shellcheck
+
+_have_xfs() {
+       _have_fs xfs && _have_program mkfs.xfs
+}
index 1dbd59804ed716239951a354f4e734563b329517..1d8d8e3cc271e3ea21de76951e4e668b647a20f7 100755 (executable)
@@ -5,14 +5,16 @@
 # Test mkfs with data verification for block device backed ns.
 
 . tests/nvme/rc
+. common/xfs
 
 DESCRIPTION="run mkfs and data verification fio job on NVMeOF block device-backed ns"
 TIMED=1
 
 requires() {
        _nvme_requires
-       _have_program mkfs.xfs && _have_program fio && \
-               _have_modules loop
+       _have_xfs
+       _have_program fio
+       _have_modules loop
        _require_nvme_trtype_is_fabrics
 }
 
index df7f23e692525e8389023ded6799846a2fbf7d36..3819a2730d9b885a9c401a00a7ba3110bd0f3b93 100755 (executable)
@@ -5,13 +5,15 @@
 # Test mkfs with data verification for file backed ns.
 
 . tests/nvme/rc
+. common/xfs
 
 DESCRIPTION="run mkfs and data verification fio job on NVMeOF file-backed ns"
 TIMED=1
 
 requires() {
        _nvme_requires
-       _have_program mkfs.xfs && _have_fio
+       _have_xfs
+       _have_fio
        _require_nvme_trtype_is_fabrics
 }