xfstests: move xfs specific tests out of top directory
[xfstests-dev.git] / tests / xfs / 244
1 #! /bin/bash
2 # FS QA Test No. 244
3 #
4 # test to verify that proper project quota id is correctly set
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2010 Arkadiusz Miƛkiewicz.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1        # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
32
33 # get standard environment, filters and checks
34 . ./common.rc
35 . ./common.filter
36 . ./common.quota
37
38 _cleanup()
39 {
40         cd /
41         umount $SCRATCH_MNT 2>/dev/null
42         rm -f $tmp.*
43 }
44
45 # real QA test starts here
46 _supported_fs xfs
47 _require_xfs_quota
48 _require_scratch
49 _require_projid32bit
50
51 export MOUNT_OPTIONS="-opquota"
52
53 # make fs with no projid32bit
54 _scratch_mkfs_xfs -i projid32bit=0 >> $seq.full || _fail "mkfs failed"
55 _qmount
56 # make sure project quota is supported
57 _require_prjquota ${SCRATCH_DEV}
58
59 dir=$SCRATCH_MNT/project
60
61 status=0
62
63 echo "Silence is golden"
64
65 # Do testing on filesystem with projid32bit feature disabled
66 mkdir $dir
67
68 touch $dir/below16bit
69 # below 16bit value
70 $XFS_QUOTA_PROG -x -c "project -s -p $dir/below16bit 3422" $SCRATCH_DEV \
71                 >> $seq.full
72 projid=$($XFS_IO_PROG -r -c "lsproj" $dir/below16bit)
73 if [ "projid = 3422" != "$projid" ]; then
74         echo "FAIL: projid32bit disabled: returned projid value ($projid)"
75         echo "      doesn't match set one (projid = 3422)"
76         status=1
77 fi
78
79 # 32bit value, should fail
80 touch $dir/over16bit
81 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over16bit 108545" $SCRATCH_DEV \
82                 >> $seq.full 2>&1; then
83         echo "FAIL: projid32bit disabled: setting 32bit projid succeeded"
84         echo "      while it should fail"
85         status=1
86 fi
87
88 # over 32bit value, should fail
89 touch $dir/over32bit
90 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over32bit 5344967296" $SCRATCH_DEV >> $seq.full 2>&1; then
91         echo "FAIL: projid32bit disabled: setting over 32bit projid succeeded"
92         echo "      while it should fail"
93         status=1
94 fi
95
96 #  Do testing on filesystem with projid32bit feature enabled
97 umount $SCRATCH_DEV 2>/dev/null
98 _scratch_mkfs_xfs -i projid32bit=1 >> $seq.full || _fail "mkfs failed"
99 _qmount
100 mkdir $dir
101
102 touch $dir/below16bit
103 # below 16bit value, should succeed
104 $XFS_QUOTA_PROG -x -c "project -s -p $dir/below16bit 3422" $SCRATCH_DEV \
105                 >> $seq.full
106 projid=$($XFS_IO_PROG -r -c "lsproj" $dir/below16bit)
107 if [ "projid = 3422" != "$projid" ]; then
108         echo "FAIL: projid32bit enabled: returned projid value ($projid)"
109         echo "      doesn't match set one (projid = 3422)"
110         status=1
111 fi
112
113 # 32bit value, should succeed
114 touch $dir/over16bit
115 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over16bit 108545" $SCRATCH_DEV \
116                 >> $seq.full 2>&1; then
117         projid=$($XFS_IO_PROG -r -c "lsproj" $dir/over16bit)
118         if [ "projid = 108545" != "$projid" ]; then
119                 echo "FAIL: projid32bit enabled: returned projid value ($projid)"
120                 echo "      doesn't match set one (projid = 108545)"
121                 status=1
122         fi
123 else
124         echo "FAIL: projid32bit enabled: setting 32bit projid failed"
125         echo "      while it should succeed"
126         status=1
127 fi
128
129 # over 32bit value, should fail
130 touch $dir/over32bit
131 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over32bit 5344967296" $SCRATCH_DEV \
132                 >> $seq.full 2>&1; then
133         echo "FAIL: projid32bit enabled: setting over 32bit projid succeeded"
134         echo "      while it should fail"
135         status=1
136 fi