xfstests: move xfs specific tests out of top directory
[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 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
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 $tmp.*
42 }
43
44 _filter_version()
45 {
46         tee -a $seq.full | tr ',' '\n' | egrep 'ATTR|MORE|LAZY'
47 }
48
49 # get standard environment, filters and checks
50 . ./common.rc
51 . ./common.filter
52 . ./common.attr
53
54 # real QA test starts here
55 _supported_fs xfs
56 _supported_os Linux
57
58 _require_scratch
59 _require_attrs
60
61 rm -f $seq.full
62
63 # lazysb and attr2 are in features2 and will require morebitsbit on
64 # So test with lazysb and without it to see if the morebitsbit is
65 # okay etc....
66 # Reset the options so that we can control what is going on here
67 export MKFS_OPTIONS=""
68 export MOUNT_OPTIONS=""
69
70 # Make sure that when we think we are testing with morebits off
71 # that we really are.
72 # Trying to future-proof in case mkfs defaults change.
73 _scratch_mkfs -i attr=1 -l lazy-count=0 >/dev/null 2>&1
74 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 >$tmp.db
75 if grep -i morebits $tmp.db
76 then
77         echo ""
78         echo "Need to update test $seq so that initial subtests do not use features2"
79         echo ""
80         exit
81 fi
82
83 echo ""
84 echo "*** 1. test attr2 mkfs and then noattr2 mount ***"
85 echo ""
86 echo "attr2 fs"
87 echo ""
88 _scratch_mkfs -i attr=2 -l lazy-count=0 >/dev/null 2>&1
89 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
90 echo ""
91 echo "noattr2 fs"
92 echo ""
93 _scratch_mount -o noattr2
94 $UMOUNT_PROG $SCRATCH_MNT
95 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
96
97 # adding an EA will ensure the ATTR1 flag is turned on
98 echo ""
99 echo "*** 2. test attr2 mkfs and then noattr2 mount with 1 EA ***"
100 echo ""
101 echo "attr2 fs"
102 echo ""
103 _scratch_mkfs -i attr=2 -l lazy-count=0 >/dev/null 2>&1
104 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
105 echo ""
106 echo "noattr2 fs"
107 echo ""
108 _scratch_mount -o noattr2
109 cd $SCRATCH_MNT
110 touch testfile
111 $SETFATTR_PROG -n user.test -v 0xbabe testfile
112 $GETFATTR_PROG testfile
113 cd $here
114 $UMOUNT_PROG $SCRATCH_MNT
115 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
116
117 echo ""
118 echo "*** 3. test noattr2 mount and lazy sb ***"
119 echo ""
120 echo ""
121 echo "attr2 fs"
122 echo ""
123 _scratch_mkfs -i attr=2 -l lazy-count=1 >/dev/null 2>&1
124 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
125 echo ""
126 echo "noattr2 fs"
127 echo ""
128 _scratch_mount -o noattr2
129 cd $SCRATCH_MNT
130 touch testfile
131 cd $here
132 $UMOUNT_PROG $SCRATCH_MNT
133 $XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 | _filter_version
134
135 # success, all done
136 status=0
137 exit