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