1.1.0 release
[xfstests-dev.git] / 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 # creator
25 owner=arekm@maven.pl
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38 . ./common.quota
39
40 _cleanup()
41 {
42         cd /
43         umount $SCRATCH_MNT 2>/dev/null
44         rm -f $tmp.*
45 }
46
47 # real QA test starts here
48 _supported_fs xfs
49 _require_xfs_quota
50 _require_scratch
51 _require_projid32bit
52
53 export MOUNT_OPTIONS="-opquota"
54
55 # make fs with no projid32bit
56 _scratch_mkfs_xfs -i projid32bit=0 >> $seq.full || _fail "mkfs failed"
57 _qmount
58 # make sure project quota is supported
59 _require_prjquota ${SCRATCH_DEV}
60
61 dir=$SCRATCH_MNT/project
62
63 status=0
64
65 echo "Silence is golden"
66
67 # Do testing on filesystem with projid32bit feature disabled
68 mkdir $dir
69
70 touch $dir/below16bit
71 # below 16bit value
72 $XFS_QUOTA_PROG -x -c "project -s -p $dir/below16bit 3422" $SCRATCH_DEV \
73                 >> $seq.full
74 projid=$($XFS_IO_PROG -r -c "lsproj" $dir/below16bit)
75 if [ "projid = 3422" != "$projid" ]; then
76         echo "FAIL: projid32bit disabled: returned projid value ($projid)"
77         echo "      doesn't match set one (projid = 3422)"
78         status=1
79 fi
80
81 # 32bit value, should fail
82 touch $dir/over16bit
83 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over16bit 108545" $SCRATCH_DEV \
84                 >> $seq.full 2>&1; then
85         echo "FAIL: projid32bit disabled: setting 32bit projid succeeded"
86         echo "      while it should fail"
87         status=1
88 fi
89
90 # over 32bit value, should fail
91 touch $dir/over32bit
92 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over32bit 5344967296" $SCRATCH_DEV >> $seq.full 2>&1; then
93         echo "FAIL: projid32bit disabled: setting over 32bit projid succeeded"
94         echo "      while it should fail"
95         status=1
96 fi
97
98 #  Do testing on filesystem with projid32bit feature enabled
99 umount $SCRATCH_DEV 2>/dev/null
100 _scratch_mkfs_xfs -i projid32bit=1 >> $seq.full || _fail "mkfs failed"
101 _qmount
102 mkdir $dir
103
104 touch $dir/below16bit
105 # below 16bit value, should succeed
106 $XFS_QUOTA_PROG -x -c "project -s -p $dir/below16bit 3422" $SCRATCH_DEV \
107                 >> $seq.full
108 projid=$($XFS_IO_PROG -r -c "lsproj" $dir/below16bit)
109 if [ "projid = 3422" != "$projid" ]; then
110         echo "FAIL: projid32bit enabled: returned projid value ($projid)"
111         echo "      doesn't match set one (projid = 3422)"
112         status=1
113 fi
114
115 # 32bit value, should succeed
116 touch $dir/over16bit
117 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over16bit 108545" $SCRATCH_DEV \
118                 >> $seq.full 2>&1; then
119         projid=$($XFS_IO_PROG -r -c "lsproj" $dir/over16bit)
120         if [ "projid = 108545" != "$projid" ]; then
121                 echo "FAIL: projid32bit enabled: returned projid value ($projid)"
122                 echo "      doesn't match set one (projid = 108545)"
123                 status=1
124         fi
125 else
126         echo "FAIL: projid32bit enabled: setting 32bit projid failed"
127         echo "      while it should succeed"
128         status=1
129 fi
130
131 # over 32bit value, should fail
132 touch $dir/over32bit
133 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over32bit 5344967296" $SCRATCH_DEV \
134                 >> $seq.full 2>&1; then
135         echo "FAIL: projid32bit enabled: setting over 32bit projid succeeded"
136         echo "      while it should fail"
137         status=1
138 fi