]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: determine if SEEK_HOLE is enabled
authorPádraig Brady <P@draigBrady.com>
Thu, 23 Feb 2023 20:28:51 +0000 (20:28 +0000)
committerPádraig Brady <P@draigBrady.com>
Fri, 24 Feb 2023 00:35:18 +0000 (00:35 +0000)
Upcomming gnulib changes may disable SEEK_HOLE
even if the system supports it, so dynamically
check if we've SEEK_HOLE enabled.

* init.cfg (seek_data_capable_): SEEK_DATA may be disabled in the build
if the system support is deemed insufficient, so also use `cp --debug`
to determine if it's enabled.
* tests/cp/sparse-2.sh: Adjust to a more general diagnostic.
* tests/cp/sparse-extents-2.sh: Likewise.
* tests/cp/sparse-extents.sh: Likewise.
* tests/cp/sparse-perf.sh: Likewise.

init.cfg
tests/cp/sparse-2.sh
tests/cp/sparse-extents-2.sh
tests/cp/sparse-extents.sh
tests/cp/sparse-perf.sh

index 125de7f956ec11e4c79ec2047f31f7376bca887e..55aa45e5b03f4b58854722582ac1362f25c469a6 100644 (file)
--- a/init.cfg
+++ b/init.cfg
@@ -546,6 +546,18 @@ require_kill_group_()
 # which SEEK_DATA support exists.
 seek_data_capable_()
 {
+  # Check that SEEK_HOLE support is enabled
+  # Note APFS was seen to not create sparse files < 16MiB
+  if ! truncate -s16M file.sparse_; then
+      warn_ "can't create a sparse file: assuming not SEEK_DATA capable"
+      return 1
+  fi
+  if ! cp --debug --reflink=never file.sparse_ file.sparse_.cp \
+       | grep SEEK_HOLE; then
+      return 1
+  fi
+
+  # Check that SEEK_HOLE is supported on the passed file
   { python3 < /dev/null && PYTHON_=python3; } ||
   { python  < /dev/null && PYTHON_=python; }
 
index 852d96da79842c73f41a696796d271010bb40be2..3024055e657fa5845b63672252f9ce708732c150 100755 (executable)
@@ -21,7 +21,7 @@ print_ver_ cp stat dd
 
 touch sparse_chk
 seek_data_capable_ sparse_chk \
-  || skip_ "this file system lacks SEEK_DATA support"
+  || skip_ "insufficient SEEK_DATA support"
 
 # Exercise the code that handles a file ending in a hole.
 printf x > k || framework_failure_
index 46be861667be7f265a4d96e814f3e60c4dc52bfd..575dbbfc655a74809d09edd0fde63113297088ab 100755 (executable)
@@ -26,7 +26,7 @@ touch sparse_chk
 if seek_data_capable_ sparse_chk && ! df -t ext3 . >/dev/null; then
   : # Current partition has working extents.  Good!
 else
-  skip_ "current file system has insufficient SEEK_DATA support"
+  skip_ "insufficient SEEK_DATA support"
 
   # It's not;  we need to create one, hence we need root access.
   require_root_
index 410116877fc33dc4b24fa921568c10fe265e55df..5009f098ce5d22ce21b6cc2c329c07d7f4a5e518 100755 (executable)
@@ -23,7 +23,7 @@ require_sparse_support_
 
 touch sparse_chk || framework_failure_
 seek_data_capable_ sparse_chk ||
-  skip_ 'this file system lacks SEEK_DATA support'
+  skip_ 'insufficient SEEK_DATA support'
 
 fallocate --help >/dev/null || skip_ 'The fallocate utility is required'
 touch falloc.test || framework_failure_
index 2ce9359bebf78d0311e6e4d72fb6b33710c7c4f5..793ecee1865b7172a8ceb4ad298a3e783ec6a379 100755 (executable)
@@ -28,7 +28,7 @@ timeout 10 truncate -s1T f ||
 # between the creation of the file and the use of SEEK_DATA,
 # for it to determine it's an empty file (return ENXIO).
 seek_data_capable_ f ||
-  skip_ "this file system lacks appropriate SEEK_DATA support"
+  skip_ "insufficient SEEK_DATA support"
 
 # Nothing can read that many bytes in so little time.
 timeout 10 cp --reflink=never f f2 || fail=1