2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Netapp, Inc. All rights reserved.
7 # Tests vfs_copy_file_range():
9 # - Use copy to swap data at beginning and end
10 # - Use copy to swap data in the middle
11 # - Use copy to swap data in a small file
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment
31 # 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 echo -n "abcde" > $testdir/file
45 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
46 cmp $testdir/file $testdir/copy
47 echo "Original md5sums:"
48 md5sum $testdir/{file,copy} | _filter_test_dir
50 echo "Swap beginning and end of original file"
51 $XFS_IO_PROG -f -c "copy_range -s 0 -d 4 -l 1 $testdir/file" "$testdir/copy"
52 $XFS_IO_PROG -f -c "copy_range -s 4 -d 0 -l 1 $testdir/file" "$testdir/copy"
53 echo -n "ebcda" | cmp $testdir/copy
54 echo "md5sums after swapping beginning and end:"
55 md5sum $testdir/{file,copy} | _filter_test_dir
57 echo "Swap middle parts of original file"
58 $XFS_IO_PROG -f -c "copy_range -s 1 -d 3 -l 1 $testdir/file" "$testdir/copy"
59 $XFS_IO_PROG -f -c "copy_range -s 3 -d 1 -l 1 $testdir/file" "$testdir/copy"
60 echo -n "edcba" | cmp $testdir/copy
61 echo "md5sums after swapping middle:"
62 md5sum $testdir/{file,copy} | _filter_test_dir
64 echo "Copy tail of original file onto copy"
65 $XFS_IO_PROG -f -c "copy_range -s 1 -d 3 -l 4 $testdir/file" "$testdir/copy"
66 echo -n "edcbcde" | cmp $testdir/copy
67 echo "md5sums after copying tail:"
68 md5sum $testdir/{file,copy} | _filter_test_dir