fstests: check for filesystem FS_IOC_FSSETXATTR support
[xfstests-dev.git] / tests / xfs / 008
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 008
6 #
7 # randholes test
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=0        # success is the default!
16 pgsize=`$here/src/feature -s`
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21     rm -f $tmp.*
22     rm -rf $TEST_DIR/randholes.$$.*
23 }
24
25 _filter()
26 {
27     sed -e "s/-b $pgsize/-b PGSIZE/g" \
28         -e "s/-l .* -c/-l FSIZE -c/g"
29 }
30
31 # get standard environment, filters and checks
32 . ./common/rc
33 . ./common/filter
34
35 _do_test()
36 {
37     _n="$1"
38     _holes="$2"
39     _param="$3"
40
41     out=$TEST_DIR/randholes.$$.$_n
42     echo ""
43     echo "randholes.$_n : $_param" | _filter
44     echo "------------------------------------------"
45     if $here/src/randholes $_param $out >$tmp.out
46     then
47         # only check if we're not allocating in huge chunks (extsz flag)
48         if _test_inode_flag extsize $out || _test_inode_flag realtime $out
49         then
50                 echo "holes is in range"
51         else
52                 # quick check - how many holes did we get?
53                 count=`xfs_bmap $out | egrep -c ': hole'`
54                 # blocks can end up adjacent, therefore number of holes varies
55                 _within_tolerance "holes" $count $_holes 10% -v
56         fi
57     else
58         echo "    randholes returned $? - see $seq.out.full"
59         echo "--------------------------------------"       >>$seqres.full
60         echo "$_n - output from randholes:"                 >>$seqres.full
61         echo "--------------------------------------"       >>$seqres.full
62         cat $tmp.out                                        >>$seqres.full
63         echo "--------------------------------------"       >>$seqres.full
64         echo "$_n - output from bmap:"                      >>$seqres.full
65         echo "--------------------------------------"       >>$seqres.full
66         xfs_bmap -vvv $out                                  >>$seqres.full
67         status=1
68     fi
69 }
70
71 # real QA test starts here
72 _supported_fs xfs
73 _supported_os Linux
74 _require_test
75
76 rm -f $seqres.full
77
78 # Note on special numbers here.
79 #
80 # We are trying to create roughly 50 or 100 holes in a file
81 # using random writes. Assuming a good distribution of 50 writes
82 # in a file, the file only needs to be 3-4x the size of the write
83 # size muliplied by the number of writes. Hence we use 200 * pgsize
84 # for files we want 50 holes in and 400 * pgsize for files we want
85 # 100 holes in. This keeps the runtime down as low as possible.
86 #
87 _do_test 1 50 "-l `expr 200 \* $pgsize` -c 50 -b $pgsize"
88 _do_test 2 100 "-l `expr 400 \* $pgsize` -c 100 -b $pgsize"
89 _do_test 3 100 "-l `expr 400 \* $pgsize` -c 100 -b 512"   # test partial pages
90
91 # rinse, lather, repeat for direct IO
92 _do_test 4 50 "-d -l `expr 200 \* $pgsize` -c 50 -b $pgsize"
93 _do_test 5 100 "-d -l `expr 400 \* $pgsize` -c 100 -b $pgsize"
94 # note: direct IO requires page aligned IO
95
96 # todo: realtime.
97
98 # success, all done
99 exit