summaryrefslogtreecommitdiff
path: root/tests/cp
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2021-05-09 14:29:01 +0100
committerPádraig Brady <P@draigBrady.com>2021-05-12 22:14:11 +0100
commit4eb2e9c11a8336e3ffcca289b56ede98a2431c8f (patch)
tree237d2fafbbc42b55c1a1dd91186a175b748cc523 /tests/cp
parent2e66e1732fced7af20fa76c60e636d39a1767d48 (diff)
downloadcoreutils-4eb2e9c11a8336e3ffcca289b56ede98a2431c8f.tar.gz
tests: ensure we test SEEK_DATA where used
fiemap is no longer the default copy implementation, so check for SEEK_DATA support instead as that's preferred. This will ensure better test coverage on systems without fiemap. * init.cfg: Replace fiemap_capable_ with seek_data_capable_. This is best supported with python 3 so prefer that. * tests/seek-data-capable: A new test script checking for SEEK_DATA support on the passed file name, called from seek_data_capable_. * tests/fiemap-capable: Remove no longer used probing script. * tests/cp/fiemap-perf.sh: Renamed to tests/cp/sparse-perf.sh * tests/cp/fiemap-2.sh: Renamed to tests/cp/sparse-2.sh * tests/cp/fiemap-extents.sh: Renamed to tests/cp/sparse-extents.sh * tests/cp/sparse-fiemap.sh: Renamed to tests/cp/sparse-extents-2.sh * tests/cp/fiemap-FMR.sh: Renamed to tests/cp/copy-FMR.sh * tests/local.mk: Reference the renamed tests.
Diffstat (limited to 'tests/cp')
-rwxr-xr-xtests/cp/copy-FMR.sh (renamed from tests/cp/fiemap-FMR.sh)1
-rwxr-xr-xtests/cp/sparse-2.sh (renamed from tests/cp/fiemap-2.sh)9
-rwxr-xr-xtests/cp/sparse-extents-2.sh (renamed from tests/cp/sparse-fiemap.sh)12
-rwxr-xr-xtests/cp/sparse-extents.sh (renamed from tests/cp/fiemap-extents.sh)9
-rwxr-xr-xtests/cp/sparse-perf.sh (renamed from tests/cp/fiemap-perf.sh)20
5 files changed, 19 insertions, 32 deletions
diff --git a/tests/cp/fiemap-FMR.sh b/tests/cp/copy-FMR.sh
index 7bbb88a2c..1ecdbe44d 100755
--- a/tests/cp/fiemap-FMR.sh
+++ b/tests/cp/copy-FMR.sh
@@ -22,6 +22,7 @@ print_ver_ cp
require_valgrind_
require_perl_
+# Trigger FMR in fiemap logic from v8.11..v8.19
$PERL -e 'for (1..600) { sysseek (*STDOUT, 4096, 1)' \
-e '&& syswrite (*STDOUT, "a" x 1024) or die "$!"}' > j || fail=1
valgrind --quiet --error-exitcode=3 cp --reflink=never j j2 || fail=1
diff --git a/tests/cp/fiemap-2.sh b/tests/cp/sparse-2.sh
index e6b80ebd3..05aa7f980 100755
--- a/tests/cp/fiemap-2.sh
+++ b/tests/cp/sparse-2.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Exercise a few more corners of the fiemap-copying code.
+# Exercise a few more corners of the copying code.
# Copyright (C) 2011-2021 Free Software Foundation, Inc.
@@ -19,10 +19,9 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ cp
-# Require a fiemap-enabled FS.
-touch fiemap_chk # check a file rather than current dir for best coverage
-fiemap_capable_ fiemap_chk \
- || skip_ "this file system lacks FIEMAP support"
+touch sparse_chk
+seek_data_capable_ sparse_chk \
+ || skip_ "this file system lacks 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-fiemap.sh b/tests/cp/sparse-extents-2.sh
index c66e714fc..544b959ef 100755
--- a/tests/cp/sparse-fiemap.sh
+++ b/tests/cp/sparse-extents-2.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Test cp --sparse=always through fiemap copy
+# Test cp --sparse=always through SEEK_DATA copy
# Copyright (C) 2010-2021 Free Software Foundation, Inc.
@@ -22,11 +22,11 @@ require_perl_
# 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
+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 FIEMAP support"
+ skip_ "current file system has insufficient SEEK_DATA support"
# It's not; we need to create one, hence we need root access.
require_root_
@@ -50,8 +50,8 @@ else
fi
# =================================================
-# Ensure that we exercise the FIEMAP-copying code enough
-# to provoke at least two iterations of the do...while loop
+# The data below was set up to ensure that the original FIEMAP-copying code
+# was exercised enough to provoke at least two iterations of the do...while loop
# in which it calls ioctl (fd, FS_IOC_FIEMAP,...
# This also verifies that non-trivial extents are preserved.
diff --git a/tests/cp/fiemap-extents.sh b/tests/cp/sparse-extents.sh
index 23f5cd9a3..1e9156149 100755
--- a/tests/cp/fiemap-extents.sh
+++ b/tests/cp/sparse-extents.sh
@@ -21,10 +21,9 @@ print_ver_ cp
require_sparse_support_
-touch fiemap_chk || framework_failure_
-fiemap_capable_ fiemap_chk ||
- skip_ 'this file system lacks FIEMAP support'
-rm fiemap_chk
+touch sparse_chk || framework_failure_
+seek_data_capable_ sparse_chk ||
+ skip_ 'this file system lacks SEEK_DATA support'
fallocate --help >/dev/null || skip_ 'The fallocate utility is required'
touch falloc.test || framework_failure_
@@ -65,7 +64,7 @@ fi
# Ensure we handle extents beyond file size correctly.
# Note until we support fallocate, we will not maintain
# the file allocation. FIXME: amend this test if fallocate is supported.
-# Note currently this only uses fiemap logic when the allocation (-l)
+# Note currently this only uses SEEK_DATA logic when the allocation (-l)
# is smaller than the size, thus identifying the file as sparse.
# Note the '-l 1' case is an effective noop, and just checks
# a file with a trailing hole is copied correctly.
diff --git a/tests/cp/fiemap-perf.sh b/tests/cp/sparse-perf.sh
index de110914f..a71b854cf 100755
--- a/tests/cp/fiemap-perf.sh
+++ b/tests/cp/sparse-perf.sh
@@ -19,30 +19,18 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ cp
-# Require a fiemap-enabled FS.
-touch fiemap_chk
-fiemap_capable_ fiemap_chk ||
- skip_ "this file system lacks FIEMAP support"
-
-# Exclude ext[23] (or unknown fs types)
-# as the emulated extent scanning can be slow
-df -t ext2 -t ext3 . >/dev/null &&
- skip_ "ext[23] can have slow FIEMAP scanning"
+touch sparse_chk
+seek_data_capable_ sparse_chk ||
+ skip_ "this file system lacks SEEK_DATA support"
# Create a large-but-sparse file.
timeout 10 truncate -s1T f ||
skip_ "unable to create a 1 TiB sparse file"
-# Disable this test on old BTRFS (e.g. Fedora 14)
-# which reports (unwritten) extents for holes.
-filefrag f || skip_ "the 'filefrag' utility is missing"
-filefrag f | grep -F ': 0 extents found' > /dev/null ||
- skip_ '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
-# Ensure that the sparse file copied through fiemap has the same size
+# Ensure that the sparse file copied through SEEK_DATA has the same size
# in bytes as the original.
test "$(stat --printf %s f)" = "$(stat --printf %s f2)" || fail=1