Provide conditions to show up problem for dioread on IRIX and Linux
[xfstests-dev.git] / 164
1 #! /bin/sh
2 # FS QA Test No. 164
3 #
4 # To test for short dio reads on IRIX and Linux - pv#962005/962547
5 # http://bugworks.engr.sgi.com/query.cgi/962005
6 #
7 # In particular we are interested in dio_reads for the cases of:
8 # * eof on a hole
9 # * eof on an unwritten extent
10 # * eof on a sector boundary and not on a sector boundary 
11 #
12 #
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
15 #-----------------------------------------------------------------------
16 #
17 # creator
18 owner=tes@puffy.melbourne.sgi.com
19
20 seq=`basename $0`
21 echo "QA output created by $seq"
22
23 here=`pwd`
24 tmp=/tmp/$$
25 status=1        # failure is the default!
26 trap "_cleanup; exit \$status" 0 1 2 3 15
27
28 _cleanup()
29 {
30     cd /
31     rm -f $tmp.*
32 }
33
34 _filter_io()
35 {
36     tee -a $seq.full | sed 's/ops;.*/ops/'
37 }
38
39 #
40 #   1: [128..199]:      212280..212351    0 (212280..212351)    72 10000
41 #  
42 #  
43 _filter_bmap()
44 {
45     tee -a $seq.full |\
46     awk '$3 ~ /hole/ { print $1, $2, $3; next }
47          $7 ~ /10000/ { print $1, $2, "unwritten"; next }
48          {print $1, $2}'
49 }
50
51
52 # get standard environment, filters and checks
53 . ./common.rc
54 . ./common.filter
55
56 # real QA test starts here
57
58 # Modify as appropriate.
59 _supported_fs xfs udf nfs
60 _supported_os IRIX Linux
61
62 testfile=$TEST_DIR/file.$seq
63 rm -f $testfile
64
65 _test_eof_hole()
66 {
67         # on a BB boundary
68         xfs_io -f -c 'pwrite 0 50k' -c 'truncate 100k'\
69                   -c 'pread -b 200k 0 200k' $testfile | _filter_io
70         xfs_io -c 'bmap -vp' $testfile | _filter_bmap  
71         echo ""
72
73         # on an odd byte boundary => 1 short of boundary 
74         boundary_minus1=`expr 100 \* 1024 - 1`
75         echo "boundary_minus1 = $boundary_minus1"
76         xfs_io -f -c 'pwrite 0 50k' -c "truncate $boundary_minus1" \
77                   -c 'pread -b 200k 0 200k' $testfile | _filter_io
78         xfs_io -c 'bmap -vp' $testfile | _filter_bmap  
79         echo ""
80
81         # on an odd byte boundary => 1 over boundary
82         echo "boundary_plus1 = $boundary_plus1"
83         boundary_plus1=`expr 100 \* 1024 + 1`
84         xfs_io -f -c 'pwrite 0 50k' -c "truncate $boundary_plus1" \
85                   -c 'pread -b 200k 0 200k' $testfile | _filter_io
86         xfs_io -c 'bmap -vp' $testfile | _filter_bmap  
87         echo ""
88 }
89
90 _test_eof_unwritten_extent()
91 {
92         # on a BB boundary
93         xfs_io -f -c 'resvsp 0 100k' -c 'pwrite 0 50k' \
94                   -c 'pread -b 200k 0 200k' $testfile | _filter_io
95         xfs_io -c 'bmap -vp' $testfile | _filter_bmap  
96         echo ""
97
98         # on an odd byte boundary => 1 short of boundary 
99         boundary_minus1=`expr 100 \* 1024 - 1`
100         echo "boundary_minus1 = $boundary_minus1"
101         xfs_io -f -c "resvsp 0 $boundary_minus1" -c 'pwrite 0 50k' \
102                   -c 'pread -b 200k 0 200k' $testfile | _filter_io
103         xfs_io -c 'bmap -vp' $testfile | _filter_bmap  
104         echo ""
105
106         # on an odd byte boundary => 1 over boundary
107         boundary_plus1=`expr 100 \* 1024 + 1`
108         echo "boundary_plus1 = $boundary_plus1"
109         xfs_io -f -c "resvsp 0 $boundary_plus1" -c 'pwrite 0 50k' \
110                   -c 'pread -b 200k 0 200k' $testfile | _filter_io
111         xfs_io -c 'bmap -vp' $testfile | _filter_bmap  
112         echo ""
113 }
114
115 _test_eof_hole
116 _test_eof_unwritten_extent
117
118 # success, all done
119 status=0
120 exit