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