tests: support more file systems in the cp fiemap tests
authorPádraig Brady <P@draigBrady.com>
Sun, 13 Feb 2011 18:56:10 +0000 (18:56 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 15 Feb 2011 00:02:29 +0000 (00:02 +0000)
* tests/cp/sparse-fiemap: Check for fiemap support against a file
rather than a directory to enable tests on BTRFS for example.
Explicity disable the test on ext3 or file systems where we
can't determine the type.
* tests/cp/fiemap-perf: Likewise.  Also disable the test on older
BTRFS (like in Fedora 14), where extents are returned for holes.
* tests/init.cfg: Comment that BTRFS only supports fiemap
for regular files.

tests/cp/fiemap-perf
tests/cp/sparse-fiemap
tests/init.cfg

index dbb2a81..c88e8ec 100755 (executable)
 print_ver_ cp
 
 # Require a fiemap-enabled FS.
-# Note we don't check a file here as that could enable
-# the test on ext3 where emulated extent scanning can be slow.
-fiemap_capable_ . \
-  || skip_ "this file system lacks FIEMAP support"
+touch fiemap_chk
+fiemap_capable_ fiemap_chk ||
+  skip_ "this file system lacks FIEMAP support"
+
+# Exclude ext3 (or unknown fs types)
+# as the emulated extent scanning is slow
+df -t ext3 . >/dev/null &&
+  skip_ "ext3 has known slow FIEMAP scanning"
 
 # Create a large-but-sparse file.
 timeout 10 truncate -s1T f || framework_failure_
 
+# Disable this test on old BTRFS (e.g. Fedora 14)
+# which reports (unwritten) extents for holes.
+filefrag f || skip_test_ 'the `filefrag` utility is missing'
+filefrag f | grep -F ': 0 extents found' > /dev/null ||
+  skip_test_ 'this file system reports extents for holes'
+
 # Nothing can read (much less write) that many bytes in so little time.
 timeout 10 cp f f2 || fail=1
 
index fc27869..4eced1d 100755 (executable)
 . "${srcdir=.}/init.sh"; path_prepend_ ../src
 print_ver_ cp
 
-# Note we don't check a file here as that could enable
-# the test on ext3 where this test is seen to fail.
-if fiemap_capable_ . ; then
-  : # Current dir is on a partition with working extents.  Good!
+# The test was seen to fail on ext3 so exclude that type
+# (or any file system where the type can't be determined)
+touch fiemap_chk
+if fiemap_capable_ fiemap_chk && ! df -t ext3 . >/dev/null; then
+  : # Current partition has working extents.  Good!
 else
   # It's not;  we need to create one, hence we need root access.
   require_root_
index eb3feaa..f74d50c 100644 (file)
@@ -296,7 +296,7 @@ require_proc_pid_status_()
 }
 
 # Return nonzero if the specified path is on a file system for
-# which FIEMAP support exists.  Note some file systems (like ext3)
+# which FIEMAP support exists.  Note some file systems (like ext3 and btrfs)
 # only support FIEMAP for files, not directories.
 fiemap_capable_()
 {