xfs/530: skip test if user MKFS_OPTIONS screw up formatting
[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 . ./common/preamble
10 _begin_fstest auto quota quick
11
12 # Import common functions.
13 . ./common/filter
14 . ./common/quota
15
16 # Override the default cleanup function.
17 _cleanup()
18 {
19         cd /
20         _scratch_unmount 2>/dev/null
21         rm -f $tmp.*
22 }
23
24 # real QA test starts here
25 _supported_fs xfs
26 _require_xfs_quota
27 _require_scratch
28 _require_projid32bit
29 _require_projid16bit
30
31 export MOUNT_OPTIONS="-opquota"
32
33 # make fs with no projid32bit
34 _scratch_mkfs_xfs -i projid32bit=0 >> $seqres.full || _fail "mkfs failed"
35 _qmount
36 # make sure project quota is supported
37 _require_prjquota ${SCRATCH_DEV}
38
39 dir=$SCRATCH_MNT/project
40
41 status=0
42
43 echo "Silence is golden"
44
45 # Do testing on filesystem with projid32bit feature disabled
46 mkdir $dir
47
48 touch $dir/below16bit
49 # below 16bit value
50 $XFS_QUOTA_PROG -x -c "project -s -p $dir/below16bit 3422" $SCRATCH_DEV \
51                 >> $seqres.full
52 projid=$($XFS_IO_PROG -r -c "lsproj" $dir/below16bit)
53 if [ "projid = 3422" != "$projid" ]; then
54         echo "FAIL: projid32bit disabled: returned projid value ($projid)"
55         echo "      doesn't match set one (projid = 3422)"
56         status=1
57 fi
58
59 # 32bit value, should fail
60 touch $dir/over16bit
61 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over16bit 108545" $SCRATCH_DEV \
62                 >> $seqres.full 2>&1; then
63         echo "FAIL: projid32bit disabled: setting 32bit projid succeeded"
64         echo "      while it should fail"
65         status=1
66 fi
67
68 # over 32bit value, should fail
69 touch $dir/over32bit
70 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over32bit 5344967296" $SCRATCH_DEV >> $seqres.full 2>&1; then
71         echo "FAIL: projid32bit disabled: setting over 32bit projid succeeded"
72         echo "      while it should fail"
73         status=1
74 fi
75
76 #  Do testing on filesystem with projid32bit feature enabled
77 _scratch_unmount 2>/dev/null
78 _scratch_mkfs_xfs -i projid32bit=1 >> $seqres.full || _fail "mkfs failed"
79 _qmount
80 mkdir $dir
81
82 touch $dir/below16bit
83 # below 16bit value, should succeed
84 $XFS_QUOTA_PROG -x -c "project -s -p $dir/below16bit 3422" $SCRATCH_DEV \
85                 >> $seqres.full
86 projid=$($XFS_IO_PROG -r -c "lsproj" $dir/below16bit)
87 if [ "projid = 3422" != "$projid" ]; then
88         echo "FAIL: projid32bit enabled: returned projid value ($projid)"
89         echo "      doesn't match set one (projid = 3422)"
90         status=1
91 fi
92
93 # 32bit value, should succeed
94 touch $dir/over16bit
95 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over16bit 108545" $SCRATCH_DEV \
96                 >> $seqres.full 2>&1; then
97         projid=$($XFS_IO_PROG -r -c "lsproj" $dir/over16bit)
98         if [ "projid = 108545" != "$projid" ]; then
99                 echo "FAIL: projid32bit enabled: returned projid value ($projid)"
100                 echo "      doesn't match set one (projid = 108545)"
101                 status=1
102         fi
103 else
104         echo "FAIL: projid32bit enabled: setting 32bit projid failed"
105         echo "      while it should succeed"
106         status=1
107 fi
108
109 # over 32bit value, should fail
110 touch $dir/over32bit
111 if $XFS_QUOTA_PROG -x -c "project -s -p $dir/over32bit 5344967296" $SCRATCH_DEV \
112                 >> $seqres.full 2>&1; then
113         echo "FAIL: projid32bit enabled: setting over 32bit projid succeeded"
114         echo "      while it should fail"
115         status=1
116 fi