xfstests: remove 285.full and 286.full
[xfstests-dev.git] / 020
1 #! /bin/bash
2 # FS QA Test No. 020
3 #
4 # extended attributes
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=0        # success is the default!
31 trap "_cleanup; rm -f $tmp.* $testfile; exit \$status" 0 1 2 3 15
32
33 # get standard environment, filters and checks
34 . ./common.rc
35 . ./common.filter
36 . ./common.attr
37
38 _cleanup()
39 {
40     _cleanup_testdir
41 }
42
43 _filter()
44 {
45     sed "s#$testdir[^ :]*#<TESTFILE>#g; 
46             s#$tmp[^ :]*#<TMPFILE>#g" $1
47 }
48
49 _attr()
50 {
51     $ATTR_PROG $* 2>$tmp.err >$tmp.out
52     exit=$?
53     _filter $tmp.out
54     _filter $tmp.err 1>&2
55     return $exit
56 }
57
58 _getfattr()
59 {
60     $GETFATTR_PROG $* 2>$tmp.err >$tmp.out
61     exit=$?
62     _filter $tmp.out
63     _filter $tmp.err 1>&2
64     return $exit
65 }
66
67 _attr_list()
68 {
69     file=$1
70     
71     echo "   *** print attributes"
72     if ! _getfattr -d -e text --absolute-names $file
73     then
74         echo "      !!! error return"
75         return 1
76     fi
77 }
78
79
80 # real QA test starts here
81 _supported_fs generic
82 _supported_os Linux
83
84 _require_attrs
85
86 _setup_testdir
87
88 rm -f $seq.full
89
90 testfile=$testdir/attribute_$$
91
92 echo "*** list non-existant file"
93 _attr_list $testfile
94
95 echo "*** list empty file"
96 touch $testfile
97 _attr_list $testfile
98
99 echo "*** query non-existant attribute"
100 _attr -g "nonexistant" $testfile 2>&1
101
102 echo "*** one attribute"
103 echo "fish" | _attr -s fish $testfile
104 _attr_list $testfile
105
106 echo "*** replace attribute"
107 echo "fish3" | _attr -s fish $testfile
108 _attr_list $testfile
109
110 echo "*** add attribute"
111 echo "fish2" | _attr -s snrub $testfile
112 _attr_list $testfile
113
114 echo "*** remove attribute"
115 _attr -r fish $testfile
116 _attr_list $testfile
117
118 echo "*** add lots of attributes"
119 v=0
120
121 while [ $v -lt $MAX_ATTRS ]
122 do
123     echo -n "value_$v" | attr -s "attribute_$v" $testfile >>$seq.full
124     if [ $? -ne 0 ]
125     then
126         echo "!!! failed to add \"attribute_$v\""
127         exit 1
128     fi
129     
130     let "v = v + 1"
131 done
132
133 echo "*** check"
134 # don't print it all out...
135 getfattr --absolute-names $testfile \
136     | tee -a $seq.full \
137     | $AWK_PROG '
138         /^#/ { next }
139         /^[     ]*$/ { next }
140         { l++ } 
141         END {print "   *** " (l - 1) " attribute(s)" }' \
142     | sed s/$MAX_ATTRS/MAX_ATTRS/
143
144 echo "*** remove lots of attributes"
145 v=0
146 while [ $v -lt $MAX_ATTRS ]
147 do
148     if ! $ATTR_PROG -r "attribute_$v" $testfile >>$seq.full
149     then
150         echo "!!! failed to remove \"attribute_$v\""
151         exit 1
152     fi
153     
154     let "v = v + 1"
155 done
156
157 _attr_list $testfile
158
159 echo "*** really long value"
160 dd if=/dev/zero bs=1 count=$MAX_ATTRVAL_SIZE 2>/dev/null \
161     | _attr -s "long_attr" $testfile >/dev/null
162
163 OCTAL_SIZE=`echo "obase=8; $MAX_ATTRVAL_SIZE" | bc`
164 _attr -q -g "long_attr" $testfile | od -t x1 | sed -e "s/^0*$OCTAL_SIZE$/ATTRSIZE/"    
165 _attr -r "long_attr" $testfile >/dev/null
166
167
168 echo "*** set/get/remove really long names (expect failure)"
169 short="XXXXXXXXXX"
170 long="$short$short$short$short$short$short$short$short$short$short"
171 vlong="$long$long$long"
172
173 _attr -s $vlong -V fish $testfile 2>&1 >/dev/null
174 _attr -g $vlong $testfile 2>&1 >/dev/null
175 _attr -r $vlong $testfile 2>&1 >/dev/null
176
177 echo "*** check final"
178
179 _attr_list $testfile
180
181 echo "*** delete"
182 rm -f $testfile
183
184 exit