common/filter: refactor quota report filtering
[xfstests-dev.git] / tests / xfs / 050
index 788ed7f1ad89da1d2fe4443701afe3bfac044e07..1df975379922a5e3c92718aed4f5a2e59005f8f6 100755 (executable)
@@ -30,7 +30,6 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # real QA test starts here
 _supported_fs xfs
-_supported_os Linux
 
 cp /dev/null $seqres.full
 chmod a+rwx $seqres.full       # arbitrary users will write here
@@ -48,23 +47,6 @@ bhard=$(( 1000 * $bsize ))
 isoft=4
 ihard=10
 
-_filter_report()
-{
-       tr -s '[:space:]' | \
-       perl -npe '
-               s/^\#'$id' /[NAME] /g;
-               s/^\#0 \d+ /[ROOT] 0 /g;
-               s/6 days/7 days/g' |
-       perl -npe '
-               $val = 0;
-               if ($ENV{'LARGE_SCRATCH_DEV'}) {
-                       $val = $ENV{'NUM_SPACE_FILES'};
-               }
-               s/(^\[ROOT\] \S+ \S+ \S+ \S+ \[--------\] )(\S+)/$1@{[$2 - $val]}/g' |
-       perl -npe '
-               s|^(.*?) (\d+) (\d+) (\d+)|$1 @{[$2 * 1024 /'$bsize']} @{[$3 * 1024 /'$bsize']} @{[$4 * 1024 /'$bsize']}|'
-}
-
 # The actual point at which limit enforcement takes place for the
 # hard block limit is variable depending on filesystem blocksize,
 # and iosize.  What we want to test is that the limit is enforced
@@ -84,7 +66,7 @@ _filter_and_check_blks()
                        }
                        s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
                }
-       ' | _filter_report
+       ' | _filter_quota_report
 }
 
 _qsetup()
@@ -128,24 +110,26 @@ _exercise()
 
        echo "Using type=$type id=$id" >>$seqres.full
 
+       $XFS_QUOTA_PROG -x -c "warn -$type 65535 -d" $SCRATCH_DEV
+
        echo
        echo "*** report no quota settings" | tee -a $seqres.full
-       xfs_quota -D $tmp.projects -P $tmp.projid -x \
+       $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
                -c "repquota -birnN -$type" $SCRATCH_DEV |
-               _filter_report | LC_COLLATE=POSIX sort -ru
+               _filter_quota_report | LC_COLLATE=POSIX sort -ru
 
        echo
        echo "*** report initial settings" | tee -a $seqres.full
        _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
        echo "ls -l $SCRATCH_MNT" >>$seqres.full
        ls -l $SCRATCH_MNT >>$seqres.full
-       xfs_quota -D $tmp.projects -P $temp.projid -x \
+       $XFS_QUOTA_PROG -D $tmp.projects -P $temp.projid -x \
                -c "limit -$type bsoft=${bsoft} bhard=${bhard} $id" \
                -c "limit -$type isoft=$isoft ihard=$ihard $id" \
                $SCRATCH_DEV
-       xfs_quota -D $tmp.projects -P $tmp.projid -x \
+       $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
                -c "repquota -birnN -$type" $SCRATCH_DEV |
-               _filter_report | LC_COLLATE=POSIX sort -ru
+               _filter_quota_report | LC_COLLATE=POSIX sort -ru
 
        echo
        echo "*** push past the soft inode limit" | tee -a $seqres.full
@@ -154,17 +138,20 @@ _exercise()
        _file_as_id $SCRATCH_MNT/softie3 $id $type 1024 0
        _file_as_id $SCRATCH_MNT/softie4 $id $type 1024 0
        _qmount
-       xfs_quota -D $tmp.projects -P $tmp.projid -x \
+       $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" $SCRATCH_DEV
+       $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
                -c "repquota -birnN -$type" $SCRATCH_DEV |
-               _filter_report | LC_COLLATE=POSIX sort -ru
+               _filter_quota_report | LC_COLLATE=POSIX sort -ru
 
        echo
        echo "*** push past the soft block limit" | tee -a $seqres.full
        _file_as_id $SCRATCH_MNT/softie $id $type $bsize 300
        _qmount
-       xfs_quota -D $tmp.projects -P $tmp.projid -x \
+       $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" \
+               -c "warn -b -$type 0 $id" $SCRATCH_DEV
+       $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
                -c "repquota -birnN -$type" $SCRATCH_DEV |
-               _filter_report | LC_COLLATE=POSIX sort -ru
+               _filter_quota_report | LC_COLLATE=POSIX sort -ru
 
        echo
        # Note: for quota accounting (not enforcement), EDQUOT is not expected
@@ -174,9 +161,11 @@ _exercise()
                _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
        done
        _qmount
-       xfs_quota -D $tmp.projects -P $tmp.projid -x \
+       $XFS_QUOTA_PROG -x  -c "warn -b -$type 0 $id" \
+               -c "warn -i -$type 0 $id" $SCRATCH_DEV
+       $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
                -c "repquota -birnN -$type" $SCRATCH_DEV |
-               _filter_report | LC_COLLATE=POSIX sort -ru
+               _filter_quota_report | LC_COLLATE=POSIX sort -ru
 
        echo
        # Note: for quota accounting (not enforcement), EDQUOT is not expected
@@ -185,7 +174,8 @@ _exercise()
        echo "ls -l $SCRATCH_MNT" >>$seqres.full
        ls -l $SCRATCH_MNT >>$seqres.full
        _qmount
-       xfs_quota -D $tmp.projects -P $tmp.projid -x \
+       $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" $SCRATCH_DEV
+       $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
                -c "repquota -birnN -$type" $SCRATCH_DEV |
                _filter_and_check_blks | LC_COLLATE=POSIX sort -ru