check for mkfs/mount failure
[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     awk '$3 ~ /hole/ { print $1, $2, $3; next }
46          $7 ~ /10000/ { print $1, $2, "unwritten"; next }
47          {print $1, $2}' >> $seq.full
48 }
49
50
51 # get standard environment, filters and checks
52 . ./common.rc
53 . ./common.filter
54
55 # real QA test starts here
56
57 # Modify as appropriate.
58 _supported_fs xfs udf nfs
59 _supported_os IRIX Linux
60
61 testfile=$TEST_DIR/file.$seq
62
63 _test_eof_hole()
64 {
65         # on a BB boundary
66         rm -f $testfile
67         xfs_io -f -d \
68                   -c 'pwrite -b 50k 0 50k' \
69                   -c 'truncate 100k' \
70                   -c 'pread -b 200k 0 200k' \
71                   $testfile | _filter_io
72         xfs_io -c 'bmap -vp' $testfile | _filter_bmap  
73         echo ""
74
75         # on an odd byte boundary => 1 short of boundary 
76         rm -f $testfile
77         boundary_minus1=`expr 100 \* 1024 - 1`
78         echo "boundary_minus1 = $boundary_minus1"
79         xfs_io -f -d \
80                   -c 'pwrite -b 50k 0 50k' \
81                   -c "truncate $boundary_minus1" \
82                   -c 'pread -b 200k 0 200k' \
83                   $testfile | _filter_io
84         xfs_io -c 'bmap -vp' $testfile | _filter_bmap  
85         echo ""
86
87         # on an odd byte boundary => 1 over boundary
88         rm -f $testfile
89         echo "boundary_plus1 = $boundary_plus1"
90         boundary_plus1=`expr 100 \* 1024 + 1`
91         xfs_io -f -d \
92                   -c 'pwrite -b 50k 0 50k' \
93                   -c "truncate $boundary_plus1" \
94                   -c 'pread -b 200k 0 200k' \
95                   $testfile | _filter_io
96         xfs_io -c 'bmap -vp' $testfile | _filter_bmap  
97         echo ""
98 }
99
100 _test_eof_unwritten_extent()
101 {
102         # on a BB boundary
103         rm -f $testfile
104         xfs_io -f -d \
105                   -c 'resvsp 0 100k' \
106                   -c 'truncate 100k' \
107                   -c 'pwrite -b 50k 0 50k' \
108                   -c 'pread -b 200k 0 200k' \
109                   $testfile | _filter_io
110         xfs_io -c 'bmap -vp' $testfile | _filter_bmap  
111         echo ""
112
113         # on an odd byte boundary => 1 short of boundary 
114         rm -f $testfile
115         boundary_minus1=`expr 100 \* 1024 - 1`
116         echo "boundary_minus1 = $boundary_minus1"
117         xfs_io -f -d \
118                   -c "resvsp 0 $boundary_minus1" \
119                   -c "truncate $boundary_minus1" \
120                   -c 'pwrite -b 50k 0 50k' \
121                   -c 'pread -b 200k 0 200k' \
122                 $testfile | _filter_io
123         xfs_io -c 'bmap -vp' $testfile | _filter_bmap  
124         echo ""
125
126         # on an odd byte boundary => 1 over boundary
127         rm -f $testfile
128         boundary_plus1=`expr 100 \* 1024 + 1`
129         echo "boundary_plus1 = $boundary_plus1"
130         xfs_io -f -d \
131                   -c "resvsp 0 $boundary_plus1" \
132                   -c "truncate $boundary_plus1" \
133                   -c 'pwrite -b 50k 0 50k' \
134                   -c 'pread -b 200k 0 200k' \
135                   $testfile | _filter_io
136         xfs_io -c 'bmap -vp' $testfile | _filter_bmap  
137         echo ""
138 }
139
140 _test_eof_hole
141 _test_eof_unwritten_extent
142
143 # success, all done
144 status=0
145 exit