2f23318d39b698ccfdf43f0790215055c17ed947
[xfstests-dev.git] / tests / xfs / 263
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 263
6 #
7 # test xfs_quota state command
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/quota
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 # real QA test starts here
33
34 # Modify as appropriate.
35 _supported_fs xfs
36 _supported_os Linux
37
38 _require_scratch
39 _require_xfs_quota
40
41 # We could test older, non-project capable kernels but keep it simpler;
42 # Only test crc and beyond (but we will test with and without the feature)
43 _require_xfs_mkfs_crc
44 _require_xfs_crc
45
46 rm -f $seqres.full
47
48 function option_string()
49 {
50         VAL=$1
51         # Treat 3 options as a bit field, prjquota|grpquota|usrquota
52         OPT="rw"
53         if [ "$((VAL & 4))" -ne "0" ]; then OPT=prjquota,${OPT}; fi;
54         if [ "$((VAL & 2))" -ne "0" ]; then OPT=grpquota,${OPT}; fi;
55         if [ "$((VAL & 1))" -ne "0" ]; then OPT=usrquota,${OPT}; fi;
56         echo $OPT
57 }
58
59 filter_quota_state() {
60         sed -e 's/Inode: #[0-9]\+/Inode #XXX/g' \
61             -e '/max warnings:/d' \
62                 | _filter_scratch
63 }
64
65 function test_all_state()
66 {
67         for I in `seq 0 7`; do
68                 OPTIONS=`option_string $I`
69                 echo "== Options: $OPTIONS =="
70                 # Some combinations won't mount on V4 supers (grp + prj)
71                 _qmount_option "$OPTIONS"
72                 _try_scratch_mount &>> $seqres.full || continue
73                 $XFS_QUOTA_PROG -x -c "state" $SCRATCH_MNT | filter_quota_state
74                 _scratch_unmount
75         done
76 }
77
78 echo "==== NO CRC ===="
79 # Control size to control inode numbers
80 _scratch_mkfs_xfs "-m crc=0 -n ftype=0 -d size=512m" >> $seqres.full
81 test_all_state
82
83 echo "==== CRC ===="
84 _scratch_mkfs_xfs "-m crc=1 -d size=512m" >>$seqres.full
85 test_all_state
86
87 status=0
88 exit