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