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 #-----------------------------------------------------------------------
25 owner=jeff.liu@oracle.com
28 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
34 # get standard environment, filters and checks
38 # real QA test starts here
42 src=$TEST_DIR/seek_copy_testfile
43 dest=$TEST_DIR/seek_copy_testfile.dest
45 [ -x $here/src/seek_copy_test ] || _notrun "seek_copy_test not built"
52 # seek_copy_test_01: tests file with holes and written data extents.
54 # 1. file size is identical.
55 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
60 write_cmd="-c \"truncate 100m\""
61 for i in $(seq 0 5 100); do
62 offset=$(($i * $((1 << 20))))
63 write_cmd="$write_cmd -c \"pwrite $offset 1m\""
66 echo "*** test01() create sparse file ***" >>$seq.full
67 eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seq.full 2>&1 ||
68 _fail "create sparse file failed!"
69 echo "*** test01() create sparse file done ***" >>$seq.full
72 $here/src/seek_copy_test $src $dest
74 test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
75 _fail "TEST01: file size check failed"
77 cmp $src $dest || _fail "TEST01: file bytes check failed"
80 # seek_copy_test_02 - tests file with holes, written and unwritten extents.
82 # 1. file size is identical.
83 # 2. perform cmp(1) to compare SRC and DEST file byte by byte.
88 write_cmd="-c \"truncate 200m\""
89 for i in $(seq 0 10 100); do
90 offset=$(($((6 << 20)) + $i * $((1 << 20))))
91 write_cmd="$write_cmd -c \"falloc $offset 3m\" -c \"pwrite $offset 1m\""
94 echo "*** test02() create sparse file ***" >>$seq.full
95 eval ${XFS_IO_PROG} -F -f "${write_cmd}" $src >>$seq.full 2>&1 ||
96 _fail "create sparse file failed!"
97 echo "*** test02() create sparse file done ***" >>$seq.full
100 $here/src/seek_copy_test $src $dest
102 test $(stat --printf "%s" $src) = $(stat --printf "%s" $dest) ||
103 _fail "TEST02: file size check failed"
105 cmp $src $dest || _fail "TEST02: file bytes check failed"