1
0
mirror of https://git.savannah.gnu.org/git/coreutils.git synced 2025-08-08 18:22:09 +03:00
Files
coreutils/tests/seek-data-capable
Pádraig Brady 4eb2e9c11a 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.
2021-05-12 22:14:11 +01:00

34 lines
834 B
Plaintext

import sys, os, errno, platform
# Pass an _empty_ file
if len(sys.argv) != 2:
sys.exit(1)
if not hasattr(os, 'SEEK_DATA'):
# Not available on python 2, or on darwin python 3
# Also Darwin swaps SEEK_DATA/SEEK_HOLE definitions
if platform.system() == "Darwin":
SEEK_DATA = 4
else:
SEEK_DATA = 3 # Valid on Linux, FreeBSD, Solaris
else:
SEEK_DATA = os.SEEK_DATA
# Even if os supports SEEK_DATA or SEEK_HOLE,
# the file system may not, in which case it would report
# current and eof positions respectively.
# Therefore work with an empty file,
# ensuring SEEK_DATA returns ENXIO (no more data)
try:
fd = os.open(sys.argv[1], os.O_RDONLY)
except:
sys.exit(1)
try:
data = os.lseek(fd, 0, SEEK_DATA)
except OSError as e:
if e.errno == errno.ENXIO:
sys.exit(0)
sys.exit(1)