generic/077: fall back to /usr if /lib/modules doesn't exist
[xfstests-dev.git] / tests / xfs / 165
1 #! /bin/bash
2 # FS QA Test No. 165
3 #
4 # Test out prealloc, direct writes and buffered read
5 # Some experimentation when looking at 
6 #   pv#962014 - DMF 3.7 reading incorrect data 
7 # Doesn't actually reproduce the problem but it tried to :-)
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2007 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
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39     cd /
40     rm -f $tmp.*
41 }
42
43 _filter_io()
44 {
45     tee -a $seqres.full | _filter_xfs_io
46 }
47
48 #
49 # <    1: [8..79]:         6552..6623        0 (6552..6623)        72
50 # >    1: [8..79]:         202544..202615    0 (202544..202615)    72
51 #
52 _filter_bmap()
53 {
54     awk '$3 ~ /hole/ { print $1, $2, $3; next }
55          {print $1, $2}' >> $seqres.full
56 }
57
58 # get standard environment, filters and checks
59 . ./common/rc
60 . ./common/filter
61
62 # real QA test starts here
63
64 # Modify as appropriate.
65 _supported_fs xfs
66 _supported_os IRIX Linux
67 _require_test
68
69 # io tests 
70 testfile=$TEST_DIR/file.$seq
71 rm -f $testfile
72 rm -f $seqres.full
73 len=4
74 end=`expr 10 \* $len`
75
76 # Other test...
77 #$XFS_IO_PROG -f -c "resvsp ${off}k ${end}k" $testfile
78
79 # write the initial file
80 $XFS_IO_PROG -f -c "pwrite 0  ${end}k" $testfile | _filter_io
81
82 off=0
83 while [ $off -le $end ]
84 do
85         offset=${off}k
86         length=${len}k
87
88         $XFS_IO_PROG -c "unresvsp $offset $length" -c "bmap -vp" $testfile | _filter_bmap
89
90         let off=$off+$len # skip over 1
91         let off=$off+$len
92 done
93
94 off=0
95 while [ $off -le $end ]
96 do
97         offset=${off}k
98         length=${len}k
99         bufsize=${len}k
100         echo ""
101         echo "*** offset = $offset ***"
102         echo ""
103
104         # prealloc and write
105         $XFS_IO_PROG -d -c "resvsp $offset $length" -c "pwrite -b $bufsize $offset $length" $testfile | _filter_io
106
107         # Other tests...
108         #$XFS_IO_PROG -c "resvsp $offset $length" $testfile
109         #xfs_bmap -v -p $testfile
110         #$XFS_IO_PROG -d -c "pwrite -b $bufsize $offset $length" $testfile
111         #xfs_bmap -v -p $testfile
112
113         $XFS_IO_PROG -r -c "pread -v -b $bufsize $offset $length" $testfile >$tmp.$off &
114
115         # Other tests...
116         #$XFS_IO_PROG -r -c "pread -v -b $bufsize $offset $length" $testfile
117         #sleep 5
118
119         let off=$off+$len # skip over 1
120         let off=$off+$len
121 done
122
123 wait
124 cat $tmp.* | _filter_io
125
126 # success, all done
127 status=0
128 exit