diff options
author | Pádraig Brady <P@draigBrady.com> | 2011-04-13 07:58:02 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2011-04-13 11:18:48 +0100 |
commit | 403e8e3b8964a41b6252089f9712e25768f7b7c6 (patch) | |
tree | 699c97b389fae7ad3145e48be55b1dd66a1ea511 /tests | |
parent | 501ce81b6a8400b37661fe65e66dfc33c5660ca0 (diff) | |
download | coreutils-403e8e3b8964a41b6252089f9712e25768f7b7c6.tar.xz |
tests: fix a false positive fiemap test on some file systems
* tests/filefrag-extent-compare: Don't check the length of the
last extent, as this was seen to vary on XFS, where it leaves
trailing blocks allocated for performance reasons.
* tests/cp/fiemap-empty: Though not seen as an issue in practise,
try to avoid possible issues with the allocator in file systems,
by requesting to allocate a power of 2.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/cp/fiemap-empty | 16 | ||||
-rw-r--r-- | tests/filefrag-extent-compare | 16 |
2 files changed, 20 insertions, 12 deletions
diff --git a/tests/cp/fiemap-empty b/tests/cp/fiemap-empty index 42d816bb0..64c3254c7 100755 --- a/tests/cp/fiemap-empty +++ b/tests/cp/fiemap-empty @@ -38,8 +38,8 @@ rm falloc.test # which would cause failure of unrelated tests run in parallel. require_file_system_bytes_free_ 800000000 -fallocate -l 600000000 space.test || - skip_test_ 'this test needs at least 600MB free space' +fallocate -l 600MiB space.test || + skip_test_ 'this test needs at least 600MiB free space' # Disable this test on old BTRFS (e.g. Fedora 14) # which reports ordinary extents for unwritten ones. @@ -50,7 +50,7 @@ filefrag -v space.test | grep -F 'unwritten' > /dev/null || rm space.test # Ensure we read a large empty file quickly -fallocate -l 300000000 empty.big || framework_failure +fallocate -l 300MiB empty.big || framework_failure timeout 3 cp --sparse=always empty.big cp.test || fail=1 test $(stat -c %s empty.big) = $(stat -c %s cp.test) || fail=1 rm empty.big cp.test @@ -58,7 +58,7 @@ rm empty.big cp.test # Ensure we handle extents beyond file size correctly. # Note until we support fallocate, we will not maintain # the file allocation. FIXME: amend this test when fallocate is supported. -fallocate -l 10000000 -n unwritten.withdata || framework_failure +fallocate -l 10MiB -n unwritten.withdata || framework_failure dd count=10 if=/dev/urandom conv=notrunc iflag=fullblock of=unwritten.withdata cp unwritten.withdata cp.test || fail=1 test $(stat -c %s unwritten.withdata) = $(stat -c %s cp.test) || fail=1 @@ -68,16 +68,16 @@ rm unwritten.withdata cp.test # The following to generate unaccounted extents followed by a hole, is not # supported by ext4 at least. The ftruncate discards all extents not # accounted for in the size. -# fallocate -l 10000000 -n unacc.withholes +# fallocate -l 10MiB -n unacc.withholes # dd count=10 if=/dev/urandom conv=notrunc iflag=fullblock of=unacc.withholes -# truncate -s20000000 unacc.withholes +# truncate -s20M unacc.withholes # Ensure we handle a hole after empty extents correctly. # Since all extents are accounted for in the size, # we can maintain the allocation independently from # fallocate() support. -fallocate -l 10000000 empty.withholes -truncate -s 20000000 empty.withholes +fallocate -l 10MiB empty.withholes +truncate -s 20M empty.withholes sectors_per_block=$(expr $(stat -c %o .) / 512) cp empty.withholes cp.test || fail=1 test $(stat -c %s empty.withholes) = $(stat -c %s cp.test) || fail=1 diff --git a/tests/filefrag-extent-compare b/tests/filefrag-extent-compare index 2c33584e5..155e7ff78 100644 --- a/tests/filefrag-extent-compare +++ b/tests/filefrag-extent-compare @@ -56,10 +56,18 @@ merge_extents \@b; my $i = 0; while (defined $a[$i]) { - $a[$i]->{L_BLK} == $b[$i]->{L_BLK} && $a[$i]->{LEN} == $b[$i]->{LEN} - or die "$ME: differing extent:\n" - . " [$i]=$a[$i]->{L_BLK} $a[$i]->{LEN}\n" - . " [$i]=$b[$i]->{L_BLK} $b[$i]->{LEN}\n"; + my $start_match = $a[$i]->{L_BLK} == $b[$i]->{L_BLK}; + my $len_match = $a[$i]->{LEN} == $b[$i]->{LEN}; + if ( ! ($start_match && ($len_match || $i == (@a - 1)))) + { + # On XFS on Linux kernel 2.6.38, it was seen that the size of the + # last extent can vary, and can extend beyond the length of the file. + # So we ignore the length of the last extent, because if the + # file is the wrong length we'll get failures elsewhere. + die "$ME: differing extent:\n" + . " [$i]=$a[$i]->{L_BLK} $a[$i]->{LEN}\n" + . " [$i]=$b[$i]->{L_BLK} $b[$i]->{LEN}\n"; + } $i++; } |