fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / xfs / 244
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2010 Arkadiusz Miƛkiewicz.  All Rights Reserved.
4 #
5 # FS QA Test No. 244
6 #
7 # test to verify that proper project quota id is correctly set
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 # get standard environment, filters and checks
19 . ./common/rc
20 . ./common/filter
21 . ./common/quota
22
23 _cleanup()
24 {
25         cd /
26         _scratch_unmount 2>/dev/null
27         rm -f $tmp.*
28 }
29
30 # real QA test starts here
31 _supported_fs xfs
32 _require_xfs_quota
33 _require_scratch
34 _require_projid32bit
35 _require_projid16bit
36
37 export MOUNT_OPTIONS="-opquota"
38
39 rm -f $seqres.full
40 # make fs with no projid32bit
41 _scratch_mkfs_xfs -i projid32bit=0 >> $seqres.full || _fail "mkfs failed"
42 _qmount
43 # make sure project quota is supported
44 _require_prjquota ${SCRATCH_DEV}
45
46 dir=$SCRATCH_MNT/project
47
48 status=0
49
50 echo "Silence is golden"
51
52 # Do testing on filesystem with projid32bit feature disabled
53 mkdir $dir
54
55 touch $dir/below16bit
56 # below 16bit value
57 $XFS_QUOTA_PROG -x -c "project -s -p $dir/below16bit 3422" $SCRATCH_DEV \
58                 >> $seqres.full
59 projid=$($XFS_IO_PROG -r -c "lsproj" $dir/below16bit)
60 if [ "projid = 3422" != "$projid" ]; then
61         echo "FAIL: projid32bit disabled: returned projid value ($projid)"
62         echo "      doesn't match set one (projid = 3422)"
63         status=1
64 fi
65
66 # 32bit value, should fail
67 touch $dir/over16bit
68 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over16bit 108545" $SCRATCH_DEV \
69                 >> $seqres.full 2>&1; then
70         echo "FAIL: projid32bit disabled: setting 32bit projid succeeded"
71         echo "      while it should fail"
72         status=1
73 fi
74
75 # over 32bit value, should fail
76 touch $dir/over32bit
77 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over32bit 5344967296" $SCRATCH_DEV >> $seqres.full 2>&1; then
78         echo "FAIL: projid32bit disabled: setting over 32bit projid succeeded"
79         echo "      while it should fail"
80         status=1
81 fi
82
83 #  Do testing on filesystem with projid32bit feature enabled
84 _scratch_unmount 2>/dev/null
85 _scratch_mkfs_xfs -i projid32bit=1 >> $seqres.full || _fail "mkfs failed"
86 _qmount
87 mkdir $dir
88
89 touch $dir/below16bit
90 # below 16bit value, should succeed
91 $XFS_QUOTA_PROG -x -c "project -s -p $dir/below16bit 3422" $SCRATCH_DEV \
92                 >> $seqres.full
93 projid=$($XFS_IO_PROG -r -c "lsproj" $dir/below16bit)
94 if [ "projid = 3422" != "$projid" ]; then
95         echo "FAIL: projid32bit enabled: returned projid value ($projid)"
96         echo "      doesn't match set one (projid = 3422)"
97         status=1
98 fi
99
100 # 32bit value, should succeed
101 touch $dir/over16bit
102 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over16bit 108545" $SCRATCH_DEV \
103                 >> $seqres.full 2>&1; then
104         projid=$($XFS_IO_PROG -r -c "lsproj" $dir/over16bit)
105         if [ "projid = 108545" != "$projid" ]; then
106                 echo "FAIL: projid32bit enabled: returned projid value ($projid)"
107                 echo "      doesn't match set one (projid = 108545)"
108                 status=1
109         fi
110 else
111         echo "FAIL: projid32bit enabled: setting 32bit projid failed"
112         echo "      while it should succeed"
113         status=1
114 fi
115
116 # over 32bit value, should fail
117 touch $dir/over32bit
118 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over32bit 5344967296" $SCRATCH_DEV \
119                 >> $seqres.full 2>&1; then
120         echo "FAIL: projid32bit enabled: setting over 32bit projid succeeded"
121         echo "      while it should fail"
122         status=1
123 fi