[parted-devel] [PATCH 2/3] tests: add a helper to check the kernel knows about a file system

Ross Burton ross.burton at arm.com
Mon Aug 9 15:25:51 BST 2021


Some tests need both the file system tools (eg mkfs.vfat) and kernel
support (eg vfat kernel module) to pass.

There are already helpers such as require_fat_ which check for mkfs.vfat,
but if the kernel doesn't support the filesystem then mounting the disk
image will fail.

Add require_filesystem_, which checks for either the filesystem name in
/proc/filesystems (so it's built-in, or already loaded) or if the name
is a valid module (so can be loaded on demand).
---
 tests/t-lib-helpers.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh
index dddb44e..33151bb 100644
--- a/tests/t-lib-helpers.sh
+++ b/tests/t-lib-helpers.sh
@@ -418,3 +418,13 @@ require_64bit_()
           ;;
   esac
 }
+
+# Check if the specified filesystem is either built into the kernel, or can be loaded
+# as a module
+# Usage: has_filesystem vfat
+# Ruturns 0 if the filesystem is available, otherwise skips the test
+require_filesystem_()
+{
+  grep -q $1 /proc/filesystems && return 0
+  modprobe --quiet --dry-run $1 || skip_ "this test requires kernel support for $1"
+}
-- 
2.25.1




More information about the parted-devel mailing list