Merge relevant CXFSQA tests into XFSQA
[xfstests-dev.git] / 108
1 #! /bin/sh
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 #
10 # creator
11 owner=nathans@sgi.com
12
13 seq=`basename $0`
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20
21 # get standard environment, filters and checks
22 . ./common.rc
23 . ./common.filter
24 . ./common.quota
25
26 filter_scratch()
27 {
28         perl -ne "
29 s,$SCRATCH_MNT,[SCR_MNT],;
30 s,$SCRATCH_DEV,[SCR_DEV],;
31         print;"
32 }
33
34 # real QA test starts here
35 _supported_fs xfs
36 _supported_os Linux #IRIX
37 _require_scratch
38 _require_quota
39 _require_prjquota
40
41 test_files()
42 {
43         echo; echo "### create files, setting up ownership (type=$type)"
44         rm -f $SCRATCH_MNT/{buffer,direct,mmap}
45         $XFS_IO_PROG -fc "chproj $prid" $SCRATCH_MNT/{buffer,direct,mmap}
46         chown $uid $SCRATCH_MNT/{buffer,direct,mmap}
47         chgrp $gid $SCRATCH_MNT/{buffer,direct,mmap}
48         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
49                 $here/src/lstat64 $file | head -3 | filter_scratch
50                 $XFS_IO_PROG -c lsproj $file
51         done
52 }
53
54 test_accounting()
55 {
56         echo "### some controlled buffered, direct and mmapd IO (type=$type)"
57         echo "--- initiating parallel IO..." >>$seq.full
58         $XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -c 'fsync' \
59                                         $SCRATCH_MNT/buffer >>$seq.full 2>&1 &
60         $XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -d \
61                                         $SCRATCH_MNT/direct >>$seq.full 2>&1 &
62         $XFS_IO_PROG -c 't 16m' -c 'mm -rw 0 16m' -c 'mw 0 16m' -c 'ms -s' \
63                                         $SCRATCH_MNT/mmap   >>$seq.full 2>&1 &
64         wait
65         echo "--- completed parallel IO ($type)" >>$seq.full
66
67         for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
68                 $here/src/lstat64 $file | head -3 | filter_scratch
69         done
70         xfs_quota -c "quota -hnb -$type $id" $QARGS | filter_scratch
71         xfs_quota -c "quota -hni -$type $id" $QARGS | filter_scratch
72         xfs_quota -c "quota -hnr -$type $id" $QARGS | filter_scratch
73 }
74
75 # real QA test starts here
76 rm -f $tmp.projects $seq.full
77 umount $SCRATCH_DEV 2>/dev/null
78 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
79 cat $tmp.mkfs >>$seq.full
80 _scratch_mount
81
82 uid=1
83 gid=2
84 prid=3
85 export QARGS="-x -D /dev/null -P /dev/null $SCRATCH_MNT"
86 umount $SCRATCH_DEV
87
88 echo; echo "### test user accounting"
89 export MOUNT_OPTIONS="-ouquota"
90 _qmount
91 type=u
92 id=$uid
93 test_files
94 test_accounting
95 umount $SCRATCH_DEV 2>/dev/null
96
97 echo; echo "### test group accounting"
98 export MOUNT_OPTIONS="-ogquota"
99 _qmount
100 type=g
101 id=$gid
102 test_files
103 test_accounting
104 umount $SCRATCH_DEV 2>/dev/null
105
106 #echo; echo "### test project accounting"
107 export MOUNT_OPTIONS="-opquota"
108 _qmount
109 type=p
110 id=$prid
111 test_files
112 test_accounting
113 umount $SCRATCH_DEV 2>/dev/null
114
115 status=0
116 exit