common: use mount/umount helpers everywhere
[xfstests-dev.git] / tests / generic / 231
1 #! /bin/bash
2 # FSQA Test No. 231
3 #
4 # Run fsx with quotas enabled and verify accounted quotas in the end
5 #
6 # Derived from test 127
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 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common/rc
37 . ./common/filter
38 . ./common/quota
39
40 FSX_FILE_SIZE=64000000
41 FSX_ARGS="-q -l $FSX_FILE_SIZE -o 65536 -N 20000"
42
43 _fsx()
44 {
45         tasks=$1
46         echo "=== FSX Standard Mode, Memory Mapping, $tasks Tasks ==="
47         for (( i = 1; i <= $tasks; i++ )); do
48                 SEED=$RANDOM
49                 echo "ltp/fsx $FSX_ARGS -S $SEED $SCRATCH_MNT/fsx_file$i" >>$seqres.full
50                 su $qa_user -c "ltp/fsx $FSX_ARGS -S $SEED \
51                         $FSX_AVOID $SCRATCH_MNT/fsx_file$i" >$tmp.output$i 2>&1 &
52         done
53
54         for (( i = 1; i <= $tasks; i++ )); do
55                 if ! wait %$i; then
56                         cat $tmp.output$i | tee -a $seqres.full
57                         wait
58                         return 1
59                 fi
60                 $XFS_IO_PROG -c 'fsync' $SCRATCH_MNT/fsx_file$i
61                 cat $tmp.output$i | tee -a $seqres.full
62         done
63         return 0
64 }
65
66 # real QA test starts here
67 _supported_fs generic
68 _supported_os Linux
69 _require_scratch
70 _require_quota
71 _require_user
72 _need_to_be_root
73
74 _scratch_mkfs >> $seqres.full 2>&1
75 _scratch_mount "-o usrquota,grpquota"
76 chmod 777 $SCRATCH_MNT
77 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
78 quotaon -u -g $SCRATCH_MNT 2>/dev/null
79
80 if ! _fsx 1; then
81         _scratch_unmount 2>/dev/null
82         status=1
83         exit
84 fi
85
86 if ! _check_quota_usage; then
87         _scratch_unmount 2>/dev/null
88         status=1
89         exit
90 fi
91
92 if ! _fsx 4; then
93         _scratch_unmount 2>/dev/null
94         status=1
95         exit
96 fi
97
98 if ! _check_quota_usage; then
99         _scratch_unmount 2>/dev/null
100         status=1
101         exit
102 fi
103
104 #flush cache after write
105 FSX_ARGS="-f $FSX_ARGS"
106 if ! _fsx 1; then
107         _scratch_unmount 2>/dev/null
108         status=1
109         exit
110 fi
111
112 if ! _check_quota_usage; then
113         _scratch_unmount 2>/dev/null
114         status=1
115         exit
116 fi
117
118 _scratch_unmount 2>/dev/null
119 status=0
120 exit