overlay: run unionmount testsuite test cases
[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 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 echo -n "abcde" > $testdir/file
45 $XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
46 cmp $testdir/file $testdir/copy
47 echo "Original md5sums:"
48 md5sum $testdir/{file,copy} | _filter_test_dir
49
50 echo "Swap beginning and end of original file"
51 $XFS_IO_PROG -f -c "copy_range -s 0 -d 4 -l 1 $testdir/file" "$testdir/copy"
52 $XFS_IO_PROG -f -c "copy_range -s 4 -d 0 -l 1 $testdir/file" "$testdir/copy"
53 echo -n "ebcda" | cmp $testdir/copy
54 echo "md5sums after swapping beginning and end:"
55 md5sum $testdir/{file,copy} | _filter_test_dir
56
57 echo "Swap middle parts of original file"
58 $XFS_IO_PROG -f -c "copy_range -s 1 -d 3 -l 1 $testdir/file" "$testdir/copy"
59 $XFS_IO_PROG -f -c "copy_range -s 3 -d 1 -l 1 $testdir/file" "$testdir/copy"
60 echo -n "edcba" | cmp $testdir/copy
61 echo "md5sums after swapping middle:"
62 md5sum $testdir/{file,copy} | _filter_test_dir
63
64 echo "Copy tail of original file onto copy"
65 $XFS_IO_PROG -f -c "copy_range -s 1 -d 3 -l 4 $testdir/file" "$testdir/copy"
66 echo -n "edcbcde" | cmp $testdir/copy
67 echo "md5sums after copying tail:"
68 md5sum $testdir/{file,copy} | _filter_test_dir
69
70 #success, all done
71 status=0
72 exit