xfstests: include test subdirectory support
[xfstests-dev.git] / 108
1 #! /bin/bash
2 # FS QA Test No. 108
3 #
4 # Simple quota accounting test for direct/buffered/mmap IO.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1        # failure is the default!
31 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
32
33 # get standard environment, filters and checks
34 . ./common.rc
35 . ./common.filter
36 . ./common.quota
37
38 # real QA test starts here
39 _supported_fs xfs
40 _supported_os Linux #IRIX
41 _require_scratch
42 _require_xfs_quota
43
44 test_files()
45 {
46         echo; echo "### create files, setting up ownership (type=$type)"
47         rm -f $SCRATCH_MNT/{buffer,direct,mmap}
48         $XFS_IO_PROG -fc "chproj $prid" $SCRATCH_MNT/{buffer,direct,mmap}
49         chown $uid $SCRATCH_MNT/{buffer,direct,mmap}
50         chgrp $gid $SCRATCH_MNT/{buffer,direct,mmap}
51         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
52                 $here/src/lstat64 $file | head -3 | _filter_scratch
53                 $XFS_IO_PROG -c lsproj $file
54         done
55 }
56
57 test_accounting()
58 {
59         echo "### some controlled buffered, direct and mmapd IO (type=$type)"
60         echo "--- initiating parallel IO..." >>$seq.full
61         $XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -c 'fsync' \
62                                         $SCRATCH_MNT/buffer >>$seq.full 2>&1 &
63         $XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -d \
64                                         $SCRATCH_MNT/direct >>$seq.full 2>&1 &
65         $XFS_IO_PROG -c 't 16m' -c 'mm -rw 0 16m' -c 'mw 0 16m' -c 'ms -s' \
66                                         $SCRATCH_MNT/mmap   >>$seq.full 2>&1 &
67         wait
68         echo "--- completed parallel IO ($type)" >>$seq.full
69
70         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
71                 $here/src/lstat64 $file | head -3 | _filter_scratch
72         done
73         xfs_quota -c "quota -hnb -$type $id" $QARGS | _filter_scratch | _filter_spaces
74         xfs_quota -c "quota -hni -$type $id" $QARGS | _filter_scratch | _filter_spaces
75         xfs_quota -c "quota -hnr -$type $id" $QARGS | _filter_scratch | _filter_spaces
76 }
77
78 export MOUNT_OPTIONS="-opquota"
79 _qmount
80 _require_prjquota $SCRATCH_DEV
81
82 # real QA test starts here
83 rm -f $tmp.projects $seq.full
84 umount $SCRATCH_DEV 2>/dev/null
85 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
86 cat $tmp.mkfs >>$seq.full
87 _scratch_mount
88
89 uid=1
90 gid=2
91 prid=3
92 export QARGS="-x -D /dev/null -P /dev/null $SCRATCH_MNT"
93 umount $SCRATCH_DEV
94
95 echo; echo "### test user accounting"
96 export MOUNT_OPTIONS="-ouquota"
97 _qmount
98 type=u
99 id=$uid
100 test_files
101 test_accounting
102 umount $SCRATCH_DEV 2>/dev/null
103
104 echo; echo "### test group accounting"
105 export MOUNT_OPTIONS="-ogquota"
106 _qmount
107 type=g
108 id=$gid
109 test_files
110 test_accounting
111 umount $SCRATCH_DEV 2>/dev/null
112
113 #echo; echo "### test project accounting"
114 export MOUNT_OPTIONS="-opquota"
115 _qmount
116 type=p
117 id=$prid
118 test_files
119 test_accounting
120 umount $SCRATCH_DEV 2>/dev/null
121
122 status=0
123 exit