fstests: move test group info to test files
[xfstests-dev.git] / tests / xfs / 140
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. 140
6 #
7 # Try to ENOSPC while expanding the refcntbt by CoWing every other block
8 # of a file that eats the whole AG.
9 #
10 . ./common/preamble
11 _begin_fstest auto clone
12
13 # Override the default cleanup function.
14 _cleanup()
15 {
16     cd /
17     rm -rf $tmp.* $testdir
18 }
19
20 # Import common functions.
21 . ./common/filter
22 . ./common/reflink
23
24 # real QA test starts here
25 # Below agsize is too small for a large fs, and it's not necessary to test on
26 # large fs
27 _require_no_large_scratch_dev
28 _require_scratch_reflink
29 _require_cp_reflink
30
31 _scratch_mkfs >/dev/null 2>&1
32 _scratch_mount
33 blksz=$(_get_file_block_size $SCRATCH_MNT)
34 _scratch_unmount
35
36 agsize=$((8192 * $blksz))
37 if [[ $agsize -lt $((16 * 1024 * 1024)) ]]; then
38         agsize=$((16 * 1024 * 1024))
39 fi
40 sz=$((4096 * $blksz + $agsize))
41 nr=$(($sz / $blksz))
42
43 echo "Format and mount"
44 _scratch_mkfs -d agsize=$agsize > $seqres.full 2>&1
45 _scratch_mount >> $seqres.full 2>&1
46
47 testdir=$SCRATCH_MNT/test-$seq
48 mkdir $testdir
49
50 echo "Create the original files"
51 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
52 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
53 _pwrite_byte 0x61 0 $sz $testdir/file2.chk >> $seqres.full
54 _scratch_cycle_mount
55
56 echo "Compare files"
57 cmp -s $testdir/file1 $testdir/file2 || echo "file1 and file2 do not match"
58 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
59
60 echo "CoW every other block"
61 seq 1 2 $((nr - 1)) | while read f; do
62         _pwrite_byte 0x62 $((f * blksz)) $blksz $testdir/file2 >> $seqres.full
63         _pwrite_byte 0x62 $((f * blksz)) $blksz $testdir/file2.chk >> $seqres.full
64 done
65 _scratch_cycle_mount
66
67 echo "Compare files"
68 ! cmp -s $testdir/file1 $testdir/file2 || echo "file1 and file2 must not match"
69 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
70
71 # success, all done
72 status=0
73 exit