tests: port generic/097 to Linux
[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 # Copyright (c) 2017 Google, Inc.  All Rights Reserved.
14 #
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
18 #
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27 #
28 #-----------------------------------------------------------------------
29 #
30
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 trap "_cleanup; exit \$status" 0 1 2 3 15
39
40 file=$TEST_DIR/foo
41
42 _cleanup()
43 {
44         rm -f $tmp.* $file
45 }
46
47 getfattr()
48 {
49         $GETFATTR_PROG --absolute-names "$@" |& _filter_test_dir
50 }
51
52 setfattr()
53 {
54         $SETFATTR_PROG "$@" |& _filter_test_dir
55 }
56
57 # get standard environment, filters and checks
58 . ./common/rc
59 . ./common/attr
60 . ./common/filter
61
62 # real QA test starts here
63 _supported_fs generic
64 _supported_os Linux
65
66 _require_test
67 _require_attrs
68
69 echo -e "\ncreate file foo"
70 rm -f $file
71 touch $file
72
73 echo -e "\nshould be no EAs for foo:"
74 getfattr -d $file
75
76 echo -e "\nset EA <noise,woof>:"
77 setfattr -n user.noise -v woof $file
78
79 echo -e "\nset EA <colour,blue>:"
80 setfattr -n user.colour -v blue $file
81
82 echo -e "\nset EA <size,small>:"
83 setfattr -n user.size -v small $file
84
85 echo -e "\nlist the EAs for foo: noise, colour, size"
86 getfattr -d $file
87
88 echo -e "\ncheck the list again for foo"
89 getfattr -d $file
90
91 echo -e "\nunmount the FS and see if EAs are persistent"
92 _test_cycle_mount
93
94 echo -e "\ncheck the list again for foo after umount/mount"
95 getfattr -d $file
96
97 echo -e "\nremove the colour EA on foo"
98 setfattr -x user.colour $file
99
100 echo -e "\nlist EAs for foo: noise, size"
101 getfattr -d $file
102
103 echo -e "\nget the value of the noise EA"
104 getfattr -n user.noise $file
105
106 echo -e "\nget the value of the colour EA which was removed earlier"
107 getfattr -n user.colour $file
108
109 echo -e "\nget the value of the size EA"
110 getfattr -n user.size $file
111
112 echo -e "\nlist all the EAs again: noise, size"
113 getfattr -d $file
114
115 echo -e "\nchange the value of the size EA from small to huge"
116 setfattr -n user.size -v huge $file
117
118 echo -e "\nget the size EA which should now have value huge"
119 getfattr -n user.size $file
120
121 echo -e "\nlist EAs: noise, size"
122 getfattr -d $file
123
124 echo -e "\nremove the size EA from foo"
125 setfattr -x user.size $file
126
127 echo -e "\nlist EAs: noise (size EA has been removed)"
128 getfattr -d $file
129
130 echo -e "\ntry removing non-existent EA named woof"
131 setfattr -x user.woof $file
132
133 echo -e "\ntry removing already removed EA size"
134 setfattr -x user.size $file
135
136 echo -e "\nlist EAs: noise"
137 getfattr -d $file
138
139 echo -e "\ntry removing already removed EA colour"
140 setfattr -x user.colour $file
141
142 echo -e "\nlist EAs: noise"
143 getfattr -d $file
144
145 echo -e "\nremove remaining EA noise"
146 setfattr -x user.noise $file
147
148 echo -e "\nlist EAs: should be no EAs left now"
149 getfattr -d $file
150
151 echo -e "\nunmount the FS and see if EAs are persistent"
152 _test_cycle_mount
153
154 echo -e "\nlist EAs: should still be no EAs left"
155 getfattr -d $file
156
157 echo -e "\n*** Test out the trusted namespace ***"
158
159 echo -e "\nset EA <trusted:colour,marone>:"
160 setfattr -n trusted.colour -v marone $file
161
162 echo -e "\nset EA <user:colour,beige>:"
163 setfattr -n user.colour -v beige $file
164
165 echo -e "\nset EA <user:vomit,pizza>:"
166 setfattr -n user.vomit -v pizza $file
167
168 echo -e "\nset EA <trusted:noise,whack>:"
169 setfattr -n trusted.noise -v whack $file
170
171 echo -e "\nlist trusted EAs: <trusted:colour,noise>:"
172 getfattr -d -m '^trusted\.' $file
173
174 echo -e "\nlist user EAs: <user:colour,vomit>:"
175 getfattr -d $file
176
177 echo -e "\nget trusted EA colour: marone"
178 getfattr -n trusted.colour $file
179
180 echo -e "\nget trusted EA noise: whack"
181 getfattr -n trusted.noise $file
182
183 echo -e "\nget trusted EA vomit which is a user EA => find nothing"
184 getfattr -n trusted.vomit $file
185
186 echo -e "\nunmount the FS and see if EAs are persistent"
187 _test_cycle_mount
188
189 echo -e "\nget trusted EA colour: marone"
190 getfattr -n trusted.colour $file
191
192 echo -e "\nget trusted EA noise: whack"
193 getfattr -n trusted.noise $file
194
195 echo -e "\nget user EA vomit: pizza"
196 getfattr -n user.vomit $file
197
198 echo -e "\nremove the trusted colour EA"
199 setfattr -x trusted.colour $file
200
201 echo -e "\nlist trusted EAs: <trusted:noise>:"
202 getfattr -d -m '^trusted\.' $file
203
204 echo -e "\nlist user EAs: <user:colour,vomit>:"
205 getfattr -d $file
206
207 echo -e "\nremove the final trusted EA noise"
208 setfattr -x trusted.noise $file
209
210 echo -e "\nlist trusted EAs: none"
211 getfattr -d -m '^trusted\.' $file
212
213 # success, all done
214 status=0
215 exit