generic: test XATTR_REPLACE doesn't take the fs down
[xfstests-dev.git] / tests / generic / 486
1 #! /bin/bash
2 # FS QA Test No. 486
3 #
4 # Ensure that we can XATTR_REPLACE a tiny attr into a large attr.
5 # Kanda Motohiro <kanda.motohiro@gmail.com> reports that XATTR_REPLACE'ing
6 # a single-byte attr with a 2048-byte attr causes a fs shutdown because we
7 # remove the shortform attr, convert the attr fork to long format, and then
8 # try to re-add the attr having not cleared ATTR_REPLACE.
9 #
10 # Commit 7b38460dc8e4 ("xfs: don't fail when converting shortform attr to long
11 # form during ATTR_REPLACE") fixed the xfs bug.
12 #
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2018 Oracle.  All Rights Reserved.
15 #
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
19 #
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28 #
29 #-----------------------------------------------------------------------
30
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 status=1        # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
37
38 _cleanup()
39 {
40         cd /
41         rm -f $testfile
42 }
43
44 # get standard environment, filters and checks
45 . ./common/rc
46 . ./common/filter
47 . ./common/attr
48
49 # remove previous $seqres.full before test
50 rm -f $seqres.full
51
52 # real QA test starts here
53 _supported_fs generic
54 _supported_os Linux
55 _require_test_program "attr_replace_test"
56 _require_attrs
57 _require_scratch
58
59 rm -f $seqres.full
60 _scratch_mkfs >>$seqres.full 2>&1
61 _scratch_mount >>$seqres.full 2>&1
62
63 filter_attr_output() {
64         _filter_scratch | sed -e 's/has a [0-9]* byte value/has a NNNN byte value/g'
65 }
66
67 ./src/attr_replace_test $SCRATCH_MNT/hello
68 $ATTR_PROG -l $SCRATCH_MNT/hello | filter_attr_output
69
70 status=0
71 exit