common: kill _supported_os
[xfstests-dev.git] / tests / generic / 601
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. 902
6 #
7 # Test individual user ID quota grace period extension
8 # This is the xfs_quota version of the test
9 #
10 # This test only exercises user quota because it's not known whether the
11 # filesystem can set individual grace timers for each quota type
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31 . ./common/quota
32
33 # remove previous $seqres.full before test
34 rm -f $seqres.full
35
36 # real QA test starts here
37 _supported_fs generic
38 _require_scratch
39 _require_quota
40 _require_user
41 # for xfs_quota on generic fs
42 _require_xfs_quota_foreign
43 # for repquota (if setquota supports it, repquota does too)
44 _require_setquota_project
45
46 _scratch_mkfs >$seqres.full 2>&1
47 _qmount_option "usrquota"
48 _qmount
49
50 echo "Silence is golden"
51
52 # Test individual timer update functionality; if "-d" is accepted
53 # this is xfs_quota that can do default /or/ individual timers
54 $XFS_QUOTA_PROG -x -c "timer 0 -d" $SCRATCH_MNT 2>&1 \
55         | grep -q ^timer \
56         && _notrun "xfs_quota does not support individual grace extension"
57
58 # Set a default user inode grace period of 1 second
59 $XFS_QUOTA_PROG -x -c "timer -u -i -d 1" $SCRATCH_MNT
60 # Soft inode limit 1, hard limit 5
61 $XFS_QUOTA_PROG -x -c "limit -u isoft=1 ihard=5 $qa_user" $SCRATCH_MNT
62 # Run qa user over soft limit and go over grace period
63 su $qa_user -c "touch $SCRATCH_MNT/file1 $SCRATCH_MNT/file2"
64 sleep 3
65 # Extend grace to now + 100s
66 now=`date +%s`
67 let set=now+100
68 $XFS_QUOTA_PROG -x -c "timer -u -i 100 $qa_user" $SCRATCH_MNT
69 # XXX We use repquota because xfs_quota doesn't know how to return
70 # raw ("since epoch") grace expiry
71 get=`repquota -up $SCRATCH_MNT | grep  "^$qa_user" | awk '{print $NF}'`
72
73 # Either the new expiry must match; or be one second after the set time, to
74 # deal with the seconds counter incrementing.
75 if [ "$get" != "$set" ] && [ "$get" -ne "$((set + 1))" ]; then
76         echo "set grace to $set but got grace $get"
77 fi
78
79 # success, all done
80 status=0
81 exit