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