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 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment
29 # real QA test starts here
32 _require_xfs_io_command "copy_range"
35 testdir=$TEST_DIR/test-$seq
40 echo "Create the original file and then copy"
41 echo -n "abcde" > $testdir/file
42 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
43 echo -n "abcde" | cmp $testdir/copy
44 echo "Original md5sums:"
45 md5sum $testdir/{file,copy} | _filter_test_dir
47 echo "Small copies from various points in the original file"
48 $XFS_IO_PROG -f -c "copy_range -s 0 -l 1 $testdir/file" "$testdir/a"
49 $XFS_IO_PROG -f -c "copy_range -s 1 -l 1 $testdir/file" "$testdir/b"
50 $XFS_IO_PROG -f -c "copy_range -s 2 -l 1 $testdir/file" "$testdir/c"
51 $XFS_IO_PROG -f -c "copy_range -s 3 -l 1 $testdir/file" "$testdir/d"
52 $XFS_IO_PROG -f -c "copy_range -s 4 -l 1 $testdir/file" "$testdir/e"
53 $XFS_IO_PROG -f -c "copy_range -s 4 -l 1 -d 1 $testdir/file" "$testdir/f"
54 $XFS_IO_PROG -f -c "copy_range -s 5 -l 1 $testdir/file" "$testdir/g"
55 echo -n "a" | cmp $testdir/a
56 echo -n "b" | cmp $testdir/b
57 echo -n "c" | cmp $testdir/c
58 echo -n "d" | cmp $testdir/d
59 echo -n "e" | cmp $testdir/e
60 echo -en "\0e" | cmp $testdir/f
61 echo -n "" | cmp $testdir/g
62 echo "md5sums after small copies"
63 md5sum $testdir/{file,a,b,c,d,e,f,g} | _filter_test_dir