overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / xfs / 236
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. 236
6 #
7 # Ensure that we can create enough distinct rmapbt entries to force creation
8 # of a multi-level rmap btree.  Delete and recreate a few times to
9 # exercise the rmap btree grow/shrink functions.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1    # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22     cd /
23     umount $SCRATCH_MNT > /dev/null 2>&1
24     rm -rf $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32 _supported_os Linux
33 _supported_fs xfs
34 _require_xfs_scratch_rmapbt
35 _require_xfs_io_command "fpunch"
36
37 rm -f $seqres.full
38
39 _scratch_mkfs >/dev/null 2>&1
40 _scratch_mount
41
42 testdir=$SCRATCH_MNT/test-$seq
43 mkdir $testdir
44
45 echo "Create the original file blocks"
46 blksz="$(_get_block_size $testdir)"
47 nr_blks=$((8 * blksz / 12))
48
49 for i in 1 2 x; do
50         _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
51         _pwrite_byte 0x62 0 $((blksz * nr_blks)) $testdir/file2 >> $seqres.full
52         sync
53
54         echo "$i: Reflink every other block"
55         seq 1 2 $((nr_blks - 1)) | while read nr; do
56                 $XFS_IO_PROG -c "fpunch $((nr * blksz)) $blksz" $testdir/file2 >> $seqres.full
57         done
58         umount $SCRATCH_MNT
59         _check_scratch_fs
60         _scratch_mount
61
62         test $i = "x" && break
63
64         echo "$i: Delete both files"
65         rm -rf $testdir/file1 $testdir/file2
66         umount $SCRATCH_MNT
67         _check_scratch_fs
68         _scratch_mount
69 done
70
71 # success, all done
72 status=0
73 exit