Ticket #2828: coreutils-8.10_sparse-fiemap-test.patch

File coreutils-8.10_sparse-fiemap-test.patch, 4.7 KB (added by Gilles Espinasse, 13 years ago)

Upstream fix for test failure

  • tests/Makefile.am

    From 1da62d67ce4d4c78b98bc947c9367a10f1bdba9d Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P <at> draigBrady.com>
    Date: Fri, 4 Feb 2011 22:05:20 +0000
    Subject: [PATCH] test: improve the fiemap_capable_ check
    
    * tests/cp/fiemap-2: Enable the fiemap check for files, which
    will enable the test on ext3.
    * tests/cp/fiemap-perf: Comment why we're not enabling for ext3.
    * tests/cp/sparse-fiemap: Ditto.
    * tests/fiemap-capable: A new python script to determine
    if a specified path supports fiemap.
    * tests/init.cfg (fiemap_capable_): Use the new python script.
    * tests/Makefile.am (EXTRA_DIST): Include the new python script.
    ---
     tests/Makefile.am      |    1 +
     tests/cp/fiemap-2      |    3 ++-
     tests/cp/fiemap-perf   |    2 ++
     tests/cp/sparse-fiemap |   12 ++++++++----
     tests/fiemap-capable   |   16 ++++++++++++++++
     tests/init.cfg         |    9 ++++-----
     6 files changed, 33 insertions(+), 10 deletions(-)
     create mode 100644 tests/fiemap-capable
    
    diff --git a/tests/Makefile.am b/tests/Makefile.am
    index 751b327..8aa56cd 100644
    a b EXTRA_DIST = \  
    1111  check.mk              \
    1212  envvar-check          \
    1313  filefrag-extent-compare \
     14  fiemap-capable        \
    1415  init.cfg              \
    1516  init.sh               \
    1617  lang-default          \
  • tests/cp/fiemap-2

    diff --git a/tests/cp/fiemap-2 b/tests/cp/fiemap-2
    index a17076c..691ead2 100755
    a b  
    2020print_ver_ cp
    2121
    2222# Require a fiemap-enabled FS.
    23 fiemap_capable_ . \
     23touch fiemap_chk # check a file rather than current dir for best coverage
     24fiemap_capable_ fiemap_chk \
    2425  || skip_ "this file system lacks FIEMAP support"
    2526
    2627# Exercise the code that handles a file ending in a hole.
  • tests/cp/fiemap-perf

    diff --git a/tests/cp/fiemap-perf b/tests/cp/fiemap-perf
    index 7369a7d..dbb2a81 100755
    a b  
    2020print_ver_ cp
    2121
    2222# Require a fiemap-enabled FS.
     23# Note we don't check a file here as that could enable
     24# the test on ext3 where emulated extent scanning can be slow.
    2325fiemap_capable_ . \
    2426  || skip_ "this file system lacks FIEMAP support"
    2527
  • tests/cp/sparse-fiemap

    diff --git a/tests/cp/sparse-fiemap b/tests/cp/sparse-fiemap
    index f224b5b..fc27869 100755
    a b  
    1919. "${srcdir=.}/init.sh"; path_prepend_ ../src
    2020print_ver_ cp
    2121
     22# Note we don't check a file here as that could enable
     23# the test on ext3 where this test is seen to fail.
    2224if fiemap_capable_ . ; then
    2325  : # Current dir is on a partition with working extents.  Good!
    2426else
    for i in $(seq 1 2 21); do  
    6668    $PERL -e 'BEGIN { $n = '$i' * 1024; *F = *STDOUT }' \
    6769          -e 'for (1..'$j') { sysseek (*F, $n, 1)' \
    6870          -e '&& syswrite (*F, chr($_)x$n) or die "$!"}' > j1 || fail=1
    69     # sync
     71
     72    # Note the explicit fdatasync is used here as
     73    # it was seen that `filefrag -s` (FIEMAP_FLAG_SYNC) was
     74    # ineffective on ext4 loopback on Linux 2.6.35.10-72.fc14.i686
     75    dd if=/dev/null of=j1 conv=notrunc,fdatasync
    7076    cp --sparse=always j1 j2 || fail=1
    71     # sync
    72     # Technically we may need the 'sync' uses above, but
    73     # uncommenting them makes this test take much longer.
     77    dd if=/dev/null of=j2 conv=notrunc,fdatasync
    7478
    7579    cmp j1 j2 || fail=1
    7680    filefrag -v j1 | grep extent \
  • new file tests/fiemap-capable

    diff --git a/tests/fiemap-capable b/tests/fiemap-capable
    new file mode 100644
    index 0000000..05c6926
    - +  
     1import struct, fcntl, sys, os
     2
     3def sizeof(t): return struct.calcsize(t)
     4IOCPARM_MASK = 0x7f
     5IOC_OUT = 0x40000000
     6IOC_IN = 0x80000000
     7IOC_INOUT = (IOC_IN|IOC_OUT)
     8def _IOWR(x,y,t): return (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
     9
     10try:
     11    fd = os.open (len (sys.argv) == 2 and sys.argv[1] or '.', os.O_RDONLY)
     12    struct_fiemap = '=qqllll'
     13    FS_IOC_FIEMAP = _IOWR (ord ('f'), 11, struct_fiemap)
     14    fcntl.ioctl (fd, FS_IOC_FIEMAP, struct.pack(struct_fiemap, 0,~0,0,0,0,0))
     15except:
     16    sys.exit (1)
  • tests/init.cfg

    diff --git a/tests/init.cfg b/tests/init.cfg
    index b2d1bab..f49c5cf 100644
    a b require_proc_pid_status_()  
    295295    kill $pid
    296296}
    297297
    298 # Return nonzero if the specified directory is on a file system for
    299 # which FIEMAP support exists, and the file system type is new enough
    300 # (unlike ext2 and ext3) that it is hard to find an instance *without*
    301 # FIEMAP support.
     298# Return nonzero if the specified path is on a file system for
     299# which FIEMAP support exists.  Note some file systems (like ext3)
     300# only support FIEMAP for files, not directories.
    302301fiemap_capable_()
    303302{
    304   df -T -t btrfs -t xfs -t ext4 -t ocfs2 -t gfs2 "$@"
     303  python $abs_srcdir/fiemap-capable "$@"
    305304}
    306305
    307306# Does the current (working-dir) file system support sparse files?