common: kill _supported_os
[xfstests-dev.git] / tests / generic / 150
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. 150
6 #
7 # Ensure that reflinking a file N times doesn't eat a lot of blocks
8 #   - Create a file and record fs block usage
9 #   - Create some reflink copies
10 #   - Compare fs block usage to before
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1    # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23     cd /
24     rm -rf $tmp.* $testdir
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30 . ./common/reflink
31
32 # real QA test starts here
33 _require_test_reflink
34 _require_cp_reflink
35
36 rm -f $seqres.full
37
38 testdir=$TEST_DIR/test-$seq
39 rm -rf $testdir
40 mkdir $testdir
41
42 echo "Create the original file blocks"
43 blksz="$(_get_block_size $testdir)"
44 blks=2000
45 margin='15%'
46 sz=$((blksz * blks))
47 nr=7
48 filesize=$((blksz * nr))
49 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
50 sync
51 free_blocks0=$(stat -f $testdir -c '%f')
52
53 echo "Create the reflink copies"
54 for i in `seq 2 $nr`; do
55         _cp_reflink $testdir/file1 $testdir/file.$i
56 done
57 _test_cycle_mount
58 free_blocks1=$(stat -f $testdir -c '%f')
59
60 _within_tolerance "free blocks after reflink" $free_blocks1 $free_blocks0 $margin -v
61
62 # success, all done
63 status=0
64 exit