overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / xfs / 210
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 210
6 #
7 # During reflink, XFS should carry the cowextsz setting to the destination file
8 # if the destination file size is less than the size of the source file, the
9 # length is the size of the source file, both offsets are zero, and the
10 # destination does not already have a cowextsz setting.  It should not do so
11 # otherwise.
12 #
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, filters and checks
29 . ./common/rc
30 . ./common/filter
31 . ./common/reflink
32
33 # real QA test starts here
34 _supported_os Linux
35 _supported_fs xfs
36 _require_scratch_reflink
37 _require_cp_reflink
38 _require_xfs_io_command "fiemap"
39 _require_xfs_io_command "cowextsize"
40
41 rm -f $seqres.full
42
43 echo "Format and mount"
44 _scratch_mkfs > $seqres.full 2>&1
45 _scratch_mount >> $seqres.full 2>&1
46
47 testdir=$SCRATCH_MNT/test-$seq
48 mkdir $testdir
49
50 echo "Create initial file"
51 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 131072" $testdir/file1 >> $seqres.full
52 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file1 >> $seqres.full
53 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 1" $testdir/file4 >> $seqres.full
54 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 262144" $testdir/file7 >> $seqres.full
55 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 262144" $testdir/file9 >> $seqres.full
56 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 262144" $testdir/file10 >> $seqres.full
57
58 echo "Reflink to an empty file"
59 _reflink_range $testdir/file1 0 $testdir/file2 0 0 >> $seqres.full
60
61 echo "Reflink to an empty file that already has cowextsz"
62 $XFS_IO_PROG -f -c "cowextsize 524288" $testdir/file3 >> $seqres.full
63 _reflink_range $testdir/file1 0 $testdir/file3 0 0 >> $seqres.full
64
65 echo "Reflink to a small file"
66 _reflink_range $testdir/file1 0 $testdir/file4 0 0 >> $seqres.full
67
68 echo "Reflink to a nonzero offset"
69 _reflink_range $testdir/file1 0 $testdir/file5 65536 0 >> $seqres.full
70
71 echo "Reflink from a nonzero offset"
72 _reflink_range $testdir/file1 65536 $testdir/file6 0 0 >> $seqres.full
73
74 echo "Reflink to a larger file"
75 _reflink_range $testdir/file1 0 $testdir/file7 0 0 >> $seqres.full
76
77 echo "Reflink less than the whole source file"
78 _reflink_range $testdir/file1 0 $testdir/file8 0 65536 >> $seqres.full
79
80 echo "cp reflink to a larger file"
81 _cp_reflink $testdir/file1 $testdir/file9 >> $seqres.full
82
83 echo "cp reflink to a larger file with cowextsize"
84 $XFS_IO_PROG -f -c "cowextsize 524288" $testdir/file10 >> $seqres.full
85 _cp_reflink $testdir/file1 $testdir/file10 >> $seqres.full
86
87 echo "Check cowextsz"
88 for i in `seq 1 10`; do
89         $XFS_IO_PROG -c "cowextsize" $testdir/file$i | _filter_scratch
90 done
91
92 # success, all done
93 status=0
94 exit