generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[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 _supported_os Linux
34
35 _require_xfs_io_command "copy_range"
36 _require_test
37
38 testdir=$TEST_DIR/test-$seq
39 rm -rf $testdir
40 mkdir $testdir
41 rm -f $seqres.full
42
43 echo "Create the original file and then copy"
44 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0    1000' $testdir/file >> $seqres.full 2>&1
45 $XFS_IO_PROG -f -c 'pwrite -S 0x62 1000 1000' $testdir/file >> $seqres.full 2>&1
46 $XFS_IO_PROG -f -c 'pwrite -S 0x63 2000 1000' $testdir/file >> $seqres.full 2>&1
47 $XFS_IO_PROG -f -c 'pwrite -S 0x64 3000 1000' $testdir/file >> $seqres.full 2>&1
48 $XFS_IO_PROG -f -c 'pwrite -S 0x65 4000 1000' $testdir/file >> $seqres.full 2>&1
49 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
50 cmp $testdir/file  $testdir/copy
51 echo "Original md5sums:"
52 md5sum $testdir/{file,copy} | _filter_test_dir
53
54 echo "Swap beginning and end of original file"
55 $XFS_IO_PROG -f -c "copy_range -s 4000 -l 1000 $testdir/file" "$testdir/copy"
56 $XFS_IO_PROG -f -c "copy_range -d 4000 -l 1000 $testdir/file" "$testdir/copy"
57 cmp -n 1000 $testdir/file $testdir/copy 4000
58 cmp -n 3000 $testdir/file $testdir/copy 1000 1000
59 cmp -n 1000 $testdir/file $testdir/copy 0 4000
60 echo "md5sums after swapping beginning and end:"
61 md5sum $testdir/{file,copy} | _filter_test_dir
62
63 echo "Swap middle parts of original file"
64 $XFS_IO_PROG -f -c "copy_range -s 1000 -d 3000 -l 1000 $testdir/file" "$testdir/copy"
65 $XFS_IO_PROG -f -c "copy_range -s 3000 -d 1000 -l 1000 $testdir/file" "$testdir/copy"
66 cmp -n 1000 $testdir/file $testdir/copy 4000
67 cmp -n 1000 $testdir/file $testdir/copy 3000 1000
68 cmp -n 1000 $testdir/file $testdir/copy 2000 2000
69 cmp -n 1000 $testdir/file $testdir/copy 1000 3000
70 cmp -n 1000 $testdir/file $testdir/copy 0 4000
71 echo "md5sums after swapping middle:"
72 md5sum $testdir/{file,copy} | _filter_test_dir
73
74 echo "Copy tail of original file onto copy"
75 $XFS_IO_PROG -f -c "copy_range -s 1000 -d 3000 -l 4000 $testdir/file" "$testdir/copy"
76 cmp -n 1000 $testdir/file $testdir/copy 4000
77 cmp -n 1000 $testdir/file $testdir/copy 3000 1000
78 cmp -n 1000 $testdir/file $testdir/copy 2000 2000
79 cmp -n 4000 $testdir/file $testdir/copy 1000 3000
80 echo "md5sums after copying tail:"
81 md5sum $testdir/{file,copy} | _filter_test_dir
82
83 #success, all done
84 status=0
85 exit