generic: copy_file_range swapfile test
[xfstests-dev.git] / tests / generic / 420
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Calvin Owens.  All Rights Reserved.
4 #
5 # FS QA Test 420
6 #
7 # Verify fallocate(mode=FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE) does
8 # not alter the file size.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 # real QA test starts here
33
34 # Modify as appropriate.
35 _supported_fs generic
36 _supported_os Linux
37 _require_test
38 _require_xfs_io_command fpunch
39
40 testfile="${TEST_DIR}/testfile.$seq"
41
42 echo "Testing fallocate(mode=FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE)"
43 $XFS_IO_PROG -f -t -c "pwrite -b 2048 0 2048" $testfile | head -n1
44 # fpunch from xfs_io has KEEP_SIZE flag set
45 $XFS_IO_PROG -c "fpunch 2048 2048" $testfile
46 $XFS_IO_PROG -c "stat" $testfile | grep -F 'stat.size'
47
48 # success, all done
49 status=0
50 exit