xfstests: randholes: clean up readblks()
[xfstests-dev.git] / 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 # creator
26 owner=jack@suse.cz
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
35
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
39 . ./common.quota
40
41 filter_scratch()
42 {
43         perl -ne "
44 s,$SCRATCH_MNT,[SCR_MNT],;
45 s,$SCRATCH_DEV,[SCR_DEV],;
46         print;"
47 }
48
49 _filter_num()
50 {
51         tee -a $here/$seq.full |\
52         sed -e 's/[0-9][0-9]* inodes/I inodes/g' \
53             -e 's/[0-9][0-9]* paths/P paths/g' \
54             -e 's/seed = [0-9][0-9]*/seed = S/'
55 }
56
57 _fsstress()
58 {
59         echo ""
60         echo "Testing fsstress"
61         echo ""
62
63         out=$SCRATCH_MNT/fsstress.$$
64         count=2000
65         args="-n $count -d $out -p 7"
66
67         echo "fsstress $args" | tee -a $here/$seq.full | sed -e "s#$out#outdir#"
68         if ! $FSSTRESS_PROG $args | tee -a $here/$seq.full | _filter_num
69         then
70                 echo "    fsstress $args returned $?"
71                 cat $tmp.out | tee -a $here/$seq.full
72                 status=1
73         fi
74 }
75
76 # real QA test starts here
77 _supported_fs generic
78 _supported_os Linux
79 _require_scratch
80 _require_quota
81 _need_to_be_root
82
83 umount $SCRATCH_DEV 2>/dev/null
84 _scratch_mkfs >> $seq.full 2>&1
85 _scratch_mount "-o usrquota,grpquota"
86 chmod 777 $SCRATCH_MNT
87 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
88 quotaon -u -g $SCRATCH_MNT 2>/dev/null
89
90 if ! _fsstress; then
91         umount $SCRATCH_DEV 2>/dev/null
92         exit
93 fi
94
95 if ! _check_quota_usage; then
96         umount $SCRATCH_DEV 2>/dev/null
97         status=1
98         exit
99 fi
100
101 umount $SCRATCH_DEV 2>/dev/null
102 status=0
103 exit