Files
apfstests/203
T
Dave Chinner 815637a2da xfsqa: make hole tests independent of speculative allocation patterns
Many of the "count-the-holes" tests (008, 012, etc) do writes that extend the
file and hence allocation patterns are dependent on speculative allocation
beyond EOF behaviour. Hence if we change that behaviour, these tests all fail
because there is a different pattern of holes.

Make the tests independent of EOF preallocation behaviour by first truncating
the file to the size the test is defined to use. This prevents speculative
prealocation from occurring, and hence changes in such behaviour will not cause
the tests to fail.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
2011-01-07 23:59:15 +11:00

90 lines
2.1 KiB
Bash
Executable File

#! /bin/bash
# FS QA Test No. 203
#
# Test out reallocation of the extent array in xfs_io.
# Based on a testcase from Tomasz Majkowski <moosh009@gmail.com>.
#
#-----------------------------------------------------------------------
# Copyright (c) 2009 Christoph Hellwig.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#-----------------------------------------------------------------------
#
# creator
owner=hch@lst.de
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_write_holes()
{
file=$1
holes=$2
let writes=$holes+1
let fsize=$(($writes * 0x100000))
# prevent EOF preallocation from affecting results
xfs_io -f $file -c "truncate $fsize"
offset=0
for i in `seq 0 $writes`; do
xfs_io -f $file -c "pwrite -q $offset 1"
let offset=$offset+0x100000
done
}
# 0: [0..7]: 104..111
# 1: [8..2047]: hole
_filter_bmap()
{
_filter_test_dir |
awk '$3 ~ /hole/ { print $1, $2, $3; next }
{print $1, $2; next}'
}
_cleanup()
{
rm -f $TEST_DIR/hole_file*
rm -f $TEST_DIR/r??
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
# real QA test starts here
_supported_fs xfs
_supported_os Linux
for i in 10 14 15 16 17 28 29 30 31; do
rm -f $TEST_DIR/hole_file
_write_holes $TEST_DIR/hole_file${i} ${i}
done
for i in 10 14 15 16 17 28 29 30 31; do
xfs_bmap $TEST_DIR/hole_file${i} | _filter_bmap
echo
done
# success, all done
echo "*** done"
rm -f $seq.full
status=0