common/rc: Add _require_{chown,chmod}()
[xfstests-dev.git] / tests / generic / 189
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. 189
6 #
7 # Ensuring that copy on write in buffered mode works when the CoW
8 # range originally covers multiple extents, some unwritten, some not.
9 #   - Create a file and fallocate a second file.
10 #   - Reflink the odd blocks of the first file into the second file.
11 #   - CoW across the halfway mark, starting with the unwritten extent.
12 #   - Check that the files are now different where we say they're different.
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1    # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25     cd /
26     rm -rf $tmp.* $testdir
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32 . ./common/reflink
33
34 # real QA test starts here
35 _require_scratch_reflink
36 _require_xfs_io_command "falloc"
37
38 rm -f $seqres.full
39
40 echo "Format and mount"
41 _scratch_mkfs > $seqres.full 2>&1
42 _scratch_mount >> $seqres.full 2>&1
43
44 testdir=$SCRATCH_MNT/test-$seq
45 mkdir $testdir
46
47 echo "Create the original files"
48 blksz=65536
49 nr=64
50 filesize=$((blksz * nr))
51 _weave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $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/file3.chk | _filter_scratch
58
59 echo "CoW across the transition"
60 cowoff=$((filesize / 4))
61 cowsz=$((filesize / 2))
62 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
63 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
64 _scratch_cycle_mount
65
66 echo "Compare files"
67 md5sum $testdir/file1 | _filter_scratch
68 md5sum $testdir/file3 | _filter_scratch
69 md5sum $testdir/file3.chk | _filter_scratch
70
71 # success, all done
72 status=0
73 exit