fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 433
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Netapp, Inc. All rights reserved.
4 #
5 # FS QA Test No. 433
6 #
7 # Tests vfs_copy_file_range():
8 #   - Copy a small file
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
12 . ./common/preamble
13 _begin_fstest auto quick copy_range
14
15 # get standard environment
16 . common/filter
17
18 # real QA test starts here
19 _supported_fs generic
20
21 _require_xfs_io_command "copy_range"
22 _require_test
23
24 testdir=$TEST_DIR/test-$seq
25 rm -rf $testdir
26 mkdir $testdir
27
28 echo "Create the original file and then copy"
29 echo -n "abcde" > $testdir/file
30 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
31 cmp $testdir/file $testdir/copy
32 echo "Original md5sums:"
33 md5sum $testdir/{file,copy} | _filter_test_dir
34
35 echo "Swap beginning and end of original file"
36 $XFS_IO_PROG -f -c "copy_range -s 0 -d 4 -l 1 $testdir/file" "$testdir/copy"
37 $XFS_IO_PROG -f -c "copy_range -s 4 -d 0 -l 1 $testdir/file" "$testdir/copy"
38 echo -n "ebcda" | cmp $testdir/copy
39 echo "md5sums after swapping beginning and end:"
40 md5sum $testdir/{file,copy} | _filter_test_dir
41
42 echo "Swap middle parts of original file"
43 $XFS_IO_PROG -f -c "copy_range -s 1 -d 3 -l 1 $testdir/file" "$testdir/copy"
44 $XFS_IO_PROG -f -c "copy_range -s 3 -d 1 -l 1 $testdir/file" "$testdir/copy"
45 echo -n "edcba" | cmp $testdir/copy
46 echo "md5sums after swapping middle:"
47 md5sum $testdir/{file,copy} | _filter_test_dir
48
49 echo "Copy tail of original file onto copy"
50 $XFS_IO_PROG -f -c "copy_range -s 1 -d 3 -l 4 $testdir/file" "$testdir/copy"
51 echo -n "edcbcde" | cmp $testdir/copy
52 echo "md5sums after copying tail:"
53 md5sum $testdir/{file,copy} | _filter_test_dir
54
55 #success, all done
56 status=0
57 exit