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