From: Pádraig Brady
Date: Thu, 23 Feb 2023 20:28:51 +0000 (+0000) Subject: tests: determine if SEEK_HOLE is enabled X-Git-Tag: v9.2~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c8c2a5161c0b6f84212778f694c526105f10dab;p=thirdparty%2Fcoreutils.git tests: determine if SEEK_HOLE is enabled 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. --- diff --git a/init.cfg b/init.cfg index 125de7f956..55aa45e5b0 100644 --- 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; } diff --git a/tests/cp/sparse-2.sh b/tests/cp/sparse-2.sh index 852d96da79..3024055e65 100755 --- a/tests/cp/sparse-2.sh +++ b/tests/cp/sparse-2.sh @@ -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_ diff --git a/tests/cp/sparse-extents-2.sh b/tests/cp/sparse-extents-2.sh index 46be861667..575dbbfc65 100755 --- a/tests/cp/sparse-extents-2.sh +++ b/tests/cp/sparse-extents-2.sh @@ -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_ diff --git a/tests/cp/sparse-extents.sh b/tests/cp/sparse-extents.sh index 410116877f..5009f098ce 100755 --- a/tests/cp/sparse-extents.sh +++ b/tests/cp/sparse-extents.sh @@ -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_ diff --git a/tests/cp/sparse-perf.sh b/tests/cp/sparse-perf.sh index 2ce9359beb..793ecee186 100755 --- a/tests/cp/sparse-perf.sh +++ b/tests/cp/sparse-perf.sh @@ -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