Files
apfstests/tests/generic/286
T
Eric Sandeen 96fce07867 xfstests: automatically add -F to xfs_io on non-xfs
The -F flag to xfs_io originally enabled it to operate on non-xfs
filesystems.  This restriction was removed upstream in favor of
gracefully failing on the handful of operations that actually
required xfs, and the option was deprecated.

However, xfstests is still used on distros with older xfsprogs, and
so "xfs_io -F" was necessary throughout xfstests.

Simplify this by appending -F to XFS_IO_PROG when it's needed -
i.e. if we're using old xfsprogs on a non-xfs filesystem.

This will eliminate errors when new tests leave out the -F, and
if and when -F is finally removed, there will be one central
location in xfstests to update.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Acked-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Rich Johnston <rjohnston@sgi.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
2013-05-14 08:33:44 -05:00

199 lines
5.6 KiB
Bash
Executable File

#! /bin/bash
# FS QA Test No. 286
#
# SEEK_DATA/SEEK_HOLE copy tests.
#
#-----------------------------------------------------------------------
# Copyright (c) 2011 Oracle Inc. All Rights Reserved.
#
# 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
#
#-----------------------------------------------------------------------
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
status=1 # failure is the default!
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 generic
_supported_os Linux
src=$TEST_DIR/seek_copy_testfile
dest=$TEST_DIR/seek_copy_testfile.dest
[ -x $here/src/seek_copy_test ] || _notrun "seek_copy_test not built"
_cleanup()
{
rm -f $src $dest
}
# seek_copy_test_01: tests file with holes and written data extents.
# verify results:
# 1. file size is identical.
# 2. perform cmp(1) to compare SRC and DEST file byte by byte.
test01()
{
rm -f $src $dest
write_cmd="-c \"truncate 100m\""
for i in $(seq 0 5 100); do
offset=$(($i * $((1 << 20))))
write_cmd="$write_cmd -c \"pwrite $offset 1m\""
done
echo "*** test01() create sparse file ***" >>$seqres.full
eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
_fail "create sparse file failed!"
echo "*** test01() create sparse file done ***" >>$seqres.full
echo >>$seqres.full
$here/src/seek_copy_test $src $dest
test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
_fail "TEST01: file size check failed"
cmp $src $dest || _fail "TEST01: file bytes check failed"
}
# seek_copy_test_02 - tests file with holes, written and unwritten extents.
# verify results:
# 1. file size is identical.
# 2. perform cmp(1) to compare SRC and DEST file byte by byte.
test02()
{
rm -rf $src $dest
write_cmd="-c \"truncate 200m\""
for i in $(seq 0 10 100); do
offset=$(($((6 << 20)) + $i * $((1 << 20))))
write_cmd="$write_cmd -c \"falloc $offset 3m\" -c \"pwrite $offset 1m\""
done
echo "*** test02() create sparse file ***" >>$seqres.full
eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
_fail "create sparse file failed!"
echo "*** test02() create sparse file done ***" >>$seqres.full
echo >>$seqres.full
$here/src/seek_copy_test $src $dest
test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
_fail "TEST02: file size check failed"
cmp $src $dest || _fail "TEST02: file bytes check failed"
}
# seek_copy_test_03 - tests file with unwritten with data, repeated unwritten
# without data, as well as data extents mapping.
# verify results:
# 1. file size is identical.
# 2. perform cmp(1) to compare SRC and DEST file byte by byte.
test03()
{
rm -rf $src $dest
write_cmd="-c \"truncate 200m\""
#
# Firstly, make the file with allocated && reserved extents
# mapping without real data wrote.
#
for i in $(seq 0 10 180); do
offset=$(($((10 << 20)) + $i * $((1 << 20))))
write_cmd="$write_cmd -c \"falloc $offset 10m\""
done
#
# Secondly, write data to some unwritten extents, hence we
# have a test file will extents mapping as:
# |data|multiple unwritten_without_data|data| repeat...
for i in $(seq 0 60 180); do
offset=$(($((20 << 20)) + $i * $((1 << 20))))
write_cmd="$write_cmd -c \"pwrite $offset 10m\""
done
echo "*** test03() create sparse file ***" >>$seqres.full
eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
_fail "create sparse file failed!"
echo "*** test03() create sparse file done ***" >>$seqres.full
echo >>$seqres.full
$here/src/seek_copy_test $src $dest
test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
_fail "TEST03: file size check failed"
cmp $src $dest || _fail "TEST03: file bytes check failed"
}
# seek_copy_test_04 - tests file with hole, repeated unwritten
# without data, as well as data extents mapping.
# verify results:
# 1. file size is identical.
# 2. perform cmp(1) to compare SRC and DEST file byte by byte.
test04()
{
rm -rf $src $dest
write_cmd="-c \"truncate 200m\""
#
# Firstly, make the file with allocated && reserved extents
# mapping without real data wrote.
#
for i in $(seq 30 30 180); do
offset=$(($((30 << 20)) + $i * $((1 << 20))))
write_cmd="$write_cmd -c \"falloc $offset 5m\""
done
#
# Secondly, write data to some unwritten extents, hence we
# have a test file will extents mapping as:
# |hole|multiple unwritten_without_data|hole|data| repeat...
for i in $(seq 30 90 180); do
offset=$(($((30 << 20)) + $i * $((1 << 20))))
write_cmd="$write_cmd -c \"pwrite $offset 2m\""
done
echo "*** test04() create sparse file ***" >>$seqres.full
eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
_fail "create sparse file failed!"
echo "*** test04() create sparse file done ***" >>$seqres.full
echo >>$seqres.full
$here/src/seek_copy_test $src $dest
test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
_fail "TEST04: file size check failed"
cmp $src $dest || _fail "TEST04: file bytes check failed"
}
rm -f $seqres.full
test01
test02
test03
test04
status=0
exit