Add GPL license plate to SGI's test files.
[xfstests-dev.git] / 098
1 #! /bin/sh
2 #
3 #-----------------------------------------------------------------------
4 # Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation.
9 #
10 # This program is distributed in the hope that it would be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write the Free Software Foundation,
17 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 #
19 #-----------------------------------------------------------------------
20 #
21 # FS QA Test No. 098. Modified from UDFQA test 035
22 #
23 # simple attr tests for EAs:
24 #  - set
25 #  - get
26 #  - list
27 #  - remove
28 # Basic testing.
29 # + udf_db checks.
30 # (033 + udf_db)
31 #
32 # creator
33 owner=ajones@sgi.com
34
35 seq=`basename $0`
36 echo "QA output created by $seq"
37
38 here=`pwd`
39 tmp=/tmp/$$
40 status=1        # failure is the default!
41 trap "_cleanup; exit \$status" 0 1 2 3 15
42
43 _cleanup()
44 {
45     rm -f $tmp.*
46 }
47
48 # get standard environment, filters and checks
49 . ./common.rc
50 . ./common.filter
51
52 _db_filter()
53 {
54     awk '
55         /<file_entry name=/ { fe_on=1 }
56         /<timestamp/  { ts_on=1; next }
57         /<\/timestamp/ { ts_on=0; next }
58         /<cksum/      { next }
59         /<desc_crc/   { next }
60         /<pos/        { next }
61         /<tag_loc/    { next }
62         /<lb_num/     { next }
63         fe_on == 1 && ts_on == 0 { print; next }
64                       { next }
65     '
66 }
67
68 _umount_check_mount()
69 {
70     cd /
71     umount $SCRATCH_MNT
72
73     udf_db -f $SCRATCH_DEV | _db_filter
74
75     _scratch_mount
76     cd $SCRATCH_MNT
77 }
78
79 # real QA test starts here
80 _supported_fs udf
81 _supported_os IRIX
82
83 _require_scratch
84 _setup_testdir
85
86 cd $SCRATCH_MNT
87
88 echo "create file foo"
89 echo "file_contents" >foo
90 cat foo
91
92 echo "should be no EAs for foo:"
93 attr -l foo
94
95 echo "set EA <noise,woof>:"
96 attr -s noise -V woof foo
97
98 echo "set EA <colour,blue>:"
99 attr -s colour -V blue foo
100
101 echo "set EA <size,small>:"
102 attr -s size -V small foo
103
104 echo "list the EAs for foo: noise, colour, size" 
105 attr -l foo
106
107 echo "check the list again for foo"
108 attr -l foo
109
110 echo "unmount the FS and see if EAs are persistent"
111 _umount_check_mount
112
113 echo "check the list again for foo after umount/mount"
114 attr -l foo
115
116 echo "get the value of the noise EA"
117 attr -g noise foo
118
119 echo "get the value of the colour EA which was removed earlier"
120 attr -g colour foo
121
122 echo "get the value of the size EA"
123 attr -g size foo
124
125 echo "remove the colour EA on foo"
126 attr -r colour foo
127
128 echo "list EAs for foo: noise, size"
129 attr -l foo
130
131 echo "get the value of the noise EA"
132 attr -g noise foo
133
134 echo "get the value of the colour EA which was removed earlier"
135 attr -g colour foo
136
137 echo "get the value of the size EA"
138 attr -g size foo
139
140 echo "list all the EAs again: noise, size"
141 attr -l foo
142
143 echo "change the value of the size EA from small to huge"
144 attr -s size -V huge foo
145
146 echo "get the size EA which should now have value huge"
147 attr -g size foo
148
149 echo "list EAs: noise, size"
150 attr -l foo
151
152 echo "remove the size EA from foo"
153 attr -r size foo
154
155 echo "list EAs: noise (size EA has been removed)"
156 attr -l foo
157
158 echo "get the noise EA: woof"
159 attr -g noise foo
160
161 echo "try removing non-existent EA named woof"
162 attr -r woof foo
163
164 echo "try removing already removed EA size"
165 attr -r size foo
166
167 echo "list EAs: noise"
168 attr -l foo
169
170 echo "try removing already removed EA colour"
171 attr -r colour foo
172
173 echo "list EAs: noise"
174 attr -l foo
175
176 echo "remove remaining EA noise"
177 attr -r noise foo
178
179 echo "list EAs: should be no EAs left now"
180 attr -l foo
181
182 echo "unmount the FS and see if EAs are persistent"
183 _umount_check_mount
184
185 echo "list EAs: should still be no EAs left"
186 attr -l foo
187
188 echo ""
189 echo "*** Test out the root namespace ***"
190 echo ""
191
192 echo "set EA <root:colour,marone>:"
193 attr -R -s colour -V marone foo
194
195 echo "set EA <user:colour,beige>:"
196 attr -s colour -V beige foo
197
198 echo "set EA <user:vomit,pizza>:"
199 attr -s vomit -V pizza foo
200
201 echo "set EA <root:noise,whack>:"
202 attr -R -s noise -V whack foo
203
204 echo "list root EAs: <root:colour,noise>:"
205 attr -R -l foo
206
207 echo "list user EAs: <user:colour,vomit>:"
208 attr -l foo
209
210 echo "get root EA colour: marone"
211 attr -R -g colour foo
212
213 echo "get root EA noise: whack"
214 attr -R -g noise foo
215
216 echo "get root EA vomit which is a user EA => find nothing"
217 attr -R -g vomit foo
218
219 echo ""
220 echo "unmount the FS and see if EAs are persistent"
221 echo ""
222 _umount_check_mount
223
224 echo "get root EA colour: marone"
225 attr -R -g colour foo
226
227 echo "get root EA noise: whack"
228 attr -R -g noise foo
229
230 echo "get user EA vomit: pizza" 
231 attr -g vomit foo
232
233 echo "remove the root colour EA"
234 attr -R -r colour foo
235
236 echo "list root EAs: <root:noise>:"
237 attr -R -l foo
238
239 echo "list user EAs: <user:colour,vomit>:"
240 attr -l foo
241
242 echo "remove the final root EA noise"
243 attr -R -r noise foo
244
245 echo "list root EAs: none"
246 attr -R -l foo
247
248 cd /
249 umount $SCRATCH_MNT
250
251 udf_db -f $SCRATCH_DEV | _db_filter
252
253 # Checks the udf filesystem
254 _check_udf_filesystem $SCRATCH_DEV
255
256 _scratch_mount
257 cd $SCRATCH_MNT
258
259 echo "delete the file foo - which will delete the associated streams"
260 rm foo
261
262 cd /
263 umount $SCRATCH_MNT
264
265 udf_db -f $SCRATCH_DEV | _db_filter
266
267 # Checks the udf filesystem
268 _check_udf_filesystem $SCRATCH_DEV
269
270 # optional stuff if your test has verbose output to help resolve problems
271 #echo
272 #echo "If failure, check $seq.full (this) and $seq.full.ok (reference)"
273
274 # success, all done
275 status=0
276 exit