fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 425
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 425
6 #
7 # Check that FIEMAP produces some output when we require an external
8 # block to hold extended attributes.
9 #
10 . ./common/preamble
11 _begin_fstest auto quick attr
12
13 _register_cleanup "_cleanup" BUS
14
15 # Override the default cleanup function.
16 _cleanup()
17 {
18         cd /
19         rm -rf $tmp.*
20         wait
21 }
22
23 # Import common functions.
24 . ./common/filter
25 . ./common/attr
26
27 # real QA test starts here
28 _supported_fs generic
29
30 [ $FSTYP = bcachefs ] && _notrun "bcachefs does not store xattrs in blocks"
31
32 _require_scratch
33 _require_attrs
34 _require_xfs_io_command "fiemap" "-a"
35
36 echo "Format and mount"
37 _scratch_mkfs > $seqres.full 2>&1
38 _scratch_mount >> $seqres.full 2>&1
39
40 testdir=$SCRATCH_MNT/test-$seq
41 mkdir $testdir
42
43 echo "Create the original files"
44 testfile=$testdir/attrfile
45 touch $testfile
46 blk_sz=$(_get_file_block_size $SCRATCH_MNT)
47
48 # Assume each attr eats at least 20 bytes.  Try to fill 2 fs blocks.
49 max_attrs=$((2 * blk_sz / 20))
50
51 i=0
52 while [ $i -lt $max_attrs ]; do
53         n="$(printf "%010d" $i)"
54         $SETFATTR_PROG -n "user.$n" -v "$n" $testfile > $seqres.full 2>&1 || break
55         i=$((i + 1))
56 done
57 sync
58
59 echo "Check attr extent counts"
60 f1=$(_count_attr_extents $testfile)
61 echo "$f1 xattr extents" >> $seqres.full
62 $XFS_IO_PROG -c 'fiemap -a -v' $testfile >> $seqres.full
63 test $f1 -gt 0 || echo "Expected at least one xattr extent."
64
65 _scratch_cycle_mount
66
67 echo "Check attr extent counts after remount"
68 f1=$(_count_attr_extents $testfile)
69 echo "$f1 xattr extents" >> $seqres.full
70 $XFS_IO_PROG -c 'fiemap -a -v' $testfile >> $seqres.full
71 test $f1 -gt 0 || echo "Expected at least one xattr extent."
72
73 # success, all done
74 status=0
75 exit