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