4 # Test listxattr syscall behaviour with different buffer sizes.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2016 Red Hat, Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation, either version 2 of
12 # the License, or (at your option) any later version.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #-----------------------------------------------------------------------
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
29 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
42 # real QA test starts here
47 _require_test_program "listxattr"
49 listxattr="$here/src/listxattr"
53 _scratch_mkfs >>$seqres.full 2>&1
56 # Create a testfile with three xattrs such that the sum of namelengths of the
57 # first two is bigger than the namelength of the third. This is needed for
58 # the 5th testcase that tests one of the cornercases.
59 testfile=${SCRATCH_MNT}/testfile
61 $SETFATTR_PROG -n user.foo -v bar $testfile
62 $SETFATTR_PROG -n user.ping -v pong $testfile
63 $SETFATTR_PROG -n user.hello -v there $testfile
65 # 1. Call listxattr without buffer length argument. This should succeed.
66 $listxattr $testfile | sort
68 # 2. Calling listxattr on nonexistant file should fail with -ENOENT.
71 # 3. Calling listxattr with buffersize not suffecient for even one xattr
72 # should fail with -ERANGE.
73 $listxattr $testfile 1
75 # 4. Calling listxattr with buffersize suffecient for one xattr, but not
76 # sufficient for the whole list should still fail with -ERANGE.
77 $listxattr $testfile 9
79 # 5. Calling listxattr with buffersize suffecient for the last xattr, but not
80 # sufficient for the sum of first two. Should fail with -ERANGE.
81 $listxattr $testfile 11
83 # 6. Calling listxattr with buffersize bigger than needed should succeed.
84 $listxattr $testfile 500 | sort