fstests: use _require_symlinks on all necessary tests
[xfstests-dev.git] / tests / generic / 473
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 473
6 #
7 # Test for the new ranged query functionality in xfs_io's fiemap command.
8 # This tests various combinations of hole + data layout being printed.
9 # Also the test used 16k holes to be compatible with 16k block filesystems
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/punch
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # real QA test starts here
34
35 # Modify as appropriate.
36 _supported_os Linux
37 _require_test
38 _require_xfs_io_command "truncate"
39 # ranged is a special argument which checks if fiemap supports
40 # [offset [len]] args
41 _require_xfs_io_command "fiemap" "ranged"
42
43 file=$TEST_DIR/fiemap.$seq
44 rm -f $file
45
46 # Create a file with 64k hole followed by 64k data, and this pattern
47 # repeats till it reaches 4M file size, so each extent has 64k data.
48 # But truncate file to its final size first, otherwise XFS would merge
49 # some extents due to speculative preallocation.
50 $XFS_IO_PROG -f -c "truncate 4m" $file
51 for i in {0..31}; do
52         $XFS_IO_PROG -c "pwrite $(($i*128+64))k 64k" $file >/dev/null;
53 done
54
55 # Query 1 data extent between 64k..64k range
56 echo "Basic data extent"
57 $XFS_IO_PROG -c "fiemap -v 64k 64k" $file | _filter_fiemap
58
59 # Query data and hole extent
60 echo "Data + Hole"
61 $XFS_IO_PROG -c "fiemap -v 64k 80k" $file | _filter_fiemap
62
63 echo "Hole + Data"
64 $XFS_IO_PROG -c "fiemap -v 0 65k" $file | _filter_fiemap
65
66 echo "Hole + Data + Hole"
67 $XFS_IO_PROG -c "fiemap -v 0k 130k" $file | _filter_fiemap
68
69 echo "Data + Hole + Data"
70 $XFS_IO_PROG -c "fiemap -v 64k 192k" $file | _filter_fiemap
71
72 echo "Beginning with a hole"
73 $XFS_IO_PROG -c "fiemap -v 0 3k" $file | _filter_fiemap
74
75 # Query for 0..160k that's 40 extents, more than the EXTENT_BATCH
76 echo "Query more than 32 extents"
77 $XFS_IO_PROG -c "fiemap -v 0 3m" $file | _filter_fiemap
78
79 echo "Larger query than file size"
80 $XFS_IO_PROG -c "fiemap -v 0 5m" $file | _filter_fiemap
81
82 # mapping past eof shouldn't print anything"
83 $XFS_IO_PROG -c "fiemap -v 5m" $file | _filter_fiemap
84
85 echo "Skip first hole"
86 # check everything without the first hole
87 $XFS_IO_PROG -c "fiemap -v 64k" $file | _filter_fiemap
88
89 # success, all done
90 status=0
91 exit