common: Check the file system consistency on SCRATCH_DEV
[xfstests-dev.git] / tests / generic / 097
1 #! /bin/bash
2 # FS QA Test No. 097. Modifed from UDFQA test 033.
3 #
4 # simple attr tests for EAs:
5 #  - set
6 #  - get
7 #  - list
8 #  - remove
9 # Basic testing.
10 #
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2000-2004 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 seqfull=$0
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38 TARGET_DIR=
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 _cleanup()
42 {
43     rm -f $tmp.*
44     cd $TARGET_DIR
45     rm -f foo
46 }
47
48 _umount_and_mount()
49 {
50     cd /
51     umount $TARGET_DIR
52     if [ "$FSTYP" == "xfs" ]; then
53         _test_mount
54     else
55         _scratch_mount
56     fi
57     
58     cd $TARGET_DIR
59 }
60
61 # get standard environment, filters and checks
62 . ./common/rc
63 . ./common/filter
64
65 # link correct .out file
66 # This is done bacause udf and xfs print attrs in different orders.
67 rm -rf $seqfull.out
68 if [ "$FSTYP" == "xfs" ]; then
69     ln -s $seq.out.xfs $seqfull.out
70 else
71     ln -s $seq.out.udf $seqfull.out
72 fi
73
74 # real QA test starts here
75 _supported_fs generic
76 _supported_os IRIX
77
78 _require_scratch
79 _require_attrs
80
81 TARGET_DIR=$SCRATCH_MNT
82 [ "$FSTYP" == "xfs" ] && TARGET_DIR=$TEST_DIR
83 cd $TARGET_DIR
84
85 echo "create file foo"
86 rm -f foo 
87 touch foo
88
89 echo "should be no EAs for foo:"
90 ${ATTR_PROG} -l foo
91
92 echo "set EA <noise,woof>:"
93 ${ATTR_PROG} -s noise -V woof foo
94
95 echo "set EA <colour,blue>:"
96 ${ATTR_PROG} -s colour -V blue foo
97
98 echo "set EA <size,small>:"
99 ${ATTR_PROG} -s size -V small foo
100
101 echo "list the EAs for foo: noise, colour, size" 
102 ${ATTR_PROG} -l foo
103
104 echo "check the list again for foo"
105 ${ATTR_PROG} -l foo
106
107 echo "unmount the FS and see if EAs are persistent"
108 _umount_and_mount
109
110 echo "check the list again for foo after umount/mount"
111 ${ATTR_PROG} -l foo
112
113 echo "get the value of the noise EA"
114 ${ATTR_PROG} -g noise foo
115
116 echo "get the value of the colour EA which was removed earlier"
117 ${ATTR_PROG} -g colour foo
118
119 echo "get the value of the size EA"
120 ${ATTR_PROG} -g size foo
121
122 echo "remove the colour EA on foo"
123 ${ATTR_PROG} -r colour foo
124
125 echo "list EAs for foo: noise, size"
126 ${ATTR_PROG} -l foo
127
128 echo "get the value of the noise EA"
129 ${ATTR_PROG} -g noise foo
130
131 echo "get the value of the colour EA which was removed earlier"
132 ${ATTR_PROG} -g colour foo
133
134 echo "get the value of the size EA"
135 ${ATTR_PROG} -g size foo
136
137 echo "list all the EAs again: noise, size"
138 ${ATTR_PROG} -l foo
139
140 echo "change the value of the size EA from small to huge"
141 ${ATTR_PROG} -s size -V huge foo
142
143 echo "get the size EA which should now have value huge"
144 ${ATTR_PROG} -g size foo
145
146 echo "list EAs: noise, size"
147 ${ATTR_PROG} -l foo
148
149 echo "remove the size EA from foo"
150 ${ATTR_PROG} -r size foo
151
152 echo "list EAs: noise (size EA has been removed)"
153 ${ATTR_PROG} -l foo
154
155 echo "get the noise EA: woof"
156 ${ATTR_PROG} -g noise foo
157
158 echo "try removing non-existent EA named woof"
159 ${ATTR_PROG} -r woof foo
160
161 echo "try removing already removed EA size"
162 ${ATTR_PROG} -r size foo
163
164 echo "list EAs: noise"
165 ${ATTR_PROG} -l foo
166
167 echo "try removing already removed EA colour"
168 ${ATTR_PROG} -r colour foo
169
170 echo "list EAs: noise"
171 ${ATTR_PROG} -l foo
172
173 echo "remove remaining EA noise"
174 ${ATTR_PROG} -r noise foo
175
176 echo "list EAs: should be no EAs left now"
177 ${ATTR_PROG} -l foo
178
179 echo "unmount the FS and see if EAs are persistent"
180 _umount_and_mount
181
182 echo "list EAs: should still be no EAs left"
183 ${ATTR_PROG} -l foo
184
185 echo ""
186 echo "*** Test out the root namespace ***"
187 echo ""
188
189 echo "set EA <root:colour,marone>:"
190 ${ATTR_PROG} -R -s colour -V marone foo
191
192 echo "set EA <user:colour,beige>:"
193 ${ATTR_PROG} -s colour -V beige foo
194
195 echo "set EA <user:vomit,pizza>:"
196 ${ATTR_PROG} -s vomit -V pizza foo
197
198 echo "set EA <root:noise,whack>:"
199 ${ATTR_PROG} -R -s noise -V whack foo
200
201 echo "list root EAs: <root:colour,noise>:"
202 ${ATTR_PROG} -R -l foo
203
204 echo "list user EAs: <user:colour,vomit>:"
205 ${ATTR_PROG} -l foo
206
207 echo "get root EA colour: marone"
208 ${ATTR_PROG} -R -g colour foo
209
210 echo "get root EA noise: whack"
211 ${ATTR_PROG} -R -g noise foo
212
213 echo "get root EA vomit which is a user EA => find nothing"
214 ${ATTR_PROG} -R -g vomit foo
215
216 echo ""
217 echo "unmount the FS and see if EAs are persistent"
218 echo ""
219 _umount_and_mount
220
221 echo "get root EA colour: marone"
222 ${ATTR_PROG} -R -g colour foo
223
224 echo "get root EA noise: whack"
225 ${ATTR_PROG} -R -g noise foo
226
227 echo "get user EA vomit: pizza" 
228 ${ATTR_PROG} -g vomit foo
229
230 echo "remove the root colour EA"
231 ${ATTR_PROG} -R -r colour foo
232
233 echo "list root EAs: <root:noise>:"
234 ${ATTR_PROG} -R -l foo
235
236 echo "list user EAs: <user:colour,vomit>:"
237 ${ATTR_PROG} -l foo
238
239 echo "remove the final root EA noise"
240 ${ATTR_PROG} -R -r noise foo
241
242 echo "list root EAs: none"
243 ${ATTR_PROG} -R -l foo
244
245 cd /
246
247 # success, all done
248 status=0
249 exit