xfstests: convert tests to use new results directory
[xfstests-dev.git] / tests / generic / 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
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 seqres=$RESULT_DIR/$seq
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
33
34 here=`pwd`
35 tmp=/tmp/$$
36 status=1        # failure is the default!
37 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
38
39 # get standard environment, filters and checks
40 . ./common.rc
41 . ./common.filter
42 . ./common.quota
43
44 test_setting()
45 {
46         echo; echo "### test limits and info setting"
47         count=2000
48         procs=5
49         idmod=200000
50         seed=$RANDOM
51         RANDOM=$seed
52         echo "Starting test with procs=$procs, idmod=$idmod, and seed=$seed" >>$seqres.full
53
54         for (( i = 0; i < $procs; i++ )); do
55                 ( SETUCOUNT=1; SETGCOUNT=1; SETUIDS[0]=0; SETGIDS[0]=0
56                 for (( j = 0; j < $count; j++ )); do
57                         OP=$(($RANDOM%22))
58                         UG=$(($OP%2))
59                         OP=$(($OP/2))
60                         if [ $UG -eq 1 ]; then
61                                 type='u'
62                         else
63                                 type='g'
64                         fi
65                         if [ $OP -eq 10 ]; then
66                                 setquota -t -$type $j $j $SCRATCH_MNT
67                         elif [ $OP -lt 5 ]; then
68                                 ID=$((($RANDOM*32768+$RANDOM)%$idmod))
69                                 if [ $UG -eq 1 ]; then
70                                         SETUIDS[$SETUCOUNT]=$ID
71                                         SETUCOUNT=$(($SETUCOUNT+1))
72                                 else
73                                         SETGIDS[$SETGCOUNT]=$ID
74                                         SETGCOUNT=$(($SETGCOUNT+1))
75                                 fi
76                                 setquota -$type $ID $j $j $j $j $SCRATCH_MNT
77                         else
78                                 if [ $UG -eq 1 ]; then
79                                         ID=${SETUIDS[$(($RANDOM%$SETUCOUNT))]}
80                                 else
81                                         ID=${SETGIDS[$(($RANDOM%$SETGCOUNT))]}
82                                 fi
83                                 setquota -$type $ID 0 0 0 0 $SCRATCH_MNT
84                         fi
85                 done )&
86         done
87         wait
88         echo "### done with testing"
89 }
90
91 # real QA test starts here
92 _supported_fs generic
93 _supported_os Linux #IRIX
94 _require_scratch
95 _require_quota
96 _need_to_be_root
97
98 # real QA test starts here
99 rm -f $seqres.full
100
101 _scratch_mkfs >> $seqres.full 2>&1
102 _scratch_mount "-o usrquota,grpquota"
103 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
104 quotaon -u -g $SCRATCH_MNT 2>/dev/null
105 test_setting
106 umount $SCRATCH_DEV
107
108 status=0
109 exit