fstests: move test group info to test files
[xfstests-dev.git] / tests / ext4 / 026
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Google, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 026
6 #
7 # Test for ea_inode feature in ext4. Without ea_inode feature, an extended
8 # attribute in ext4 cannot be larger than the fs block size. ea_inode feature
9 # allows storing xattr values in external inodes and so raises xattr value
10 # size limit to 64k.
11 #
12 . ./common/preamble
13 _begin_fstest auto quick attr
14
15 # Import common functions.
16 . ./common/filter
17 . ./common/attr
18
19 # real QA test starts here
20 _supported_fs ext4
21 _require_scratch
22 _require_attrs
23 _require_scratch_ext4_feature "ea_inode"
24
25 _scratch_mkfs_ext4 -O ea_inode >/dev/null 2>&1
26 _scratch_mount
27
28 # Sets an extended attribute on a file.
29 attr_set()
30 {
31         local file=$1 name=$2 value=$3 tmp
32
33         if [[ "$value" != "" ]]; then
34                 $SETFATTR_PROG -n $name -v "$value" $file
35         else
36                 $SETFATTR_PROG -n $name $file
37         fi
38
39         tmp=$(_getfattr --absolute-names --only-values -n $name $file)
40         [[ "$tmp" == "$value" ]] || echo "unexpected value returned: $tmp"
41 }
42
43 # List attributes on a file.
44 attr_list()
45 {
46         _getfattr --absolute-names $1 | grep -v '^#'
47 }
48
49 # Removes an extended attribute from a file.
50 attr_remove()
51 {
52         local file=$1 name=$2
53
54         $SETFATTR_PROG -x $name $file
55 }
56
57 # Test files.
58 x=$SCRATCH_MNT/x
59 y=$SCRATCH_MNT/y
60 z=$SCRATCH_MNT/z
61
62 # Attribute with short name that goes into inode body.
63 name_in_ibody=user.i
64
65 # Attribute with long name that goes into xattr block.
66 name_in_block=user.$(perl -e 'print "b" x 100;')
67
68 # Set large xattr values on multiple files.
69 touch $x $y $z
70 for file in $x $y $z; do
71         for name in $name_in_ibody $name_in_block; do
72                 for size in 4096 8000 $((64*1024)); do
73                         attr_set $file $name-$size \
74                                 $(perl -e "print 'v' x $size;")
75                 done
76         done
77         attr_list $file
78 done
79 rm $x $y $z
80
81 # Set/remove.
82 touch $x
83 attr_set $x $name_in_ibody $(perl -e "print 'i' x 25000;")
84 attr_set $x $name_in_block $(perl -e "print 'b' x 25000;")
85 attr_list $x
86 attr_remove $x $name_in_ibody
87 attr_remove $x $name_in_block
88 rm $x
89
90 # Set with same value twice.
91 touch $x
92 attr_set $x $name_in_ibody $(perl -e "print 'i' x 60000;")
93 attr_set $x $name_in_ibody $(perl -e "print 'i' x 60000;")
94 attr_list $x
95 rm $x
96
97 # Repeatedly set an extended attribute with various value sizes.
98 touch $x
99 for size in 0 10 80 900 1900 3000 9000 60 10000 0 8000 3000 10 0 20 10000 5; do
100         attr_set $x user.1 $(perl -e "print 'v' x $size;")
101 done
102 attr_list $x
103 rm $x
104
105 # success, all done
106 status=0
107 exit