2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Netapp, Inc. All rights reserved.
7 # Tests vfs_copy_file_range():
9 # - Copy beginning of original to new file
10 # - Copy middle of original to a new file
11 # - Copy end of original to new file
12 # - Copy middle of original to a new file, creating a hole
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment
32 # real QA test starts here
35 _require_xfs_io_command "copy_range"
38 testdir=$TEST_DIR/test-$seq
43 echo "Create the original file and then copy"
44 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 1000' $testdir/file >> $seqres.full 2>&1
45 $XFS_IO_PROG -f -c 'pwrite -S 0x62 1000 1000' $testdir/file >> $seqres.full 2>&1
46 $XFS_IO_PROG -f -c 'pwrite -S 0x63 2000 1000' $testdir/file >> $seqres.full 2>&1
47 $XFS_IO_PROG -f -c 'pwrite -S 0x64 3000 1000' $testdir/file >> $seqres.full 2>&1
48 $XFS_IO_PROG -f -c 'pwrite -S 0x65 4000 1000' $testdir/file >> $seqres.full 2>&1
49 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
50 cmp $testdir/file $testdir/copy
51 echo "Original md5sums:"
52 md5sum $testdir/{file,copy} | _filter_test_dir
54 echo "Copy beginning of original file"
55 $XFS_IO_PROG -f -c "copy_range -l 1000 $testdir/file" "$testdir/beginning"
56 cmp -n 1000 $testdir/file $testdir/beginning
57 echo "md5sums after copying beginning:"
58 md5sum $testdir/{file,beginning} | _filter_test_dir
60 echo "Copy middle of original file"
61 $XFS_IO_PROG -f -c "copy_range -s 1000 -l 3000 $testdir/file" "$testdir/middle"
62 cmp -n 3000 $testdir/file $testdir/middle 1000
63 echo "md5sums after copying middle:"
64 md5sum $testdir/{file,middle} | _filter_test_dir
66 echo "Copy end of original file"
67 $XFS_IO_PROG -f -c "copy_range -s 4000 -l 1000 $testdir/file" "$testdir/end"
68 cmp -n 1000 $testdir/file $testdir/end 4000
69 echo "md5sums after copying end:"
70 md5sum $testdir/{file,end} | _filter_test_dir
72 echo "Copy beyond end of original file"
73 $XFS_IO_PROG -f -c "copy_range -s 4000 -l 2000 $testdir/file" "$testdir/beyond"
74 cmp -n 1000 $testdir/file $testdir/beyond 4000
75 echo "md5sums after copying beyond:"
76 md5sum $testdir/{file,beyond} | _filter_test_dir
78 echo "Copy creates hole in target file"
79 $XFS_IO_PROG -f -c "copy_range -s 1000 -l 3000 -d 1000 $testdir/file" "$testdir/hole"
80 cmp -n 3000 $testdir/file $testdir/hole 1000 1000
81 echo "md5sums after creating hole:"
82 md5sum $testdir/{file,hole} | _filter_test_dir