generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 026
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 # Copyright (c) 2014 Red hat, Inc.  All Rights Reserved.
5 #
6 # FS QA Test No. generic/026
7 #
8 # Test out ACL count limits
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 # get standard environment, filters and checks
20 . ./common/rc
21 . ./common/filter
22 . ./common/attr
23
24 _cleanup()
25 {
26     cd /
27     rm -f $tmp.*
28     [ -n "$TEST_DIR" ] && rm -rf $TEST_DIR/$seq.dir1
29 }
30
31 # real QA test starts here
32 _supported_fs generic
33 _supported_os Linux
34 _require_test
35 _acl_setup_ids
36 _require_acls
37 _require_acl_get_max
38
39 rm -f $seqres.full
40
41 # get dir
42 cd $TEST_DIR
43 rm -rf $seq.dir1
44 mkdir $seq.dir1
45 cd $seq.dir1
46
47 # we return E2BIG if hit the max acl limits on new kernel, but EINVAL
48 # on old kernel. So we need to filter out the error message in order
49 # to make the updated golden output works for both old and new kernels.
50 _filter_largeacl()
51 {
52         sed -e "s/Invalid argument/Argument list too long/"
53 }
54
55 # filter all the non-ace stuff from the acl output so the count is
56 # correct. Note that this assumes that _create_n_aces always creates rwx acls.
57 _filter_acls()
58 {
59         _filter_aces | grep ':rwx'
60 }
61
62 # store the output in seqres.full, then run again an count and filter the
63 # output.
64 check_acls()
65 {
66         _acl=$1
67         _count=$2
68
69         chacl $_acl largeaclfile 2>&1 | _filter_largeacl
70         getfacl --numeric largeaclfile | _filter_aces \
71                 >> $seqres.full 2> /dev/null
72         nacls=`getfacl --numeric largeaclfile | _filter_acls | wc -l`
73         if [ $nacls -ne $_count ]; then
74                 echo Wrong ACL count - $nacls != $_count
75         fi
76 }
77
78
79 echo ""
80 echo "=== Test out large ACLs  ==="
81 touch largeaclfile
82
83 ACL_MAX_ENTRIES=$(_acl_get_max)
84 num_aces_pre=$((ACL_MAX_ENTRIES - 1))
85 num_aces_post=$((ACL_MAX_ENTRIES + 1))
86
87 acl1=`_create_n_aces $num_aces_pre`
88 acl2=`_create_n_aces $ACL_MAX_ENTRIES`
89 acl3=`_create_n_aces $num_aces_post`
90 acl4=`_create_n_aces 16` # Andreas G. libacl size for initial get
91 acl5=`_create_n_aces 17` # 1 over A.G. libacl initial size
92
93 echo "1 below acl max"
94 check_acls $acl1 $num_aces_pre
95
96 echo "acl max"
97 check_acls $acl2 $ACL_MAX_ENTRIES
98
99 # we expect the ACL change to fail, so the old ACLs should remain on the
100 # file. Hence the expected ACL count is XFS_ACL_MAX_ENTRIES, not num_aces_post.
101 echo "1 above acl max"
102 check_acls $acl3 $ACL_MAX_ENTRIES
103
104 echo "use 16 aces"
105 check_acls $acl4 16
106
107 echo "use 17 aces"
108 check_acls $acl5 17
109
110 # success, all done
111 status=0
112 exit