common/rc: refactor _require_{ext2,tmpfs} helpers
authorDarrick J. Wong <djwong@kernel.org>
Tue, 23 Mar 2021 04:20:11 +0000 (21:20 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 28 Mar 2021 15:27:32 +0000 (23:27 +0800)
Combine these two helpers into a single generic function so that we can
use it in the next patch to test a regression when running overlayfs
atop xfs.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/rc
tests/overlay/025
tests/overlay/106
tests/overlay/107
tests/overlay/108
tests/overlay/109
tests/xfs/049

index fc1a7751ef2d7e36aa8ad0df2706e8b7ef3135a8..8e5282c17566c6c5b3918c7a6a7094520db04d30 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -1766,26 +1766,13 @@ _require_loop()
     fi
 }
 
     fi
 }
 
-# this test requires ext2 filesystem support
+# this test requires kernel support for a secondary filesystem
 #
 #
-_require_ext2()
+_require_extra_fs()
 {
 {
-    modprobe ext2 >/dev/null 2>&1
-    if grep ext2 /proc/filesystems >/dev/null 2>&1
-    then
-       :
-    else
-       _notrun "This test requires ext2 filesystem support"
-    fi
-}
-
-# this test requires tmpfs filesystem support
-#
-_require_tmpfs()
-{
-       modprobe tmpfs >/dev/null 2>&1
-       grep -q tmpfs /proc/filesystems ||
-               _notrun "this test requires tmpfs support"
+       modprobe "$1" >/dev/null 2>&1
+       grep -q -w "$1" /proc/filesystems ||
+               _notrun "this test requires $1 support"
 }
 
 # this test requires that (large) loopback device files are not in use
 }
 
 # this test requires that (large) loopback device files are not in use
index 979bd98e407a19ecff4a2fb3df5c7f2813bc86df..c5f328c8d4f2f7dbf702d12049e79d6058d0ff90 100755 (executable)
@@ -42,7 +42,7 @@ rm -f $seqres.full
 # Modify as appropriate.
 _supported_fs overlay
 _require_user
 # Modify as appropriate.
 _supported_fs overlay
 _require_user
-_require_tmpfs
+_require_extra_fs tmpfs
 
 # create a tmpfs in $TEST_DIR
 tmpfsdir=$TEST_DIR/tmpfs
 
 # create a tmpfs in $TEST_DIR
 tmpfsdir=$TEST_DIR/tmpfs
index 28e9a81983b84a544a2f675aac1372c29cbee85b..0b3e0c9849f6cd651154cfea3815187f943e3cc7 100755 (executable)
@@ -27,7 +27,7 @@ rm -f $seqres.full
 # real QA test starts here
 
 _supported_fs overlay
 # real QA test starts here
 
 _supported_fs overlay
-_require_tmpfs
+_require_extra_fs tmpfs
 _require_test
 _require_scratch
 _require_unionmount_testsuite
 _require_test
 _require_scratch
 _require_unionmount_testsuite
index 733a555684596ec720f6240a75589a4844887a5e..89fde9de89faa1a71bf514ea633f7bb6d96a3465 100755 (executable)
@@ -27,7 +27,7 @@ rm -f $seqres.full
 # real QA test starts here
 
 _supported_fs overlay
 # real QA test starts here
 
 _supported_fs overlay
-_require_tmpfs
+_require_extra_fs tmpfs
 _require_test
 _require_scratch
 _require_unionmount_testsuite
 _require_test
 _require_scratch
 _require_unionmount_testsuite
index e757e0e4e01ae7022691c64f1eb0c2d574815d5b..ae367a5cea94159e62c1e5f149f46560e4b8b129 100755 (executable)
@@ -27,7 +27,7 @@ rm -f $seqres.full
 # real QA test starts here
 
 _supported_fs overlay
 # real QA test starts here
 
 _supported_fs overlay
-_require_tmpfs
+_require_extra_fs tmpfs
 _require_test
 _require_scratch
 _require_unionmount_testsuite
 _require_test
 _require_scratch
 _require_unionmount_testsuite
index d49080be1b61229c2c71bc42176e129f918096bc..df0366160f2500c4fc4a0705470fc83583bfa3ef 100755 (executable)
@@ -27,7 +27,7 @@ rm -f $seqres.full
 # real QA test starts here
 
 _supported_fs overlay
 # real QA test starts here
 
 _supported_fs overlay
-_require_tmpfs
+_require_extra_fs tmpfs
 _require_test
 _require_scratch
 _require_unionmount_testsuite
 _require_test
 _require_scratch
 _require_unionmount_testsuite
index 67739265eb2b7fada7cf3d49aa663df2d41876ce..16bc788db70c99c61fac8b3b826cf0de674c3abe 100755 (executable)
@@ -46,7 +46,7 @@ _require_nonexternal
 _require_scratch_nocheck
 _require_no_large_scratch_dev
 _require_loop
 _require_scratch_nocheck
 _require_no_large_scratch_dev
 _require_loop
-_require_ext2
+_require_extra_fs ext2
 
 rm -f $seqres.full
 
 
 rm -f $seqres.full