On Fri, Aug 05, 2022 at 07:25:31PM +0200, Andrey Albershteyn wrote: > These parameters define ID range of users/groups/projects to show. > This test adds more checks for wider coverage (e.g. empty range, > full range, open range). > > Signed-off-by: Andrey Albershteyn <aalbersh@xxxxxxxxxx> > --- > > This is regression test in relation to the patch [1]. If this's a regression test case for a specific patchset, will it fail on the kernel without this patchset? > > Changes from v1: > - Moved to separate test (initially added to 152) > Changes from v2: > - sed expression simplification > - remove _filter_trailing_spaces() from common/filter > - easier to read test cases > > [1]: https://lore.kernel.org/all/20220328222503.146496-1-aalbersh@xxxxxxxxxx/ > > --- > tests/xfs/550 | 169 +++++++++++++++++++++++++++++++++ > tests/xfs/550.out | 232 ++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 401 insertions(+) > create mode 100755 tests/xfs/550 > create mode 100644 tests/xfs/550.out > > diff --git a/tests/xfs/550 b/tests/xfs/550 > new file mode 100755 > index 00000000..1fc1d37c > --- /dev/null > +++ b/tests/xfs/550 > @@ -0,0 +1,169 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2022 Andrey Albershteyn <aalbersh@xxxxxxxxxx>. > +# All Rights Reserved. > +# > +# FS QA Test 550 > +# > +# Test xfs_quota -L/-U range parameters for report and dump commands. These > +# parameters define ID range of users/groups/projects with non-zero quota to > +# show. > +# > +. ./common/preamble > +_begin_fstest quick quota Can it be in "auto" group? > + > +# Override the default cleanup function. > +_cleanup() > +{ > + _scratch_unmount >/dev/null 2>&1 Why a _scratch_unmount is needed at here? I think this case doesn't need a specific _cleanup. > + cd / > + rm -f $tmp.* > +} > + > +# Import common functions. > +. ./common/filter > +. ./common/quota > + > +# real QA test starts here > +_supported_fs xfs > +_require_test I didn't see this case need TEST_DIR, so this requirement might be useless > +_require_scratch > +_require_xfs_quota > +_require_user fsgqa > +_require_user fsgqa2 > +_require_group fsgqa > +_require_group fsgqa2 > + > +_scratch_mkfs_xfs >>$seqres.full || _fail "mkfs failed" > + > +uqid=`id -u fsgqa` > +gqid=`id -g fsgqa` > + > +uqid2=`id -u fsgqa2` > +gqid2=`id -g fsgqa2` > + > +[ $uqid -ge $uqid2 ] && _notrun \ > + "ID of fsgqa user ($uqid) expected to be lower than fsgqa2 ($uqid2)" > +[ $gqid -ge $gqid2 ] && _notrun \ > + "ID of fsgqa group ($gqid) expected to be lower than fsgqa2 ($gqid2)" > + > +pqid=10 > +pqid2=42 > +cat >$tmp.projects <<EOF > +$pqid:$SCRATCH_MNT > +$pqid2:$SCRATCH_MNT > +EOF > + > +cat >$tmp.projid <<EOF > +root:0 > +fsgqa:$pqid > +fsgqa2:$pqid2 > +EOF > + > +filter_dump() > +{ > + _filter_scratch | sed -e 's/^[0-9]\+/#ID/' -e 's/\s*$//' > +} > + > +filter_report() > +{ > + _filter_quota | sed -e '/^root/d' \ > + -e '/^#0/d' \ > + -e 's/^#[0-9]\+/#ID/' \ > + -e 's/\s*$//' > +} > + > +set_quota_limit() > +{ > + local bs=$1 > + local bh=$2 > + local is=$3 > + local ih=$4 > + local user=$5 > + > + $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \ > + -c "limit -$type bsoft=$bs bhard=$bh $user" \ > + -c "limit -$type isoft=$is ihard=$ih $user" \ > + $SCRATCH_MNT > +} > + > +test_dump() > +{ > + local description=$1 ; shift > + local opt="$*" > + > + echo "Options: $description" > + > + rm -f $tmp.backup 2>>/dev/null > + $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \ > + -c "dump -$type $opt -f $tmp.backup" \ > + $SCRATCH_MNT | _filter_scratch > + cat $tmp.backup | filter_dump > +} > + > +test_report() > +{ > + local description=$1 ; shift > + local opt="$*" > + > + echo "Options: $description" > + > + $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \ > + -c "report -$type $opt -bi" \ > + $SCRATCH_MNT | filter_report > +} > + > +test_xfs_quota() > +{ > + set_quota_limit 512k 2048k 10 20 $id > + set_quota_limit 1024k 4096k 10 20 $id2 > + > + echo "dump options test (type=$type)" > + test_dump "no options (full range)" > + test_dump "-L option" -L $id > + test_dump "-U option" -U $id > + test_dump "-L/-U options (one element range)" -L $id -U $id > + test_dump "-L/-U options (multiple elements range)" -L $id -U $id2 > + test_dump "-L/-U options (empty range)" -L $id2 -U $id > + test_dump "-L/-U options (full range)" -L 0 -U 0 > + > + echo "report options test (type=$type)" > + test_report "no options (full range)" > + test_report "-L options" -L $id > + test_report "-U options" -U $id > + test_report "-L/-U options (one element range)" -L $id -U $id > + test_report "-L/-U options (multiple elements range)" -L $id -U $id2 > + test_report "-L/-U options (empty range)" -L $id2 -U $id > + test_report "-L/-U options (full range)" -L 0 -U 0 > +} > + > +echo "Checking User quota" > +_scratch_unmount >/dev/null 2>&1 > +_qmount_option "uquota" > +_try_scratch_mount || _fail "qmount failed" Why not use "_qmount" directly? (same below) Thanks, Zorro > +type=u > +id=$uqid > +id2=$uqid2 > +test_xfs_quota > + > +echo "Checking Group quota" > +_scratch_unmount >/dev/null 2>&1 > +_qmount_option "gquota" > +_try_scratch_mount || _fail "qmount failed" > +type=g > +id=$gqid > +id2=$gqid2 > +test_xfs_quota > + > +echo "Checking Project quota" > +_scratch_unmount >/dev/null 2>&1 > +_qmount_option "pquota" > +_try_scratch_mount || _fail "qmount failed" > +type=p > +id=$pqid > +id2=$pqid2 > +test_xfs_quota > + > +# success, all done > +status=0 > +exit > diff --git a/tests/xfs/550.out b/tests/xfs/550.out > new file mode 100644 > index 00000000..d98166c4 > --- /dev/null > +++ b/tests/xfs/550.out > @@ -0,0 +1,232 @@ > +QA output created by 550 > +Checking User quota > +dump options test (type=u) > +Options: no options (full range) > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +fs = SCRATCH_DEV > +#ID 2048 8192 10 20 > +Options: -L option > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +fs = SCRATCH_DEV > +#ID 2048 8192 10 20 > +Options: -U option > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +Options: -L/-U options (one element range) > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +Options: -L/-U options (multiple elements range) > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +fs = SCRATCH_DEV > +#ID 2048 8192 10 20 > +Options: -L/-U options (empty range) > +Options: -L/-U options (full range) > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +fs = SCRATCH_DEV > +#ID 2048 8192 10 20 > +report options test (type=u) > +Options: no options (full range) > +User quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +User ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +fsgqa 0 512 2048 00 [--------] 0 10 20 00 [--------] > +fsgqa2 0 1024 4096 00 [--------] 0 10 20 00 [--------] > + > +Options: -L options > +User quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +User ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > +#ID 0 1024 4096 00 [--------] 0 10 20 00 [--------] > + > +Options: -U options > +User quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +User ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > + > +Options: -L/-U options (one element range) > +User quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +User ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > + > +Options: -L/-U options (multiple elements range) > +User quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +User ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > +#ID 0 1024 4096 00 [--------] 0 10 20 00 [--------] > + > +Options: -L/-U options (empty range) > +Options: -L/-U options (full range) > +User quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +User ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > +#ID 0 1024 4096 00 [--------] 0 10 20 00 [--------] > + > +Checking Group quota > +dump options test (type=g) > +Options: no options (full range) > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +fs = SCRATCH_DEV > +#ID 2048 8192 10 20 > +Options: -L option > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +fs = SCRATCH_DEV > +#ID 2048 8192 10 20 > +Options: -U option > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +Options: -L/-U options (one element range) > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +Options: -L/-U options (multiple elements range) > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +fs = SCRATCH_DEV > +#ID 2048 8192 10 20 > +Options: -L/-U options (empty range) > +Options: -L/-U options (full range) > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +fs = SCRATCH_DEV > +#ID 2048 8192 10 20 > +report options test (type=g) > +Options: no options (full range) > +Group quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +Group ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +fsgqa 0 512 2048 00 [--------] 0 10 20 00 [--------] > +fsgqa2 0 1024 4096 00 [--------] 0 10 20 00 [--------] > + > +Options: -L options > +Group quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +Group ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > +#ID 0 1024 4096 00 [--------] 0 10 20 00 [--------] > + > +Options: -U options > +Group quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +Group ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > + > +Options: -L/-U options (one element range) > +Group quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +Group ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > + > +Options: -L/-U options (multiple elements range) > +Group quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +Group ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > +#ID 0 1024 4096 00 [--------] 0 10 20 00 [--------] > + > +Options: -L/-U options (empty range) > +Options: -L/-U options (full range) > +Group quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +Group ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > +#ID 0 1024 4096 00 [--------] 0 10 20 00 [--------] > + > +Checking Project quota > +dump options test (type=p) > +Options: no options (full range) > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +fs = SCRATCH_DEV > +#ID 2048 8192 10 20 > +Options: -L option > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +fs = SCRATCH_DEV > +#ID 2048 8192 10 20 > +Options: -U option > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +Options: -L/-U options (one element range) > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +Options: -L/-U options (multiple elements range) > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +fs = SCRATCH_DEV > +#ID 2048 8192 10 20 > +Options: -L/-U options (empty range) > +Options: -L/-U options (full range) > +fs = SCRATCH_DEV > +#ID 1024 4096 10 20 > +fs = SCRATCH_DEV > +#ID 2048 8192 10 20 > +report options test (type=p) > +Options: no options (full range) > +Project quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +fsgqa 0 512 2048 00 [--------] 0 10 20 00 [--------] > +fsgqa2 0 1024 4096 00 [--------] 0 10 20 00 [--------] > + > +Options: -L options > +Project quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > +#ID 0 1024 4096 00 [--------] 0 10 20 00 [--------] > + > +Options: -U options > +Project quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > + > +Options: -L/-U options (one element range) > +Project quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > + > +Options: -L/-U options (multiple elements range) > +Project quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > +#ID 0 1024 4096 00 [--------] 0 10 20 00 [--------] > + > +Options: -L/-U options (empty range) > +Options: -L/-U options (full range) > +Project quota on SCRATCH_MNT (SCRATCH_DEV) > + Blocks Inodes > +Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace > +---------- -------------------------------------------------- -------------------------------------------------- > +#ID 0 512 2048 00 [--------] 0 10 20 00 [--------] > +#ID 0 1024 4096 00 [--------] 0 10 20 00 [--------] > + > -- > 2.31.1 >