xfs: fix old fuzz test invocations of xfs_repair
[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 _require_scratch
30 _require_attrs
31 _require_test_program "listxattr"
32
33 listxattr="$here/src/listxattr"
34
35 rm -f $seqres.full
36
37 _scratch_mkfs >>$seqres.full 2>&1
38 _scratch_mount
39
40 # Create a testfile with three xattrs such that the sum of namelengths of the
41 # first two is bigger than the namelength of the third. This is needed for
42 # the 5th testcase that tests one of the cornercases.
43 testfile=${SCRATCH_MNT}/testfile
44 touch $testfile
45 $SETFATTR_PROG -n user.foo -v bar $testfile
46 $SETFATTR_PROG -n user.ping -v pong $testfile
47 $SETFATTR_PROG -n user.hello -v there $testfile
48
49 # 1. Call listxattr without buffer length argument. This should succeed.
50 $listxattr $testfile | grep '^xattr: user\.' | sort
51
52 # 2. Calling listxattr on nonexistant file should fail with -ENOENT.
53 $listxattr ""
54
55 # 3. Calling listxattr with buffersize not suffecient for even one xattr
56 # should fail with -ERANGE.
57 $listxattr $testfile 1
58
59 # 4. Calling listxattr with buffersize suffecient for one xattr, but not
60 # sufficient for the whole list should still fail with -ERANGE.
61 $listxattr $testfile 9
62
63 # 5. Calling listxattr with buffersize suffecient for the last xattr, but not
64 # sufficient for the sum of first two. Should fail with -ERANGE.
65 $listxattr $testfile 11
66
67 # 6. Calling listxattr with buffersize bigger than needed should succeed.
68 $listxattr $testfile 500 | grep '^xattr: user\.' | sort
69
70 status=0
71 exit