generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 594
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 594
6 #
7 # Test per-type(user, group and project) filesystem quota timers, make sure
8 # each of grace time can be set/get properly.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/quota
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # real QA test starts here
34 _supported_fs generic
35 _supported_os Linux
36 _require_scratch
37 _require_setquota_project
38 # V4 XFS doesn't support to mount project and group quota together
39 if [ "$FSTYP" = "xfs" ];then
40         _require_scratch_xfs_crc
41 fi
42 _require_quota
43
44 _scratch_mkfs >$seqres.full 2>&1
45 _scratch_enable_pquota
46 _qmount_option "usrquota,grpquota,prjquota"
47 _qmount
48 _require_prjquota $SCRATCH_DEV
49
50 MIN=60
51
52 # get default time at first
53 def_time=`repquota -u $SCRATCH_MNT | \
54                 sed -n -e "/^Block/s/.* time: \(.*\); .* time: \(.*\)/\1 \2/p"`
55 echo "Default block and inode grace timers are: $def_time" >> $seqres.full
56
57 filter_repquota()
58 {
59         local blocktime=$1
60         local inodetime=$2
61
62         _filter_scratch | sed -e "s,$blocktime,DEF_TIME,g" \
63                               -e "s,$inodetime,DEF_TIME,g"
64 }
65
66 echo "1. set project quota timer"
67 setquota -t -P $((10 * MIN)) $((20 * MIN)) $SCRATCH_MNT
68 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
69 echo
70
71 echo "2. set group quota timer"
72 setquota -t -g $((30 * MIN)) $((40 * MIN)) $SCRATCH_MNT
73 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
74 echo
75
76 echo "3. set user quota timer"
77 setquota -t -u $((50 * MIN)) $((60 * MIN)) $SCRATCH_MNT
78 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
79 echo
80
81 # cycle mount, make sure the quota timers are still right
82 echo "4. cycle mount test-1"
83 _qmount
84 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
85 echo
86
87 # Run repair to force quota check
88 echo "5. fsck to force quota check"
89 _scratch_unmount
90 _repair_scratch_fs >> $seqres.full 2>&1
91 echo
92
93 # Remount (this time to run quotacheck) and check the limits.  There's a bug
94 # in quotacheck where we would reset the ondisk default grace period to zero
95 # while the incore copy stays at whatever was read in prior to quotacheck.
96 # This will show up after the /next/ remount.
97 echo "6. cycle mount test-2"
98 _qmount
99 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
100 echo
101
102 # Remount and check the limits
103 echo "7. cycle mount test-3"
104 _qmount
105 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
106
107 # success, all done
108 status=0
109 exit