tests: remove udf/101
[xfstests-dev.git] / tests / generic / 432
1 #!/bin/bash
2 # FS QA Test No. 432
3 #
4 # Tests vfs_copy_file_range():
5 #   - Copy a file
6 #   - Use copy to swap data at beginning and end
7 #   - Use copy to swap data in the middle
8 #   - Use copy to simultaneously overwrite and append to destination file
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2017 Netapp, Inc. All rights reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1    # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38         cd /
39         rm -rf $tmp.*
40 }
41
42 # get standard environment
43 . common/rc
44 . common/filter
45
46 # real QA test starts here
47 _supported_fs generic
48 _supported_os Linux
49
50 _require_xfs_io_command "copy_range"
51 _require_test
52
53 testdir=$TEST_DIR/test-$seq
54 rm -rf $testdir
55 mkdir $testdir
56 rm -f $seqres.full
57
58 echo "Create the original file and then copy"
59 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0    1000' $testdir/file >> $seqres.full 2>&1
60 $XFS_IO_PROG -f -c 'pwrite -S 0x62 1000 1000' $testdir/file >> $seqres.full 2>&1
61 $XFS_IO_PROG -f -c 'pwrite -S 0x63 2000 1000' $testdir/file >> $seqres.full 2>&1
62 $XFS_IO_PROG -f -c 'pwrite -S 0x64 3000 1000' $testdir/file >> $seqres.full 2>&1
63 $XFS_IO_PROG -f -c 'pwrite -S 0x65 4000 1000' $testdir/file >> $seqres.full 2>&1
64 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
65 cmp $testdir/file  $testdir/copy
66 echo "Original md5sums:"
67 md5sum $testdir/{file,copy} | _filter_test_dir
68
69 echo "Swap beginning and end of original file"
70 $XFS_IO_PROG -f -c "copy_range -s 4000 -l 1000 $testdir/file" "$testdir/copy"
71 $XFS_IO_PROG -f -c "copy_range -d 4000 -l 1000 $testdir/file" "$testdir/copy"
72 cmp -n 1000 $testdir/file $testdir/copy 4000
73 cmp -n 3000 $testdir/file $testdir/copy 1000 1000
74 cmp -n 1000 $testdir/file $testdir/copy 0 4000
75 echo "md5sums after swapping beginning and end:"
76 md5sum $testdir/{file,copy} | _filter_test_dir
77
78 echo "Swap middle parts of original file"
79 $XFS_IO_PROG -f -c "copy_range -s 1000 -d 3000 -l 1000 $testdir/file" "$testdir/copy"
80 $XFS_IO_PROG -f -c "copy_range -s 3000 -d 1000 -l 1000 $testdir/file" "$testdir/copy"
81 cmp -n 1000 $testdir/file $testdir/copy 4000
82 cmp -n 1000 $testdir/file $testdir/copy 3000 1000
83 cmp -n 1000 $testdir/file $testdir/copy 2000 2000
84 cmp -n 1000 $testdir/file $testdir/copy 1000 3000
85 cmp -n 1000 $testdir/file $testdir/copy 0 4000
86 echo "md5sums after swapping middle:"
87 md5sum $testdir/{file,copy} | _filter_test_dir
88
89 echo "Copy tail of original file onto copy"
90 $XFS_IO_PROG -f -c "copy_range -s 1000 -d 3000 -l 4000 $testdir/file" "$testdir/copy"
91 cmp -n 1000 $testdir/file $testdir/copy 4000
92 cmp -n 1000 $testdir/file $testdir/copy 3000 1000
93 cmp -n 1000 $testdir/file $testdir/copy 2000 2000
94 cmp -n 4000 $testdir/file $testdir/copy 1000 3000
95 echo "md5sums after copying tail:"
96 md5sum $testdir/{file,copy} | _filter_test_dir
97
98 #success, all done
99 status=0
100 exit