fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 387
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test 387
6 #
7 # Create a heavily reflinked file, then check whether we can truncate
8 # it correctly.
9 #
10 . ./common/preamble
11 _begin_fstest auto clone
12
13 # Import common functions.
14 . ./common/filter
15 . ./common/reflink
16
17 # Modify as appropriate.
18 _supported_fs generic
19 _require_scratch_reflink
20
21 #btrfs needs 256mb to create default blockgroup fs
22 _scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
23 _scratch_mount
24
25 testfile=$SCRATCH_MNT/testfile
26 dummyfile=$SCRATCH_MNT/dummyfile
27 blocksize=$((128 * 1024))
28
29 # create a dummy file, which is used to occupy some fs space first.
30 _pwrite_byte 0xcdcdcdcd 0 $((1 * 1024 * 1024)) $dummyfile > /dev/null
31 _pwrite_byte 0xcdcdcdcd 0 $blocksize  $testfile > /dev/null
32
33 echo "Silence is golden"
34 for ((i = 0; i < 16384; i++)); do
35         _reflink_range $testfile 0 $testfile $(($i * $blocksize)) \
36                 $blocksize > /dev/null 2>&1
37 done
38
39 # consume all remaining free space
40 dd if=/dev/zero of=$SCRATCH_MNT/space >/dev/null 2>&1
41 sync
42
43 # fs is full now and fs internal operations may need some free space, for
44 # example, in btrfs, transaction will need to reserve space first, so here free
45 # 1MB space.
46 rm -f $dummyfile
47 $XFS_IO_PROG -f -c "truncate 0" $testfile
48
49 status=0
50 exit