xfstests: introduce a common directory
[xfstests-dev.git] / tests / xfs / 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 seqres=$RESULT_DIR/$seq
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
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 # real QA test starts here
42 _supported_fs xfs
43 _supported_os Linux #IRIX
44 _require_scratch
45 _require_xfs_quota
46
47 test_files()
48 {
49         echo; echo "### create files, setting up ownership (type=$type)"
50         rm -f $SCRATCH_MNT/{buffer,direct,mmap}
51         $XFS_IO_PROG -fc "chproj $prid" $SCRATCH_MNT/{buffer,direct,mmap}
52         chown $uid $SCRATCH_MNT/{buffer,direct,mmap}
53         chgrp $gid $SCRATCH_MNT/{buffer,direct,mmap}
54         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
55                 $here/src/lstat64 $file | head -3 | _filter_scratch
56                 $XFS_IO_PROG -c lsproj $file
57         done
58 }
59
60 test_accounting()
61 {
62         echo "### some controlled buffered, direct and mmapd IO (type=$type)"
63         echo "--- initiating parallel IO..." >>$seqres.full
64         $XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -c 'fsync' \
65                                         $SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
66         $XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -d \
67                                         $SCRATCH_MNT/direct >>$seqres.full 2>&1 &
68         $XFS_IO_PROG -c 't 16m' -c 'mm -rw 0 16m' -c 'mw 0 16m' -c 'ms -s' \
69                                         $SCRATCH_MNT/mmap   >>$seqres.full 2>&1 &
70         wait
71         echo "--- completed parallel IO ($type)" >>$seqres.full
72
73         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
74                 $here/src/lstat64 $file | head -3 | _filter_scratch
75         done
76         xfs_quota -c "quota -hnb -$type $id" $QARGS | _filter_scratch | _filter_spaces
77         xfs_quota -c "quota -hni -$type $id" $QARGS | _filter_scratch | _filter_spaces
78         xfs_quota -c "quota -hnr -$type $id" $QARGS | _filter_scratch | _filter_spaces
79 }
80
81 export MOUNT_OPTIONS="-opquota"
82 _qmount
83 _require_prjquota $SCRATCH_DEV
84
85 # real QA test starts here
86 rm -f $tmp.projects $seqres.full
87 umount $SCRATCH_DEV 2>/dev/null
88 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
89 cat $tmp.mkfs >>$seqres.full
90 _scratch_mount
91
92 uid=1
93 gid=2
94 prid=3
95 export QARGS="-x -D /dev/null -P /dev/null $SCRATCH_MNT"
96 umount $SCRATCH_DEV
97
98 echo; echo "### test user accounting"
99 export MOUNT_OPTIONS="-ouquota"
100 _qmount
101 type=u
102 id=$uid
103 test_files
104 test_accounting
105 umount $SCRATCH_DEV 2>/dev/null
106
107 echo; echo "### test group accounting"
108 export MOUNT_OPTIONS="-ogquota"
109 _qmount
110 type=g
111 id=$gid
112 test_files
113 test_accounting
114 umount $SCRATCH_DEV 2>/dev/null
115
116 #echo; echo "### test project accounting"
117 export MOUNT_OPTIONS="-opquota"
118 _qmount
119 type=p
120 id=$prid
121 test_files
122 test_accounting
123 umount $SCRATCH_DEV 2>/dev/null
124
125 status=0
126 exit