common: use mount/umount helpers everywhere
[xfstests-dev.git] / tests / generic / 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
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
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 FSX_FILE_SIZE=64000000
42 FSX_ARGS="-q -l $FSX_FILE_SIZE -o 65536 -S 191110531 -N 100000"
43
44 _filter_num()
45 {
46         tee -a $seqres.full |\
47         sed -e 's/[0-9][0-9]* inodes/I inodes/g' \
48             -e 's/[0-9][0-9]* paths/P paths/g' \
49             -e 's/seed = [0-9][0-9]*/seed = S/'
50 }
51
52 _fsstress()
53 {
54         echo ""
55         echo "Testing fsstress"
56         echo ""
57
58         out=$SCRATCH_MNT/fsstress.$$
59         count=5000
60         args=`_scale_fsstress_args -z \
61 -f rmdir=20 -f link=10 -f creat=10 -f mkdir=10 -f unlink=20 -f symlink=10 \
62 -f rename=10 -f fsync=2 -f write=15 -f dwrite=15 \
63 -n $count -d $out -p 7`
64
65         echo "fsstress $args" >> $seqres.full
66         if ! su $qa_user -c "$FSSTRESS_PROG $args" | tee -a $seqres.full | _filter_num
67         then
68                 echo "    fsstress $args returned $?"
69                 cat $tmp.out | tee -a $seqres.full
70                 status=1
71         fi
72 }
73
74 # real QA test starts here
75 _supported_fs generic
76 _supported_os Linux
77 _require_scratch
78 _require_quota
79 _require_user
80 _need_to_be_root
81
82 _scratch_mkfs >> $seqres.full 2>&1
83 _scratch_mount "-o usrquota,grpquota"
84 chmod 777 $SCRATCH_MNT
85 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
86 quotaon -u -g $SCRATCH_MNT 2>/dev/null
87 setquota -u $qa_user 32000 32000 1000 1000 $SCRATCH_MNT 2>/dev/null
88
89 if ! _fsstress; then
90         _scratch_unmount 2>/dev/null
91         exit
92 fi
93
94 if ! _check_quota_usage; then
95         _scratch_unmount 2>/dev/null
96         status=1
97         exit
98 fi
99
100 _scratch_unmount 2>/dev/null
101 status=0
102 exit