fstests: move test group info to test files
[xfstests-dev.git] / tests / xfs / 309
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. 309
6 #
7 # Ensure that we can create enough distinct reflink entries to force creation
8 # of a multi-level refcount btree by reflinking a file a number of times and
9 # truncating the copies at successively lower sizes.  Delete and recreate a few
10 # times to exercise the refcount btree grow/shrink functions.
11 #
12 . ./common/preamble
13 _begin_fstest auto clone
14
15 # Override the default cleanup function.
16 _cleanup()
17 {
18         cd /
19         _scratch_unmount > /dev/null 2>&1
20         rm -rf $tmp.*
21 }
22
23 # Import common functions.
24 . ./common/filter
25 . ./common/reflink
26
27 # real QA test starts here
28 _supported_fs xfs
29 _require_scratch_reflink
30 _require_cp_reflink
31
32 _scratch_mkfs >/dev/null 2>&1
33 _scratch_mount
34
35 testdir=$SCRATCH_MNT/test-$seq
36 mkdir $testdir
37
38 echo "Create the original file blocks"
39 blksz="$(_get_block_size $testdir)"
40 nr_blks=$((2 * blksz / 12))
41
42 for i in 1 2 x; do
43         _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
44
45         echo "$i: Reflink a bunch of times"
46         seq 1 $nr_blks | while read nr; do
47                 _cp_reflink $testdir/file1 $testdir/file1.$nr >> $seqres.full
48         done
49         sync
50
51         echo "$i: Truncate files"
52         seq 1 $nr_blks | while read nr; do
53                 truncate -s $((blksz * (nr_blks - nr))) $testdir/file1.$nr >> $seqres.full
54         done
55
56         _scratch_unmount
57         _check_scratch_fs
58         _scratch_mount
59
60         test $i = "x" && break
61
62         echo "$i: Delete both files"
63         rm -rf $testdir
64         mkdir -p $testdir
65         _scratch_unmount
66         _check_scratch_fs
67         _scratch_mount
68 done
69
70 # success, all done
71 status=0
72 exit