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
34 _require_xfs_io_command "copy_range"
37 testdir=$TEST_DIR/test-$seq
42 echo "Create the original file and then copy"
43 echo -n "abcde" > $testdir/file
44 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
45 cmp $testdir/file $testdir/copy
46 echo "Original md5sums:"
47 md5sum $testdir/{file,copy} | _filter_test_dir
49 echo "Swap beginning and end of original file"
50 $XFS_IO_PROG -f -c "copy_range -s 0 -d 4 -l 1 $testdir/file" "$testdir/copy"
51 $XFS_IO_PROG -f -c "copy_range -s 4 -d 0 -l 1 $testdir/file" "$testdir/copy"
52 echo -n "ebcda" | cmp $testdir/copy
53 echo "md5sums after swapping beginning and end:"
54 md5sum $testdir/{file,copy} | _filter_test_dir
56 echo "Swap middle parts of original file"
57 $XFS_IO_PROG -f -c "copy_range -s 1 -d 3 -l 1 $testdir/file" "$testdir/copy"
58 $XFS_IO_PROG -f -c "copy_range -s 3 -d 1 -l 1 $testdir/file" "$testdir/copy"
59 echo -n "edcba" | cmp $testdir/copy
60 echo "md5sums after swapping middle:"
61 md5sum $testdir/{file,copy} | _filter_test_dir
63 echo "Copy tail of original file onto copy"
64 $XFS_IO_PROG -f -c "copy_range -s 1 -d 3 -l 4 $testdir/file" "$testdir/copy"
65 echo -n "edcbcde" | cmp $testdir/copy
66 echo "md5sums after copying tail:"
67 md5sum $testdir/{file,copy} | _filter_test_dir