common/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify
[xfstests-dev.git] / tests / generic / 430
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. 430
6 #
7 # Tests vfs_copy_file_range():
8 #   - Copy a file
9 #   - Copy beginning of original to new file
10 #   - Copy middle of original to a new file
11 #   - Copy end of original to new file
12 #   - Copy middle of original to a new file, creating a hole
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1    # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -rf $tmp.*
26 }
27
28 # get standard environment
29 . common/rc
30 . common/filter
31
32 # real QA test starts here
33 _supported_fs generic
34 _supported_os Linux
35
36 _require_xfs_io_command "copy_range"
37 _require_test
38
39 testdir=$TEST_DIR/test-$seq
40 rm -rf $testdir
41 mkdir $testdir
42 rm -f $seqres.full
43
44 echo "Create the original file and then copy"
45 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0    1000' $testdir/file >> $seqres.full 2>&1
46 $XFS_IO_PROG -f -c 'pwrite -S 0x62 1000 1000' $testdir/file >> $seqres.full 2>&1
47 $XFS_IO_PROG -f -c 'pwrite -S 0x63 2000 1000' $testdir/file >> $seqres.full 2>&1
48 $XFS_IO_PROG -f -c 'pwrite -S 0x64 3000 1000' $testdir/file >> $seqres.full 2>&1
49 $XFS_IO_PROG -f -c 'pwrite -S 0x65 4000 1000' $testdir/file >> $seqres.full 2>&1
50 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
51 cmp $testdir/file $testdir/copy
52 echo "Original md5sums:"
53 md5sum $testdir/{file,copy} | _filter_test_dir
54
55 echo "Copy beginning of original file"
56 $XFS_IO_PROG -f -c "copy_range -l 1000 $testdir/file" "$testdir/beginning"
57 cmp -n 1000 $testdir/file $testdir/beginning
58 echo "md5sums after copying beginning:"
59 md5sum $testdir/{file,beginning} | _filter_test_dir
60
61 echo "Copy middle of original file"
62 $XFS_IO_PROG -f -c "copy_range -s 1000 -l 3000 $testdir/file" "$testdir/middle"
63 cmp -n 3000 $testdir/file $testdir/middle 1000
64 echo "md5sums after copying middle:"
65 md5sum $testdir/{file,middle} | _filter_test_dir
66
67 echo "Copy end of original file"
68 $XFS_IO_PROG -f -c "copy_range -s 4000 -l 1000 $testdir/file" "$testdir/end"
69 cmp -n 1000 $testdir/file $testdir/end 4000
70 echo "md5sums after copying end:"
71 md5sum $testdir/{file,end} | _filter_test_dir
72
73 echo "Copy beyond end of original file"
74 $XFS_IO_PROG -f -c "copy_range -s 4000 -l 2000 $testdir/file" "$testdir/beyond"
75 cmp -n 1000 $testdir/file $testdir/beyond 4000
76 echo "md5sums after copying beyond:"
77 md5sum $testdir/{file,beyond} | _filter_test_dir
78
79 echo "Copy creates hole in target file"
80 $XFS_IO_PROG -f -c "copy_range -s 1000 -l 3000 -d 1000 $testdir/file" "$testdir/hole"
81 cmp -n 3000 $testdir/file $testdir/hole 1000 1000
82 echo "md5sums after creating hole:"
83 md5sum $testdir/{file,hole} | _filter_test_dir
84
85 #success, all done
86 status=0
87 exit