Files
apfstests/tests/generic/306
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

101 lines
3.0 KiB
Bash

#! /bin/bash
# FS QA Test No. 306
#
# Test RW open of a device on a RO fs
#
#-----------------------------------------------------------------------
# Copyright (c) 2013 Red Hat, 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`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
umount $BINDFILE
cd /
rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
# real QA test starts here
# Modify as appropriate.
_supported_fs generic
_supported_os Linux
_require_scratch
DEVNULL=$SCRATCH_MNT/devnull
DEVZERO=$SCRATCH_MNT/devzero
SYMLINK=$SCRATCH_MNT/symlink
BINDFILE=$SCRATCH_MNT/bindfile
TARGET=$TEST_DIR/target
rm -f $seqres.full
_scratch_mkfs > $seqres.full 2>&1
_scratch_mount
rm -f $DEVNULL $DEVZERO
mknod $DEVNULL c 1 3 || _fail "Could not create devnull device"
mknod $DEVZERO c 1 5 || _fail "Could not create devzero device"
touch $BINDFILE || _fail "Could not create bind mount file"
touch $TARGET || _fail "Could not create symlink target"
ln -s $TARGET $SYMLINK
_scratch_unmount || _fail "Could not unmount scratch device"
_scratch_mount -o ro || _fail "Could not mount scratch readonly"
# We should be able to read & write to/from these devices even on an RO fs
echo "== try to create new file"
touch $SCRATCH_MNT/this_should_fail 2>&1 | _filter_scratch
echo "== pwrite to null device"
$XFS_IO_PROG -c "pwrite 0 512" $DEVNULL | _filter_xfs_io
echo "== pread from zero device"
$XFS_IO_PROG -c "pread 0 512" $DEVZERO | _filter_xfs_io
echo "== truncating write to null device"
echo foo > $DEVNULL 2>&1 | _filter_scratch
echo "== appending write to null device"
echo foo >> $DEVNULL 2>&1 | _filter_scratch
echo "== writing to symlink from ro fs to rw fs"
# Various combinations of O_CREAT & O_TRUNC
$XFS_IO_PROG -c "pwrite 0 512" $SYMLINK | _filter_xfs_io
$XFS_IO_PROG -f -c "pwrite 0 512" $SYMLINK | _filter_xfs_io
$XFS_IO_PROG -t -c "pwrite 0 512" $SYMLINK | _filter_xfs_io
echo "== write to bind-mounted rw file on ro fs"
mount --bind $TARGET $BINDFILE
# with and without -f (adds O_CREAT)
$XFS_IO_PROG -c "pwrite 0 512" $BINDFILE | _filter_xfs_io
$XFS_IO_PROG -f -c "pwrite 0 512" $BINDFILE | _filter_xfs_io
$XFS_IO_PROG -t -c "pwrite 0 512" $BINDFILE | _filter_xfs_io
# success, all done
status=0
exit