xfstests: introduce a common directory
[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 seqres=$RESULT_DIR/$seq
29 seqres=$RESULT_DIR/$seq
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 -N 20000"
44
45 _fsx()
46 {
47         tasks=$1
48         echo "=== FSX Standard Mode, Memory Mapping, $tasks Tasks ==="
49         for (( i = 1; i <= $tasks; i++ )); do
50                 SEED=$RANDOM
51                 echo "ltp/fsx $FSX_ARGS -S $SEED $SCRATCH_MNT/fsx_file$i" >>$seqres.full
52                 su $qa_user -c "ltp/fsx $FSX_ARGS -S $SEED \
53                         $SCRATCH_MNT/fsx_file$i" >$tmp.output$i 2>&1 &
54         done
55
56         for (( i = 1; i <= $tasks; i++ )); do
57                 if ! wait %$i; then
58                         cat $tmp.output$i | tee -a $seqres.full
59                         wait
60                         return 1
61                 fi
62                 $XFS_IO_PROG -F -c 'fsync' $SCRATCH_MNT/fsx_file$i
63                 cat $tmp.output$i | tee -a $seqres.full
64         done
65         return 0
66 }
67
68 # real QA test starts here
69 _supported_fs generic
70 _supported_os Linux
71 _require_scratch
72 _require_quota
73 _require_user
74 _need_to_be_root
75
76 _scratch_mkfs >> $seqres.full 2>&1
77 _scratch_mount "-o usrquota,grpquota"
78 chmod 777 $SCRATCH_MNT
79 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
80 quotaon -u -g $SCRATCH_MNT 2>/dev/null
81
82 if ! _fsx 1; then
83         umount $SCRATCH_DEV 2>/dev/null
84         status=1
85         exit
86 fi
87
88 if ! _check_quota_usage; then
89         umount $SCRATCH_DEV 2>/dev/null
90         status=1
91         exit
92 fi
93
94 if ! _fsx 4; then
95         umount $SCRATCH_DEV 2>/dev/null
96         status=1
97         exit
98 fi
99
100 if ! _check_quota_usage; then
101         umount $SCRATCH_DEV 2>/dev/null
102         status=1
103         exit
104 fi
105
106 #flush cache after write
107 FSX_ARGS="-f $FSX_ARGS"
108 if ! _fsx 1; then
109         umount $SCRATCH_DEV 2>/dev/null
110         status=1
111         exit
112 fi
113
114 if ! _check_quota_usage; then
115         umount $SCRATCH_DEV 2>/dev/null
116         status=1
117         exit
118 fi
119
120 umount $SCRATCH_DEV 2>/dev/null
121 status=0
122 exit