xfstests: make install support common/ and tests/ dirs
[xfstests-dev.git] / tests / xfs / 187
1 #! /bin/bash
2 # FS QA Test No. 187
3 #
4 # To test out the noattr2 flag which is broken in pv#980021
5 # Given an existing attr2 filesystem, we should be able to mount
6 # as noattr2 and go back to an attr1 filesystem.
7 #
8 # Test the case where there are no more features2 bits on and
9 # so the morebitsbit should be off.
10 #
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
17 #
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26 #
27 #-----------------------------------------------------------------------
28 #
29
30 seq=`basename $0`
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
33
34 here=`pwd`
35 tmp=/tmp/$$
36 status=1        # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 _cleanup()
40 {
41     cd /
42     rm -f $tmp.*
43 }
44
45 _filter_version()
46 {
47         tee -a $seqres.full | tr ',' '\n' | egrep 'ATTR|MORE|LAZY'
48 }
49
50 # get standard environment, filters and checks
51 . ./common/rc
52 . ./common/filter
53 . ./common/attr
54
55 # real QA test starts here
56 _supported_fs xfs
57 _supported_os Linux
58
59 _require_scratch
60 _require_attrs
61
62 rm -f $seqres.full
63
64 # lazysb and attr2 are in features2 and will require morebitsbit on
65 # So test with lazysb and without it to see if the morebitsbit is
66 # okay etc....
67 # Reset the options so that we can control what is going on here
68 export MKFS_OPTIONS=""
69 export MOUNT_OPTIONS=""
70
71 # Make sure that when we think we are testing with morebits off
72 # that we really are.
73 # Trying to future-proof in case mkfs defaults change.
74 _scratch_mkfs -i attr=1 -l lazy-count=0 >/dev/null 2>&1
75 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 >$tmp.db
76 if grep -i morebits $tmp.db
77 then
78         echo ""
79         echo "Need to update test $seq so that initial subtests do not use features2"
80         echo ""
81         exit
82 fi
83
84 echo ""
85 echo "*** 1. test attr2 mkfs and then noattr2 mount ***"
86 echo ""
87 echo "attr2 fs"
88 echo ""
89 _scratch_mkfs -i attr=2 -l lazy-count=0 >/dev/null 2>&1
90 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
91 echo ""
92 echo "noattr2 fs"
93 echo ""
94 _scratch_mount -o noattr2
95 $UMOUNT_PROG $SCRATCH_MNT
96 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
97
98 # adding an EA will ensure the ATTR1 flag is turned on
99 echo ""
100 echo "*** 2. test attr2 mkfs and then noattr2 mount with 1 EA ***"
101 echo ""
102 echo "attr2 fs"
103 echo ""
104 _scratch_mkfs -i attr=2 -l lazy-count=0 >/dev/null 2>&1
105 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
106 echo ""
107 echo "noattr2 fs"
108 echo ""
109 _scratch_mount -o noattr2
110 cd $SCRATCH_MNT
111 touch testfile
112 $SETFATTR_PROG -n user.test -v 0xbabe testfile
113 $GETFATTR_PROG testfile
114 cd $here
115 $UMOUNT_PROG $SCRATCH_MNT
116 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
117
118 echo ""
119 echo "*** 3. test noattr2 mount and lazy sb ***"
120 echo ""
121 echo ""
122 echo "attr2 fs"
123 echo ""
124 _scratch_mkfs -i attr=2 -l lazy-count=1 >/dev/null 2>&1
125 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
126 echo ""
127 echo "noattr2 fs"
128 echo ""
129 _scratch_mount -o noattr2
130 cd $SCRATCH_MNT
131 touch testfile
132 cd $here
133 $UMOUNT_PROG $SCRATCH_MNT
134 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
135
136 # success, all done
137 status=0
138 exit