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 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
30 status=1 # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
33 # get standard environment, filters and checks
37 # real QA test starts here
41 src=$TEST_DIR/seek_copy_testfile
42 dest=$TEST_DIR/seek_copy_testfile.dest
44 [ -x $here/src/seek_copy_test ] || _notrun "seek_copy_test not built"
51 # seek_copy_test_01: tests file with holes and written data extents.
53 # 1. file size is identical.
54 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
59 write_cmd="-c \"truncate 100m\""
60 for i in $(seq 0 5 100); do
61 offset=$(($i * $((1 << 20))))
62 write_cmd="$write_cmd -c \"pwrite $offset 1m\""
65 echo "*** test01() create sparse file ***" >>$seqres.full
66 eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
67 _fail "create sparse file failed!"
68 echo "*** test01() create sparse file done ***" >>$seqres.full
71 $here/src/seek_copy_test $src $dest
73 test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
74 _fail "TEST01: file size check failed"
76 cmp $src $dest || _fail "TEST01: file bytes check failed"
79 # seek_copy_test_02 - tests file with holes, written and unwritten extents.
81 # 1. file size is identical.
82 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
87 write_cmd="-c \"truncate 200m\""
88 for i in $(seq 0 10 100); do
89 offset=$(($((6 << 20)) + $i * $((1 << 20))))
90 write_cmd="$write_cmd -c \"falloc $offset 3m\" -c \"pwrite $offset 1m\""
93 echo "*** test02() create sparse file ***" >>$seqres.full
94 eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
95 _fail "create sparse file failed!"
96 echo "*** test02() create sparse file done ***" >>$seqres.full
99 $here/src/seek_copy_test $src $dest
101 test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
102 _fail "TEST02: file size check failed"
104 cmp $src $dest || _fail "TEST02: file bytes check failed"
107 # seek_copy_test_03 - tests file with unwritten with data, repeated unwritten
108 # without data, as well as data extents mapping.
110 # 1. file size is identical.
111 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
116 write_cmd="-c \"truncate 200m\""
119 # Firstly, make the file with allocated && reserved extents
120 # mapping without real data wrote.
122 for i in $(seq 0 10 180); do
123 offset=$(($((10 << 20)) + $i * $((1 << 20))))
124 write_cmd="$write_cmd -c \"falloc $offset 10m\""
128 # Secondly, write data to some unwritten extents, hence we
129 # have a test file will extents mapping as:
130 # |data|multiple unwritten_without_data|data| repeat...
131 for i in $(seq 0 60 180); do
132 offset=$(($((20 << 20)) + $i * $((1 << 20))))
133 write_cmd="$write_cmd -c \"pwrite $offset 10m\""
136 echo "*** test03() create sparse file ***" >>$seqres.full
137 eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
138 _fail "create sparse file failed!"
139 echo "*** test03() create sparse file done ***" >>$seqres.full
141 $here/src/seek_copy_test $src $dest
143 test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
144 _fail "TEST03: file size check failed"
146 cmp $src $dest || _fail "TEST03: file bytes check failed"
149 # seek_copy_test_04 - tests file with hole, repeated unwritten
150 # without data, as well as data extents mapping.
152 # 1. file size is identical.
153 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
158 write_cmd="-c \"truncate 200m\""
161 # Firstly, make the file with allocated && reserved extents
162 # mapping without real data wrote.
164 for i in $(seq 30 30 180); do
165 offset=$(($((30 << 20)) + $i * $((1 << 20))))
166 write_cmd="$write_cmd -c \"falloc $offset 5m\""
170 # Secondly, write data to some unwritten extents, hence we
171 # have a test file will extents mapping as:
172 # |hole|multiple unwritten_without_data|hole|data| repeat...
173 for i in $(seq 30 90 180); do
174 offset=$(($((30 << 20)) + $i * $((1 << 20))))
175 write_cmd="$write_cmd -c \"pwrite $offset 2m\""
178 echo "*** test04() create sparse file ***" >>$seqres.full
179 eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
180 _fail "create sparse file failed!"
181 echo "*** test04() create sparse file done ***" >>$seqres.full
183 $here/src/seek_copy_test $src $dest
185 test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
186 _fail "TEST04: file size check failed"
188 cmp $src $dest || _fail "TEST04: file bytes check failed"