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