2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Netapp, Inc. All rights reserved.
7 # Tests vfs_copy_file_range():
9 # - Small copies from various points in the original file
11 _begin_fstest auto quick copy_range
13 # get standard environment
16 # real QA test starts here
19 _require_xfs_io_command "copy_range"
22 testdir=$TEST_DIR/test-$seq
26 echo "Create the original file and then copy"
27 echo -n "abcde" > $testdir/file
28 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
29 echo -n "abcde" | cmp $testdir/copy
30 echo "Original md5sums:"
31 md5sum $testdir/{file,copy} | _filter_test_dir
33 echo "Small copies from various points in the original file"
34 $XFS_IO_PROG -f -c "copy_range -s 0 -l 1 $testdir/file" "$testdir/a"
35 $XFS_IO_PROG -f -c "copy_range -s 1 -l 1 $testdir/file" "$testdir/b"
36 $XFS_IO_PROG -f -c "copy_range -s 2 -l 1 $testdir/file" "$testdir/c"
37 $XFS_IO_PROG -f -c "copy_range -s 3 -l 1 $testdir/file" "$testdir/d"
38 $XFS_IO_PROG -f -c "copy_range -s 4 -l 1 $testdir/file" "$testdir/e"
39 $XFS_IO_PROG -f -c "copy_range -s 4 -l 1 -d 1 $testdir/file" "$testdir/f"
40 $XFS_IO_PROG -f -c "copy_range -s 5 -l 1 $testdir/file" "$testdir/g"
41 echo -n "a" | cmp $testdir/a
42 echo -n "b" | cmp $testdir/b
43 echo -n "c" | cmp $testdir/c
44 echo -n "d" | cmp $testdir/d
45 echo -n "e" | cmp $testdir/e
46 echo -en "\0e" | cmp $testdir/f
47 echo -n "" | cmp $testdir/g
48 echo "md5sums after small copies"
49 md5sum $testdir/{file,a,b,c,d,e,f,g} | _filter_test_dir