2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2011 Oracle Inc. All Rights Reserved.
7 # SEEK_DATA/SEEK_HOLE copy tests.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
14 status=1 # failure is the default!
15 trap "_cleanup; exit \$status" 0 1 2 3 15
17 # get standard environment, filters and checks
21 # real QA test starts here
26 _require_xfs_io_command "falloc"
27 _require_seek_data_hole
29 src=$TEST_DIR/seek_copy_testfile
30 dest=$TEST_DIR/seek_copy_testfile.dest
32 _require_test_program "seek_copy_test"
39 # seek_copy_test_01: tests file with holes and written data extents.
41 # 1. file size is identical.
42 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
47 write_cmd="-c \"truncate 100m\""
48 for i in $(seq 0 5 100); do
49 offset=$(($i * $((1 << 20))))
50 write_cmd="$write_cmd -c \"pwrite $offset 1m\""
53 echo "*** test01() create sparse file ***" >>$seqres.full
54 eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
55 _fail "create sparse file failed!"
56 echo "*** test01() create sparse file done ***" >>$seqres.full
59 $here/src/seek_copy_test $src $dest
61 test $(_get_filesize $src) = $(_get_filesize $dest) ||
62 _fail "TEST01: file size check failed"
64 cmp $src $dest || _fail "TEST01: file bytes check failed"
67 # seek_copy_test_02 - tests file with holes, written and unwritten extents.
69 # 1. file size is identical.
70 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
75 write_cmd="-c \"truncate 200m\""
76 for i in $(seq 0 10 100); do
77 offset=$(($((6 << 20)) + $i * $((1 << 20))))
78 write_cmd="$write_cmd -c \"falloc $offset 3m\" -c \"pwrite $offset 1m\""
81 echo "*** test02() create sparse file ***" >>$seqres.full
82 eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
83 _fail "create sparse file failed!"
84 echo "*** test02() create sparse file done ***" >>$seqres.full
87 $here/src/seek_copy_test $src $dest
89 test $(_get_filesize $src) = $(_get_filesize $dest) ||
90 _fail "TEST02: file size check failed"
92 cmp $src $dest || _fail "TEST02: file bytes check failed"
95 # seek_copy_test_03 - tests file with unwritten with data, repeated unwritten
96 # without data, as well as data extents mapping.
98 # 1. file size is identical.
99 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
104 write_cmd="-c \"truncate 200m\""
107 # Firstly, make the file with allocated && reserved extents
108 # mapping without real data wrote.
110 for i in $(seq 0 10 180); do
111 offset=$(($((10 << 20)) + $i * $((1 << 20))))
112 write_cmd="$write_cmd -c \"falloc $offset 10m\""
116 # Secondly, write data to some unwritten extents, hence we
117 # have a test file will extents mapping as:
118 # |data|multiple unwritten_without_data|data| repeat...
119 for i in $(seq 0 60 180); do
120 offset=$(($((20 << 20)) + $i * $((1 << 20))))
121 write_cmd="$write_cmd -c \"pwrite $offset 10m\""
124 echo "*** test03() create sparse file ***" >>$seqres.full
125 eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
126 _fail "create sparse file failed!"
127 echo "*** test03() create sparse file done ***" >>$seqres.full
129 $here/src/seek_copy_test $src $dest
131 test $(_get_filesize $src) = $(_get_filesize $dest) ||
132 _fail "TEST03: file size check failed"
134 cmp $src $dest || _fail "TEST03: file bytes check failed"
137 # seek_copy_test_04 - tests file with hole, repeated unwritten
138 # without data, as well as data extents mapping.
140 # 1. file size is identical.
141 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
146 write_cmd="-c \"truncate 200m\""
149 # Firstly, make the file with allocated && reserved extents
150 # mapping without real data wrote.
152 for i in $(seq 30 30 180); do
153 offset=$(($((30 << 20)) + $i * $((1 << 20))))
154 write_cmd="$write_cmd -c \"falloc $offset 5m\""
158 # Secondly, write data to some unwritten extents, hence we
159 # have a test file will extents mapping as:
160 # |hole|multiple unwritten_without_data|hole|data| repeat...
161 for i in $(seq 30 90 180); do
162 offset=$(($((30 << 20)) + $i * $((1 << 20))))
163 write_cmd="$write_cmd -c \"pwrite $offset 2m\""
166 echo "*** test04() create sparse file ***" >>$seqres.full
167 eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
168 _fail "create sparse file failed!"
169 echo "*** test04() create sparse file done ***" >>$seqres.full
171 $here/src/seek_copy_test $src $dest
173 test $(_get_filesize $src) = $(_get_filesize $dest) ||
174 _fail "TEST04: file size check failed"
176 cmp $src $dest || _fail "TEST04: file bytes check failed"