fstests: use _require_symlinks on all necessary tests
[xfstests-dev.git] / tests / generic / 377
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 377
6 #
7 # Test listxattr syscall behaviour with different buffer sizes.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12 tmp=/tmp/$$
13 status=1        # failure is the default!
14 trap "_cleanup; exit \$status" 0 1 2 3 15
15
16 _cleanup()
17 {
18         cd /
19         rm -f $tmp.*
20 }
21
22 # get standard environment, filters and checks
23 . ./common/rc
24 . ./common/filter
25 . ./common/attr
26
27 # real QA test starts here
28 _supported_fs generic
29 _supported_os Linux
30 _require_scratch
31 _require_attrs
32 _require_test_program "listxattr"
33
34 listxattr="$here/src/listxattr"
35
36 rm -f $seqres.full
37
38 _scratch_mkfs >>$seqres.full 2>&1
39 _scratch_mount
40
41 # Create a testfile with three xattrs such that the sum of namelengths of the
42 # first two is bigger than the namelength of the third. This is needed for
43 # the 5th testcase that tests one of the cornercases.
44 testfile=${SCRATCH_MNT}/testfile
45 touch $testfile
46 $SETFATTR_PROG -n user.foo -v bar $testfile
47 $SETFATTR_PROG -n user.ping -v pong $testfile
48 $SETFATTR_PROG -n user.hello -v there $testfile
49
50 # 1. Call listxattr without buffer length argument. This should succeed.
51 $listxattr $testfile | sort
52
53 # 2. Calling listxattr on nonexistant file should fail with -ENOENT.
54 $listxattr ""
55
56 # 3. Calling listxattr with buffersize not suffecient for even one xattr
57 # should fail with -ERANGE.
58 $listxattr $testfile 1
59
60 # 4. Calling listxattr with buffersize suffecient for one xattr, but not
61 # sufficient for the whole list should still fail with -ERANGE.
62 $listxattr $testfile 9
63
64 # 5. Calling listxattr with buffersize suffecient for the last xattr, but not
65 # sufficient for the sum of first two. Should fail with -ERANGE.
66 $listxattr $testfile 11
67
68 # 6. Calling listxattr with buffersize bigger than needed should succeed.
69 $listxattr $testfile 500 | sort
70
71 status=0
72 exit