generic/050: fix xfsquota configuration failures
[xfstests-dev.git] / tests / generic / 050
index efa45f04825b999cf393660ba2947fc3cae4e465..7eabc7a756976560e7fa8700defeeecac1bd1bd7 100755 (executable)
@@ -1,26 +1,12 @@
 #! /bin/bash
-# FS QA Test No. 050
-#
-# Check out various mount/remount/unmount scenarious on a read-only blockdev.
-#
-#-----------------------------------------------------------------------
+# SPDX-License-Identifier: GPL-2.0
 # 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.
+# FS QA Test No. 050
 #
-# 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
-#-----------------------------------------------------------------------
+# Check out various mount/remount/unmount scenarious on a read-only blockdev.
 #
-
+seqfull=$0
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
@@ -46,8 +32,20 @@ _supported_os Linux
 
 _require_scratch_nocheck
 _require_scratch_shutdown
+_require_local_device $SCRATCH_DEV
 _require_norecovery
 
+# Select appropriate output file
+features=""
+if ! _has_metadata_journaling $SCRATCH_DEV >/dev/null; then
+       features="nojournal"
+elif [ "$FSTYP" = "xfs" ] && echo "$MOUNT_OPTIONS" | grep -q quota ; then
+       # Mounting with quota on XFS requires a writable fs, which means
+       # we expect to fail the ro blockdev test with with EPERM.
+       features="xfsquota"
+fi
+_link_out_file "$features"
+
 _scratch_mkfs >/dev/null 2>&1
 
 #
@@ -60,29 +58,30 @@ blockdev --setro $SCRATCH_DEV
 # Mount it, and make sure we can't write to it, and we can unmount it again
 #
 echo "mounting read-only block device:"
-_scratch_mount 2>&1 | _filter_ro_mount
-
-echo "touching file on read-only filesystem (should fail)"
-touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
+_try_scratch_mount 2>&1 | _filter_ro_mount | _filter_scratch
+if [ "${PIPESTATUS[0]}" -eq 0 ]; then
+       echo "touching file on read-only filesystem (should fail)"
+       touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
+fi
 
 #
 # Apparently this used to be broken at some point:
 #      http://oss.sgi.com/bugzilla/show_bug.cgi?id=807
 #
 echo "unmounting read-only filesystem"
-_scratch_unmount 2>&1 | _filter_scratch
+_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot
 
 echo "setting device read-write"
 blockdev --setrw $SCRATCH_DEV
 
 echo "mounting read-write block device:"
-_scratch_mount 2>&1 | _filter_scratch
+_try_scratch_mount 2>&1 | _filter_scratch
 
 echo "touch files"
 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
 
 echo "going down:"
-src/godown -f $SCRATCH_MNT
+_scratch_shutdown -f
 
 echo "unmounting shutdown filesystem:"
 _scratch_unmount 2>&1 | _filter_scratch
@@ -95,21 +94,20 @@ blockdev --setro $SCRATCH_DEV
 # -o norecovery is used.
 #
 echo "mounting filesystem that needs recovery on a read-only device:"
-_scratch_mount 2>&1 | _filter_ro_mount
+_try_scratch_mount 2>&1 | _filter_ro_mount | _filter_scratch
 
 echo "unmounting read-only filesystem"
 _scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot
 
 #
 # This is the way out if the underlying device really is read-only.
-# Doesn't mean it's a good idea in practive, more a last resort
+# Doesn't mean it's a good idea in practice, more a last resort
 # data recovery hack.
 #
 echo "mounting filesystem with -o norecovery on a read-only device:"
-_scratch_mount -o norecovery 2>&1 | _filter_ro_mount
-
+_try_scratch_mount -o norecovery 2>&1 | _filter_ro_mount | _filter_scratch
 echo "unmounting read-only filesystem"
-_scratch_unmount 2>&1 | _filter_scratch
+_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot
 
 echo "setting device read-write"
 blockdev --setrw $SCRATCH_DEV
@@ -119,7 +117,7 @@ blockdev --setrw $SCRATCH_DEV
 # the underlying device is not write protected.
 #
 echo "mounting filesystem that needs recovery with -o ro:"
-_scratch_mount -o ro 2>&1 | _filter_scratch
+_try_scratch_mount -o ro 2>&1 | _filter_scratch
 
 # success, all done
 echo "*** done"