4 # Tests vfs_copy_file_range():
6 # - Use copy to swap data at beginning and end
7 # - Use copy to swap data in the middle
8 # - Use copy to simultaneously overwrite and append to destination file
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2017 Netapp, Inc. All rights reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment
46 # real QA test starts here
50 _require_xfs_io_command "copy_range"
53 testdir=$TEST_DIR/test-$seq
58 echo "Create the original file and then copy"
59 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 1000' $testdir/file >> $seqres.full 2>&1
60 $XFS_IO_PROG -f -c 'pwrite -S 0x62 1000 1000' $testdir/file >> $seqres.full 2>&1
61 $XFS_IO_PROG -f -c 'pwrite -S 0x63 2000 1000' $testdir/file >> $seqres.full 2>&1
62 $XFS_IO_PROG -f -c 'pwrite -S 0x64 3000 1000' $testdir/file >> $seqres.full 2>&1
63 $XFS_IO_PROG -f -c 'pwrite -S 0x65 4000 1000' $testdir/file >> $seqres.full 2>&1
64 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
65 cmp $testdir/file $testdir/copy
66 echo "Original md5sums:"
67 md5sum $testdir/{file,copy} | _filter_test_dir
69 echo "Swap beginning and end of original file"
70 $XFS_IO_PROG -f -c "copy_range -s 4000 -l 1000 $testdir/file" "$testdir/copy"
71 $XFS_IO_PROG -f -c "copy_range -d 4000 -l 1000 $testdir/file" "$testdir/copy"
72 cmp -n 1000 $testdir/file $testdir/copy 4000
73 cmp -n 3000 $testdir/file $testdir/copy 1000 1000
74 cmp -n 1000 $testdir/file $testdir/copy 0 4000
75 echo "md5sums after swapping beginning and end:"
76 md5sum $testdir/{file,copy} | _filter_test_dir
78 echo "Swap middle parts of original file"
79 $XFS_IO_PROG -f -c "copy_range -s 1000 -d 3000 -l 1000 $testdir/file" "$testdir/copy"
80 $XFS_IO_PROG -f -c "copy_range -s 3000 -d 1000 -l 1000 $testdir/file" "$testdir/copy"
81 cmp -n 1000 $testdir/file $testdir/copy 4000
82 cmp -n 1000 $testdir/file $testdir/copy 3000 1000
83 cmp -n 1000 $testdir/file $testdir/copy 2000 2000
84 cmp -n 1000 $testdir/file $testdir/copy 1000 3000
85 cmp -n 1000 $testdir/file $testdir/copy 0 4000
86 echo "md5sums after swapping middle:"
87 md5sum $testdir/{file,copy} | _filter_test_dir
89 echo "Copy tail of original file onto copy"
90 $XFS_IO_PROG -f -c "copy_range -s 1000 -d 3000 -l 4000 $testdir/file" "$testdir/copy"
91 cmp -n 1000 $testdir/file $testdir/copy 4000
92 cmp -n 1000 $testdir/file $testdir/copy 3000 1000
93 cmp -n 1000 $testdir/file $testdir/copy 2000 2000
94 cmp -n 4000 $testdir/file $testdir/copy 1000 3000
95 echo "md5sums after copying tail:"
96 md5sum $testdir/{file,copy} | _filter_test_dir