fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 540
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 540
6 #
7 # Ensuring that reflinking works when the destination range covers multiple
8 # extents, some unwritten, some not:
9 #
10 #   - Create a file with the following repeating sequence of blocks:
11 #     1. reflinked
12 #     2. unwritten
13 #     3. hole
14 #     4. regular block
15 #     5. delalloc
16 #   - reflink across the halfway mark, starting with the unwritten extent.
17 #   - Check that the files are now different where we say they're different.
18 #
19 . ./common/preamble
20 _begin_fstest auto quick clone
21
22 # Import common functions.
23 . ./common/filter
24 . ./common/reflink
25
26 # real QA test starts here
27 _supported_fs generic
28 _require_scratch_reflink
29 _require_xfs_io_command "falloc"
30
31 echo "Format and mount"
32 _scratch_mkfs > $seqres.full 2>&1
33 _scratch_mount >> $seqres.full 2>&1
34
35 testdir=$SCRATCH_MNT/test-$seq
36 mkdir $testdir
37
38 echo "Create the original files"
39 blksz=65536
40 nr=64
41 filesize=$((blksz * nr))
42 _pwrite_byte 0x64 0 $((blksz * nr)) $testdir/file2 >> $seqres.full
43 _weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
44 _scratch_cycle_mount
45
46 echo "Compare files"
47 md5sum $testdir/file1 | _filter_scratch
48 md5sum $testdir/file2 | _filter_scratch
49 md5sum $testdir/file3 | _filter_scratch
50 md5sum $testdir/file3.chk | _filter_scratch
51
52 echo "reflink across the transition"
53 roff=$((filesize / 4))
54 rsz=$((filesize / 2))
55 _weave_reflink_rainbow_delalloc $blksz $nr $testdir/file3 >> $seqres.full
56
57 # now reflink into the rainbow
58 echo "before reflink" >> $seqres.full
59 $FILEFRAG_PROG -v $testdir/file2 >> $seqres.full 2>&1
60 $FILEFRAG_PROG -v $testdir/file3 >> $seqres.full 2>&1
61 $XFS_IO_PROG -f -c "reflink $testdir/file2 $roff $roff $rsz" $testdir/file3 >> $seqres.full
62 _pwrite_byte 0x64 $roff $rsz $testdir/file3.chk >> $seqres.full
63 _scratch_cycle_mount
64
65 echo "Compare files"
66 echo "after reflink" >> $seqres.full
67 $FILEFRAG_PROG -v $testdir/file2 >> $seqres.full 2>&1
68 $FILEFRAG_PROG -v $testdir/file3 >> $seqres.full 2>&1
69 md5sum $testdir/file1 | _filter_scratch
70 md5sum $testdir/file2 | _filter_scratch
71 md5sum $testdir/file3 | _filter_scratch
72 md5sum $testdir/file3.chk | _filter_scratch
73
74 # success, all done
75 status=0
76 exit