2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
10 _begin_fstest metadata attr udf auto quick
12 status=0 # success is the default!
14 # Import common functions.
20 sed "s#$TEST_DIR[^ :]*#<TESTFILE>#g;
21 s#$tmp[^ :]*#<TMPFILE>#g" $1
26 $ATTR_PROG $* 2>$tmp.err >$tmp.out
35 _getfattr $* 2>$tmp.err >$tmp.out
46 echo " *** print attributes"
47 if ! do_getfattr -d -e text --absolute-names $file
49 echo " !!! error return"
54 # real QA test starts here
60 testfile=$TEST_DIR/attribute_$$
62 echo "*** list non-existant file"
65 echo "*** list empty file"
69 echo "*** query non-existant attribute"
70 _attr -g "nonexistant" $testfile 2>&1
72 echo "*** one attribute"
73 echo "fish" | _attr -s fish $testfile
76 echo "*** replace attribute"
77 echo "fish3" | _attr -s fish $testfile
80 echo "*** add attribute"
81 echo "fish2" | _attr -s snrub $testfile
84 echo "*** remove attribute"
85 _attr -r fish $testfile
88 echo "*** add lots of attributes"
91 while [ $v -lt $MAX_ATTRS ]
93 echo -n "value_$v" | attr -s "attribute_$v" $testfile >>$seqres.full
96 echo "!!! failed to add \"attribute_$v\""
104 # don't print it all out...
105 _getfattr --absolute-names $testfile \
106 | tee -a $seqres.full \
111 END {print " *** " (l - 1) " attribute(s)" }' \
112 | sed s/$MAX_ATTRS/MAX_ATTRS/
114 echo "*** remove lots of attributes"
116 while [ $v -lt $MAX_ATTRS ]
118 if ! $ATTR_PROG -r "attribute_$v" $testfile >>$seqres.full
120 echo "!!! failed to remove \"attribute_$v\""
129 echo "*** really long value"
130 dd if=/dev/zero bs=1 count=$MAX_ATTRVAL_SIZE 2>/dev/null \
131 | _attr -s "long_attr" $testfile >/dev/null
133 OCTAL_SIZE=`echo "obase=8; $MAX_ATTRVAL_SIZE" | bc`
134 _attr -q -g "long_attr" $testfile | od -t x1 | sed -e "s/^0*$OCTAL_SIZE$/ATTRSIZE/"
135 _attr -r "long_attr" $testfile >/dev/null
137 echo "*** set/get/remove really long names (expect failure)"
139 long="$short$short$short$short$short$short$short$short$short$short"
140 vlong="$long$long$long"
142 _attr -s $vlong -V fish $testfile 2>&1 >/dev/null
143 _attr -g $vlong $testfile 2>&1 >/dev/null
144 _attr -r $vlong $testfile 2>&1 >/dev/null
146 echo "*** check final"