xfstests: Assume yes when test device is not partitioned
[xfstests-dev.git] / 234
1 #! /bin/bash
2 # FS QA Test No. 234
3 #
4 # Stress setquota and setinfo handling.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2010 Jan Kara.  All Rights Reserved.
8 #
9 # Based on test 219,
10 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #
25 #-----------------------------------------------------------------------
26 #
27 # creator
28 owner=jack@suse.cz
29
30 seq=`basename $0`
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
37
38 # get standard environment, filters and checks
39 . ./common.rc
40 . ./common.filter
41 . ./common.quota
42
43 test_setting()
44 {
45         echo; echo "### test limits and info setting"
46         count=2000
47         procs=5
48         idmod=200000
49         seed=$RANDOM
50         RANDOM=$seed
51         echo "Starting test with procs=$procs, idmod=$idmod, and seed=$seed" >>$seq.full
52
53         for (( i = 0; i < $procs; i++ )); do
54                 ( SETUCOUNT=1; SETGCOUNT=1; SETUIDS[0]=0; SETGIDS[0]=0
55                 for (( j = 0; j < $count; j++ )); do
56                         OP=$(($RANDOM%22))
57                         UG=$(($OP%2))
58                         OP=$(($OP/2))
59                         if [ $UG -eq 1 ]; then
60                                 type='u'
61                         else
62                                 type='g'
63                         fi
64                         if [ $OP -eq 10 ]; then
65                                 setquota -t -$type $j $j $SCRATCH_MNT
66                         elif [ $OP -lt 5 ]; then
67                                 ID=$((($RANDOM*32768+$RANDOM)%$idmod))
68                                 if [ $UG -eq 1 ]; then
69                                         SETUIDS[$SETUCOUNT]=$ID
70                                         SETUCOUNT=$(($SETUCOUNT+1))
71                                 else
72                                         SETGIDS[$SETGCOUNT]=$ID
73                                         SETGCOUNT=$(($SETGCOUNT+1))
74                                 fi
75                                 setquota -$type $ID $j $j $j $j $SCRATCH_MNT
76                         else
77                                 if [ $UG -eq 1 ]; then
78                                         ID=${SETUIDS[$(($RANDOM%$SETUCOUNT))]}
79                                 else
80                                         ID=${SETGIDS[$(($RANDOM%$SETGCOUNT))]}
81                                 fi
82                                 setquota -$type $ID 0 0 0 0 $SCRATCH_MNT
83                         fi
84                 done )&
85         done
86         wait
87         echo "### done with testing"
88 }
89
90 # real QA test starts here
91 _supported_fs generic
92 _supported_os Linux #IRIX
93 _require_scratch
94 _require_quota
95 _need_to_be_root
96
97 # real QA test starts here
98 rm -f $seq.full
99
100 _scratch_mkfs >> $seq.full 2>&1
101 _scratch_mount "-o usrquota,grpquota"
102 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
103 quotaon -u -g $SCRATCH_MNT 2>/dev/null
104 test_setting
105 umount $SCRATCH_DEV
106
107 status=0
108 exit