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
42 _require_seek_data_hole
44 src=$TEST_DIR/seek_copy_testfile
45 dest=$TEST_DIR/seek_copy_testfile.dest
47 _require_test_program "seek_copy_test"
54 # seek_copy_test_01: tests file with holes and written data extents.
56 # 1. file size is identical.
57 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
62 write_cmd="-c \"truncate 100m\""
63 for i in $(seq 0 5 100); do
64 offset=$(($i * $((1 << 20))))
65 write_cmd="$write_cmd -c \"pwrite $offset 1m\""
68 echo "*** test01() create sparse file ***" >>$seqres.full
69 eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
70 _fail "create sparse file failed!"
71 echo "*** test01() create sparse file done ***" >>$seqres.full
74 $here/src/seek_copy_test $src $dest
76 test $(stat -c "%s" $src) = $(stat -c "%s" $dest) ||
77 _fail "TEST01: file size check failed"
79 cmp $src $dest || _fail "TEST01: file bytes check failed"
82 # seek_copy_test_02 - tests file with holes, written and unwritten extents.
84 # 1. file size is identical.
85 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
90 write_cmd="-c \"truncate 200m\""
91 for i in $(seq 0 10 100); do
92 offset=$(($((6 << 20)) + $i * $((1 << 20))))
93 write_cmd="$write_cmd -c \"falloc $offset 3m\" -c \"pwrite $offset 1m\""
96 echo "*** test02() create sparse file ***" >>$seqres.full
97 eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
98 _fail "create sparse file failed!"
99 echo "*** test02() create sparse file done ***" >>$seqres.full
102 $here/src/seek_copy_test $src $dest
104 test $(stat -c "%s" $src) = $(stat -c "%s" $dest) ||
105 _fail "TEST02: file size check failed"
107 cmp $src $dest || _fail "TEST02: file bytes check failed"
110 # seek_copy_test_03 - tests file with unwritten with data, repeated unwritten
111 # without data, as well as data extents mapping.
113 # 1. file size is identical.
114 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
119 write_cmd="-c \"truncate 200m\""
122 # Firstly, make the file with allocated && reserved extents
123 # mapping without real data wrote.
125 for i in $(seq 0 10 180); do
126 offset=$(($((10 << 20)) + $i * $((1 << 20))))
127 write_cmd="$write_cmd -c \"falloc $offset 10m\""
131 # Secondly, write data to some unwritten extents, hence we
132 # have a test file will extents mapping as:
133 # |data|multiple unwritten_without_data|data| repeat...
134 for i in $(seq 0 60 180); do
135 offset=$(($((20 << 20)) + $i * $((1 << 20))))
136 write_cmd="$write_cmd -c \"pwrite $offset 10m\""
139 echo "*** test03() create sparse file ***" >>$seqres.full
140 eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
141 _fail "create sparse file failed!"
142 echo "*** test03() create sparse file done ***" >>$seqres.full
144 $here/src/seek_copy_test $src $dest
146 test $(stat -c "%s" $src) = $(stat -c "%s" $dest) ||
147 _fail "TEST03: file size check failed"
149 cmp $src $dest || _fail "TEST03: file bytes check failed"
152 # seek_copy_test_04 - tests file with hole, repeated unwritten
153 # without data, as well as data extents mapping.
155 # 1. file size is identical.
156 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
161 write_cmd="-c \"truncate 200m\""
164 # Firstly, make the file with allocated && reserved extents
165 # mapping without real data wrote.
167 for i in $(seq 30 30 180); do
168 offset=$(($((30 << 20)) + $i * $((1 << 20))))
169 write_cmd="$write_cmd -c \"falloc $offset 5m\""
173 # Secondly, write data to some unwritten extents, hence we
174 # have a test file will extents mapping as:
175 # |hole|multiple unwritten_without_data|hole|data| repeat...
176 for i in $(seq 30 90 180); do
177 offset=$(($((30 << 20)) + $i * $((1 << 20))))
178 write_cmd="$write_cmd -c \"pwrite $offset 2m\""
181 echo "*** test04() create sparse file ***" >>$seqres.full
182 eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
183 _fail "create sparse file failed!"
184 echo "*** test04() create sparse file done ***" >>$seqres.full
186 $here/src/seek_copy_test $src $dest
188 test $(stat -c "%s" $src) = $(stat -c "%s" $dest) ||
189 _fail "TEST04: file size check failed"
191 cmp $src $dest || _fail "TEST04: file bytes check failed"