fstests: move test group info to test files
[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 . ./common/preamble
11 _begin_fstest acl quick auto
12
13 # Import common functions.
14 . ./common/filter
15 . ./common/attr
16
17 # Override the default cleanup function.
18 _cleanup()
19 {
20     cd /
21     rm -f $tmp.*
22     [ -n "$TEST_DIR" ] && rm -rf $TEST_DIR/$seq.dir1
23 }
24
25 # real QA test starts here
26 _supported_fs generic
27 _require_test
28 _acl_setup_ids
29 _require_acls
30 _require_acl_get_max
31
32 # get dir
33 cd $TEST_DIR
34 rm -rf $seq.dir1
35 mkdir $seq.dir1
36 cd $seq.dir1
37
38 # we return E2BIG if hit the max acl limits on new kernel, but EINVAL
39 # on old kernel. So we need to filter out the error message in order
40 # to make the updated golden output works for both old and new kernels.
41 _filter_largeacl()
42 {
43         sed -e "s/Invalid argument/Argument list too long/"
44 }
45
46 # filter all the non-ace stuff from the acl output so the count is
47 # correct. Note that this assumes that _create_n_aces always creates rwx acls.
48 _filter_acls()
49 {
50         _filter_aces | grep ':rwx'
51 }
52
53 # store the output in seqres.full, then run again an count and filter the
54 # output.
55 check_acls()
56 {
57         _acl=$1
58         _count=$2
59
60         chacl $_acl largeaclfile 2>&1 | _filter_largeacl
61         getfacl --numeric largeaclfile | _filter_aces \
62                 >> $seqres.full 2> /dev/null
63         nacls=`getfacl --numeric largeaclfile | _filter_acls | wc -l`
64         if [ $nacls -ne $_count ]; then
65                 echo Wrong ACL count - $nacls != $_count
66         fi
67 }
68
69 echo ""
70 echo "=== Test out large ACLs  ==="
71 touch largeaclfile
72
73 ACL_MAX_ENTRIES=$(_acl_get_max)
74 num_aces_pre=$((ACL_MAX_ENTRIES - 1))
75 num_aces_post=$((ACL_MAX_ENTRIES + 1))
76
77 acl1=`_create_n_aces $num_aces_pre`
78 acl2=`_create_n_aces $ACL_MAX_ENTRIES`
79 acl3=`_create_n_aces $num_aces_post`
80 acl4=`_create_n_aces 16` # Andreas G. libacl size for initial get
81 acl5=`_create_n_aces 17` # 1 over A.G. libacl initial size
82
83 echo "1 below acl max"
84 check_acls $acl1 $num_aces_pre
85
86 echo "acl max"
87 check_acls $acl2 $ACL_MAX_ENTRIES
88
89 # we expect the ACL change to fail, so the old ACLs should remain on the
90 # file. Hence the expected ACL count is XFS_ACL_MAX_ENTRIES, not num_aces_post.
91 echo "1 above acl max"
92 check_acls $acl3 $ACL_MAX_ENTRIES
93
94 echo "use 16 aces"
95 check_acls $acl4 16
96
97 echo "use 17 aces"
98 check_acls $acl5 17
99
100 # success, all done
101 status=0
102 exit