fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 291
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. 291
6 #
7 # Ensuring that copy on write in buffered mode to the source file when the
8 # CoW range covers holes and regular shared blocks.
9 #   - Create two files.
10 #   - Truncate the first file.
11 #   - Write the odd blocks of the first file.
12 #   - Reflink the odd blocks of the first file into the second file.
13 #   - CoW the first file across the halfway mark, starting with the
14 #     regular extent.
15 #   - Check that the files are now different where we say they're different.
16 #
17 . ./common/preamble
18 _begin_fstest auto quick clone
19
20 # Import common functions.
21 . ./common/filter
22 . ./common/reflink
23
24 # real QA test starts here
25 _require_scratch_reflink
26 _require_xfs_io_command "falloc"
27
28 echo "Format and mount"
29 _scratch_mkfs > $seqres.full 2>&1
30 _scratch_mount >> $seqres.full 2>&1
31
32 testdir=$SCRATCH_MNT/test-$seq
33 mkdir $testdir
34
35 echo "Create the original files"
36 blksz=65536
37 nr=64
38 filesize=$((blksz * nr))
39 _sweave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
40 _scratch_cycle_mount
41
42 echo "Compare files"
43 md5sum $testdir/file1 | _filter_scratch
44 md5sum $testdir/file3 | _filter_scratch
45 md5sum $testdir/file1.chk | _filter_scratch
46
47 echo "CoW across the transition"
48 cowoff=$((filesize / 4))
49 cowsz=$((filesize / 2))
50 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file1 >> $seqres.full
51 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file1.chk >> $seqres.full
52 _scratch_cycle_mount
53
54 echo "Compare files"
55 md5sum $testdir/file1 | _filter_scratch
56 md5sum $testdir/file3 | _filter_scratch
57 md5sum $testdir/file1.chk | _filter_scratch
58
59 # success, all done
60 status=0
61 exit