xfstests 241: Add missing golden output
[xfstests-dev.git] / 219
1 #! /bin/bash
2 # FS QA Test No. 219
3 #
4 # Simple quota accounting test for direct/buffered/mmap IO.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2009 Eric Sandeen.  All Rights Reserved.
8 #
9 # Based on test 108,
10 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #
25 #-----------------------------------------------------------------------
26 #
27 # creator
28 owner=sandeen@sandeen.net
29
30 seq=`basename $0`
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
37
38 # get standard environment, filters and checks
39 . ./common.rc
40 . ./common.filter
41 . ./common.quota
42
43 filter_scratch()
44 {
45         perl -ne "
46 s,$SCRATCH_MNT,[SCR_MNT],;
47 s,$SCRATCH_DEV,[SCR_DEV],;
48         print;"
49 }
50
51 # real QA test starts here
52 _supported_fs generic
53 _supported_os Linux #IRIX
54 _require_scratch
55 _require_quota
56
57 test_files()
58 {
59         echo; echo "### create files, setting up ownership (type=$type)"
60         rm -f $SCRATCH_MNT/{buffer,direct,mmap}
61         touch $SCRATCH_MNT/{buffer,direct,mmap}
62         chown $uid $SCRATCH_MNT/{buffer,direct,mmap}
63         chgrp $gid $SCRATCH_MNT/{buffer,direct,mmap}
64         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
65                 $here/src/lstat64 $file | head -3 | filter_scratch
66         done
67 }
68
69 test_accounting()
70 {
71         echo "### some controlled buffered, direct and mmapd IO (type=$type)"
72         echo "--- initiating parallel IO..." >>$seq.full
73         # Small ios here because ext3 will account for indirect blocks too ...
74         # 48k will fit w/o indirect for 4k blocks (default blocksize)
75         $XFS_IO_PROG -F -c 'pwrite 0 48k' -c 'fsync' \
76                                         $SCRATCH_MNT/buffer >>$seq.full 2>&1 &
77         $XFS_IO_PROG -F -c 'pwrite 0 48k' -d \
78                                         $SCRATCH_MNT/direct >>$seq.full 2>&1 &
79         $XFS_IO_PROG -F -c 't 48k' -c 'mm -rw 0 48k' -c 'mw 0 48k' -c 'ms -s' \
80                                         $SCRATCH_MNT/mmap   >>$seq.full 2>&1 &
81         wait
82         echo "--- completed parallel IO ($type)" >>$seq.full
83
84         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
85                 $here/src/lstat64 $file | head -3 | filter_scratch
86         done
87
88         repquota -$type -n $SCRATCH_MNT  | grep -v "^#0" | filter_scratch |
89         awk '/^#/ { if (seen[$1]) next; seen[$1]++; } { print; }'
90 }
91
92 # real QA test starts here
93 rm -f $seq.full
94
95 uid=1
96 gid=2
97
98 umount $SCRATCH_DEV 2>/dev/null
99 _scratch_mkfs >> $seq.full 2>&1
100 _scratch_mount "-o usrquota,grpquota"
101 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
102 quotaon $SCRATCH_MNT 2>/dev/null
103 umount $SCRATCH_DEV
104
105 echo; echo "### test user accounting"
106 export MOUNT_OPTIONS="-o usrquota"
107 _qmount
108 quotaon $SCRATCH_MNT 2>/dev/null
109 type=u
110 test_files
111 test_accounting
112 umount $SCRATCH_DEV 2>/dev/null
113
114 echo; echo "### test group accounting"
115 export MOUNT_OPTIONS="-o grpquota"
116 _qmount
117 quotaon $SCRATCH_MNT 2>/dev/null
118 type=g
119 test_files
120 test_accounting
121 umount $SCRATCH_DEV 2>/dev/null
122
123 status=0
124 exit