generic: test MADV_POPULATE_READ with IO errors
[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 . ./common/preamble
10 _begin_fstest attr auto quick metadata
11
12 # Import common functions.
13 . ./common/filter
14 . ./common/attr
15
16 # real QA test starts here
17 _supported_fs generic
18 _require_scratch
19 _require_attrs
20 _require_test_program "listxattr"
21
22 listxattr="$here/src/listxattr"
23
24 _scratch_mkfs >>$seqres.full 2>&1
25 _scratch_mount
26
27 # Create a testfile with three xattrs such that the sum of namelengths of the
28 # first two is bigger than the namelength of the third. This is needed for
29 # the 5th testcase that tests one of the cornercases.
30 testfile=${SCRATCH_MNT}/testfile
31 touch $testfile
32 $SETFATTR_PROG -n user.foo -v bar $testfile
33 $SETFATTR_PROG -n user.ping -v pong $testfile
34 $SETFATTR_PROG -n user.hello -v there $testfile
35
36 # 1. Call listxattr without buffer length argument. This should succeed.
37 $listxattr $testfile | grep '^xattr: user\.' | sort
38
39 # 2. Calling listxattr on nonexistant file should fail with -ENOENT.
40 $listxattr ""
41
42 # 3. Calling listxattr with buffersize not suffecient for even one xattr
43 # should fail with -ERANGE.
44 $listxattr $testfile 1
45
46 # 4. Calling listxattr with buffersize suffecient for one xattr, but not
47 # sufficient for the whole list should still fail with -ERANGE.
48 $listxattr $testfile 9
49
50 # 5. Calling listxattr with buffersize suffecient for the last xattr, but not
51 # sufficient for the sum of first two. Should fail with -ERANGE.
52 $listxattr $testfile 11
53
54 # 6. Calling listxattr with buffersize bigger than needed should succeed.
55 $listxattr $testfile 500 | grep '^xattr: user\.' | sort
56
57 status=0
58 exit