diff options
author | Eric Sandeen <sandeen@sandeen.net> | 2018-05-17 10:28:26 -0500 |
---|---|---|
committer | Eryu Guan <guaneryu@gmail.com> | 2018-05-21 16:12:39 +0800 |
commit | c3c9630968a66891a134b60ed2a06d71c7a71c3f (patch) | |
tree | 6ef3d8f8832cfc24d2463fbc367fbc5f4e5da4bb | |
parent | 60300eb6e150d1095fb01fe186f9e1bf65337905 (diff) | |
download | xfstests-dev-c3c9630968a66891a134b60ed2a06d71c7a71c3f.tar.gz |
generic: test online label ioctl
This tests the online label ioctl that btrfs has, which has been
recently proposed for XFS.
To run, it requires an updated xfs_io with the label command and a
filesystem that supports it
A slight change here to _require_xfs_io_command as well, so that
tests which simply fail with "Inappropriate ioctl" can be caught in
the common case.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rw-r--r-- | common/rc | 28 | ||||
-rwxr-xr-x | tests/generic/492 | 95 | ||||
-rw-r--r-- | tests/generic/492.out | 13 | ||||
-rw-r--r-- | tests/generic/group | 1 |
4 files changed, 136 insertions, 1 deletions
@@ -2144,6 +2144,9 @@ _require_xfs_io_command() echo $testio | grep -q "Inappropriate ioctl" && \ _notrun "xfs_io $command support is missing" ;; + "label") + testio=`$XFS_IO_PROG -c "label" $TEST_DIR 2>&1` + ;; "open") # -c "open $f" is broken in xfs_io <= 4.8. Along with the fix, # a new -C flag was introduced to execute one shot commands. @@ -2182,7 +2185,7 @@ _require_xfs_io_command() rm -f $testfile 2>&1 > /dev/null echo $testio | grep -q "not found" && \ _notrun "xfs_io $command support is missing" - echo $testio | grep -q "Operation not supported" && \ + echo $testio | grep -q "Operation not supported\|Inappropriate ioctl" && \ _notrun "xfs_io $command failed (old kernel/wrong fs?)" echo $testio | grep -q "Invalid" && \ _notrun "xfs_io $command failed (old kernel/wrong fs/bad args?)" @@ -3788,6 +3791,29 @@ _require_scratch_feature() esac } +# The maximum filesystem label length, /not/ including terminating NULL +_label_get_max() +{ + case $FSTYP in + xfs) + echo 12 + ;; + btrfs) + echo 255 + ;; + *) + _notrun "$FSTYP does not define maximum label length" + ;; + esac +} + +# Helper to check above early in a script +_require_label_get_max() +{ + # Just call _label_get_max which will notrun if appropriate + dummy=$(_label_get_max) +} + init_rc ################################################################################ diff --git a/tests/generic/492 b/tests/generic/492 new file mode 100755 index 0000000000..2dba0c86b9 --- /dev/null +++ b/tests/generic/492 @@ -0,0 +1,95 @@ +#! /bin/bash +# FS QA Test 492 +# +# Test the online filesystem label set/get ioctls +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 Red Hat, Inc. All Rights Reserved. +# Author: Eric Sandeen <sandeen@redhat.com> +# +# 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() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs generic +_supported_os Linux +_require_scratch +_require_xfs_io_command "label" +_require_label_get_max + +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount + +# Make sure we can set & clear the label +$XFS_IO_PROG -c "label -s label.$seq" $SCRATCH_MNT +$XFS_IO_PROG -c "label" $SCRATCH_MNT + +$XFS_IO_PROG -c "label -c" $SCRATCH_MNT +$XFS_IO_PROG -c "label" $SCRATCH_MNT + +# And that userspace can see it now, while mounted +# NB: some blkid has trailing whitespace, filter it out here +$XFS_IO_PROG -c "label -s label.$seq" $SCRATCH_MNT +$XFS_IO_PROG -c "label" $SCRATCH_MNT +blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g" + +# And that the it is still there when it's unmounted +_scratch_unmount +blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g" + +# And that it persists after a remount +_scratch_mount +$XFS_IO_PROG -c "label" $SCRATCH_MNT + +# And that a too-long label is rejected, beyond the interface max: +fs_label=$(perl -e "print 'l' x 257;") +$XFS_IO_PROG -c "label -s $fs_label" $SCRATCH_MNT + +# And it succeeds right at the filesystem max: +max_label_len=$(_label_get_max) +fs_label=$(perl -e "print 'o' x $max_label_len;") +$XFS_IO_PROG -c "label -s $fs_label" $SCRATCH_MNT | sed -e 's/o\+/MAXLABEL/' + +# And that it fails past the filesystem max: +let toolong_label_len=max_label_len+1 +fs_label=$(perl -e "print 'o' x $toolong_label_len;") +$XFS_IO_PROG -c "label -s $fs_label " $SCRATCH_MNT + +# success, all done +status=0 +exit diff --git a/tests/generic/492.out b/tests/generic/492.out new file mode 100644 index 0000000000..b190c66750 --- /dev/null +++ b/tests/generic/492.out @@ -0,0 +1,13 @@ +QA output created by 492 +label = "label.492" +label = "label.492" +label = "" +label = "" +label = "label.492" +label = "label.492" +SCRATCH_DEV: LABEL="label.492" +SCRATCH_DEV: LABEL="label.492" +label = "label.492" +label: Invalid argument +label = "MAXLABEL" +label: Invalid argument diff --git a/tests/generic/group b/tests/generic/group index 4fc3e45717..c84313ac83 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -494,3 +494,4 @@ 489 auto quick attr 490 auto quick rw 491 auto quick freeze mount +492 auto quick |