506093126709979ba667f49f88fa17eb5533d433
[xfstests-dev.git] / 233
1 #! /bin/bash
2 # FSQA Test No. 233
3 #
4 # Run fsstress with quotas enabled and limits set low and verify accounted
5 # quotas in the end
6 #
7 # Derived from test 231
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #
24 #-----------------------------------------------------------------------
25 #
26 # creator
27 owner=jack@suse.cz
28
29 seq=`basename $0`
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
36
37 # get standard environment, filters and checks
38 . ./common.rc
39 . ./common.filter
40 . ./common.quota
41
42 FSX_FILE_SIZE=64000000
43 FSX_ARGS="-q -l $FSX_FILE_SIZE -o 65536 -S 191110531 -N 100000"
44
45 filter_scratch()
46 {
47         perl -ne "
48 s,$SCRATCH_MNT,[SCR_MNT],;
49 s,$SCRATCH_DEV,[SCR_DEV],;
50         print;"
51 }
52
53 _filter_num()
54 {
55         tee -a $here/$seq.full |\
56         sed -e 's/[0-9][0-9]* inodes/I inodes/g' \
57             -e 's/[0-9][0-9]* paths/P paths/g' \
58             -e 's/seed = [0-9][0-9]*/seed = S/'
59 }
60
61 _fsstress()
62 {
63         echo ""
64         echo "Testing fsstress"
65         echo ""
66
67         out=$SCRATCH_MNT/fsstress.$$
68         count=5000
69         args="-z \
70 -f rmdir=20 -f link=10 -f creat=10 -f mkdir=10 -f unlink=20 -f symlink=10 \
71 -f rename=10 -f fsync=2 -f write=15 -f dwrite=15 \
72 -n $count -d $out -p 7"
73
74         echo "fsstress $args" | tee -a $here/$seq.full | sed -e "s#$out#outdir#"
75         if ! su $qa_user -c "$FSSTRESS_PROG $args" | tee -a $here/$seq.full | _filter_num
76         then
77                 echo "    fsstress $args returned $?"
78                 cat $tmp.out | tee -a $here/$seq.full
79                 status=1
80         fi
81 }
82
83 # real QA test starts here
84 _supported_fs generic
85 _supported_os Linux
86 _require_scratch
87 _require_quota
88 _require_user
89 _need_to_be_root
90
91 umount $SCRATCH_DEV 2>/dev/null
92 _scratch_mkfs >> $seq.full 2>&1
93 _scratch_mount "-o usrquota,grpquota"
94 chmod 777 $SCRATCH_MNT
95 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
96 quotaon -u -g $SCRATCH_MNT 2>/dev/null
97 setquota -u $qa_user 32000 32000 1000 1000 $SCRATCH_MNT 2>/dev/null
98
99 if ! _fsstress; then
100         umount $SCRATCH_DEV 2>/dev/null
101         exit
102 fi
103
104 if ! _check_quota_usage; then
105         umount $SCRATCH_DEV 2>/dev/null
106         status=1
107         exit
108 fi
109
110 umount $SCRATCH_DEV 2>/dev/null
111 status=0
112 exit