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