4 # SEEK_DATA/SEEK_HOLE copy tests.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2011 Oracle Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 echo "QA output created by $seq"
29 status=1 # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
32 # get standard environment, filters and checks
36 # real QA test starts here
40 src=$TEST_DIR/seek_copy_testfile
41 dest=$TEST_DIR/seek_copy_testfile.dest
43 [ -x $here/src/seek_copy_test ] || _notrun "seek_copy_test not built"
50 # seek_copy_test_01: tests file with holes and written data extents.
52 # 1. file size is identical.
53 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
58 write_cmd="-c \"truncate 100m\""
59 for i in $(seq 0 5 100); do
60 offset=$(($i * $((1 << 20))))
61 write_cmd="$write_cmd -c \"pwrite $offset 1m\""
64 echo "*** test01() create sparse file ***" >>$seq.full
65 eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seq.full 2>&1 ||
66 _fail "create sparse file failed!"
67 echo "*** test01() create sparse file done ***" >>$seq.full
70 $here/src/seek_copy_test $src $dest
72 test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
73 _fail "TEST01: file size check failed"
75 cmp $src $dest || _fail "TEST01: file bytes check failed"
78 # seek_copy_test_02 - tests file with holes, written and unwritten extents.
80 # 1. file size is identical.
81 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
86 write_cmd="-c \"truncate 200m\""
87 for i in $(seq 0 10 100); do
88 offset=$(($((6 << 20)) + $i * $((1 << 20))))
89 write_cmd="$write_cmd -c \"falloc $offset 3m\" -c \"pwrite $offset 1m\""
92 echo "*** test02() create sparse file ***" >>$seq.full
93 eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seq.full 2>&1 ||
94 _fail "create sparse file failed!"
95 echo "*** test02() create sparse file done ***" >>$seq.full
98 $here/src/seek_copy_test $src $dest
100 test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
101 _fail "TEST02: file size check failed"
103 cmp $src $dest || _fail "TEST02: file bytes check failed"
106 # seek_copy_test_03 - tests file with unwritten with data, repeated unwritten
107 # without data, as well as data extents mapping.
109 # 1. file size is identical.
110 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
115 write_cmd="-c \"truncate 200m\""
118 # Firstly, make the file with allocated && reserved extents
119 # mapping without real data wrote.
121 for i in $(seq 0 10 180); do
122 offset=$(($((10 << 20)) + $i * $((1 << 20))))
123 write_cmd="$write_cmd -c \"falloc $offset 10m\""
127 # Secondly, write data to some unwritten extents, hence we
128 # have a test file will extents mapping as:
129 # |data|multiple unwritten_without_data|data| repeat...
130 for i in $(seq 0 60 180); do
131 offset=$(($((20 << 20)) + $i * $((1 << 20))))
132 write_cmd="$write_cmd -c \"pwrite $offset 10m\""
135 echo "*** test03() create sparse file ***" >>$seq.full
136 eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seq.full 2>&1 ||
137 _fail "create sparse file failed!"
138 echo "*** test03() create sparse file done ***" >>$seq.full
140 $here/src/seek_copy_test $src $dest
142 test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
143 _fail "TEST03: file size check failed"
145 cmp $src $dest || _fail "TEST03: file bytes check failed"
148 # seek_copy_test_04 - tests file with hole, repeated unwritten
149 # without data, as well as data extents mapping.
151 # 1. file size is identical.
152 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
157 write_cmd="-c \"truncate 200m\""
160 # Firstly, make the file with allocated && reserved extents
161 # mapping without real data wrote.
163 for i in $(seq 30 30 180); do
164 offset=$(($((30 << 20)) + $i * $((1 << 20))))
165 write_cmd="$write_cmd -c \"falloc $offset 5m\""
169 # Secondly, write data to some unwritten extents, hence we
170 # have a test file will extents mapping as:
171 # |hole|multiple unwritten_without_data|hole|data| repeat...
172 for i in $(seq 30 90 180); do
173 offset=$(($((30 << 20)) + $i * $((1 << 20))))
174 write_cmd="$write_cmd -c \"pwrite $offset 2m\""
177 echo "*** test04() create sparse file ***" >>$seq.full
178 eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seq.full 2>&1 ||
179 _fail "create sparse file failed!"
180 echo "*** test04() create sparse file done ***" >>$seq.full
182 $here/src/seek_copy_test $src $dest
184 test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
185 _fail "TEST04: file size check failed"
187 cmp $src $dest || _fail "TEST04: file bytes check failed"