tests: port generic/097 to Linux

This IRIX-specific test did some basic testing of extended attributes.
Port it to Linux; this mainly involved updating it to use the 'getfattr'
and 'setfattr' programs instead 'attr'.  Note that although 'attr' is
available on Linux, it's mainly for IRIX compatibility, the man page
recommends against using it on non-XFS filesystems, and it doesn't
support listing user xattrs only.  (In the last point it actually
differs from IRIX 'attr', but probably no one cares anymore.)  getfattr
also sorts its output by xattr name, so its output will be the same on
all filesystems unlike 'attr -l'.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
Eric Biggers
2017-07-20 21:22:04 -07:00
committed by Eryu Guan
parent f5413189db
commit 74d977646c
6 changed files with 287 additions and 410 deletions
-1
View File
@@ -235,7 +235,6 @@
# Symlinked files # Symlinked files
/tests/generic/088.out /tests/generic/088.out
/tests/generic/097.out
/tests/xfs/018.op /tests/xfs/018.op
/tests/xfs/022.out /tests/xfs/022.out
/tests/xfs/023.out /tests/xfs/023.out
+109 -144
View File
@@ -10,6 +10,7 @@
# #
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. # Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
# Copyright (c) 2017 Google, Inc. All Rights Reserved.
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as # modify it under the terms of the GNU General Public License as
@@ -27,7 +28,6 @@
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# #
seqfull=$0
seq=`basename $0` seq=`basename $0`
seqres=$RESULT_DIR/$seq seqres=$RESULT_DIR/$seq
echo "QA output created by $seq" echo "QA output created by $seq"
@@ -35,215 +35,180 @@ echo "QA output created by $seq"
here=`pwd` here=`pwd`
tmp=/tmp/$$ tmp=/tmp/$$
status=1 # failure is the default! status=1 # failure is the default!
TARGET_DIR=
trap "_cleanup; exit \$status" 0 1 2 3 15 trap "_cleanup; exit \$status" 0 1 2 3 15
file=$TEST_DIR/foo
_cleanup() _cleanup()
{ {
rm -f $tmp.* rm -f $tmp.* $file
cd $TARGET_DIR
rm -f foo
} }
_umount_and_mount() getfattr()
{ {
cd / $GETFATTR_PROG --absolute-names "$@" |& _filter_test_dir
umount $TARGET_DIR }
if [ "$FSTYP" == "xfs" ]; then
_test_mount setfattr()
else {
_scratch_mount $SETFATTR_PROG "$@" |& _filter_test_dir
fi
cd $TARGET_DIR
} }
# get standard environment, filters and checks # get standard environment, filters and checks
. ./common/rc . ./common/rc
. ./common/attr
. ./common/filter . ./common/filter
# link correct .out file
# This is done bacause udf and xfs print attrs in different orders.
rm -rf $seqfull.out
if [ "$FSTYP" == "xfs" ]; then
ln -s $seq.out.xfs $seqfull.out
else
ln -s $seq.out.udf $seqfull.out
fi
# real QA test starts here # real QA test starts here
_supported_fs generic _supported_fs generic
_supported_os IRIX _supported_os Linux
_require_test _require_test
_require_scratch
_require_attrs _require_attrs
TARGET_DIR=$SCRATCH_MNT echo -e "\ncreate file foo"
[ "$FSTYP" == "xfs" ] && TARGET_DIR=$TEST_DIR rm -f $file
cd $TARGET_DIR touch $file
echo "create file foo" echo -e "\nshould be no EAs for foo:"
rm -f foo getfattr -d $file
touch foo
echo "should be no EAs for foo:" echo -e "\nset EA <noise,woof>:"
${ATTR_PROG} -l foo setfattr -n user.noise -v woof $file
echo "set EA <noise,woof>:" echo -e "\nset EA <colour,blue>:"
${ATTR_PROG} -s noise -V woof foo setfattr -n user.colour -v blue $file
echo "set EA <colour,blue>:" echo -e "\nset EA <size,small>:"
${ATTR_PROG} -s colour -V blue foo setfattr -n user.size -v small $file
echo "set EA <size,small>:" echo -e "\nlist the EAs for foo: noise, colour, size"
${ATTR_PROG} -s size -V small foo getfattr -d $file
echo "list the EAs for foo: noise, colour, size" echo -e "\ncheck the list again for foo"
${ATTR_PROG} -l foo getfattr -d $file
echo "check the list again for foo" echo -e "\nunmount the FS and see if EAs are persistent"
${ATTR_PROG} -l foo _test_cycle_mount
echo "unmount the FS and see if EAs are persistent" echo -e "\ncheck the list again for foo after umount/mount"
_umount_and_mount getfattr -d $file
echo "check the list again for foo after umount/mount" echo -e "\nremove the colour EA on foo"
${ATTR_PROG} -l foo setfattr -x user.colour $file
echo "get the value of the noise EA" echo -e "\nlist EAs for foo: noise, size"
${ATTR_PROG} -g noise foo getfattr -d $file
echo "get the value of the colour EA which was removed earlier" echo -e "\nget the value of the noise EA"
${ATTR_PROG} -g colour foo getfattr -n user.noise $file
echo "get the value of the size EA" echo -e "\nget the value of the colour EA which was removed earlier"
${ATTR_PROG} -g size foo getfattr -n user.colour $file
echo "remove the colour EA on foo" echo -e "\nget the value of the size EA"
${ATTR_PROG} -r colour foo getfattr -n user.size $file
echo "list EAs for foo: noise, size" echo -e "\nlist all the EAs again: noise, size"
${ATTR_PROG} -l foo getfattr -d $file
echo "get the value of the noise EA" echo -e "\nchange the value of the size EA from small to huge"
${ATTR_PROG} -g noise foo setfattr -n user.size -v huge $file
echo "get the value of the colour EA which was removed earlier" echo -e "\nget the size EA which should now have value huge"
${ATTR_PROG} -g colour foo getfattr -n user.size $file
echo "get the value of the size EA" echo -e "\nlist EAs: noise, size"
${ATTR_PROG} -g size foo getfattr -d $file
echo "list all the EAs again: noise, size" echo -e "\nremove the size EA from foo"
${ATTR_PROG} -l foo setfattr -x user.size $file
echo "change the value of the size EA from small to huge" echo -e "\nlist EAs: noise (size EA has been removed)"
${ATTR_PROG} -s size -V huge foo getfattr -d $file
echo "get the size EA which should now have value huge" echo -e "\ntry removing non-existent EA named woof"
${ATTR_PROG} -g size foo setfattr -x user.woof $file
echo "list EAs: noise, size" echo -e "\ntry removing already removed EA size"
${ATTR_PROG} -l foo setfattr -x user.size $file
echo "remove the size EA from foo" echo -e "\nlist EAs: noise"
${ATTR_PROG} -r size foo getfattr -d $file
echo "list EAs: noise (size EA has been removed)" echo -e "\ntry removing already removed EA colour"
${ATTR_PROG} -l foo setfattr -x user.colour $file
echo "get the noise EA: woof" echo -e "\nlist EAs: noise"
${ATTR_PROG} -g noise foo getfattr -d $file
echo "try removing non-existent EA named woof" echo -e "\nremove remaining EA noise"
${ATTR_PROG} -r woof foo setfattr -x user.noise $file
echo "try removing already removed EA size" echo -e "\nlist EAs: should be no EAs left now"
${ATTR_PROG} -r size foo getfattr -d $file
echo "list EAs: noise" echo -e "\nunmount the FS and see if EAs are persistent"
${ATTR_PROG} -l foo _test_cycle_mount
echo "try removing already removed EA colour" echo -e "\nlist EAs: should still be no EAs left"
${ATTR_PROG} -r colour foo getfattr -d $file
echo "list EAs: noise" echo -e "\n*** Test out the trusted namespace ***"
${ATTR_PROG} -l foo
echo "remove remaining EA noise" echo -e "\nset EA <trusted:colour,marone>:"
${ATTR_PROG} -r noise foo setfattr -n trusted.colour -v marone $file
echo "list EAs: should be no EAs left now" echo -e "\nset EA <user:colour,beige>:"
${ATTR_PROG} -l foo setfattr -n user.colour -v beige $file
echo "unmount the FS and see if EAs are persistent" echo -e "\nset EA <user:vomit,pizza>:"
_umount_and_mount setfattr -n user.vomit -v pizza $file
echo "list EAs: should still be no EAs left" echo -e "\nset EA <trusted:noise,whack>:"
${ATTR_PROG} -l foo setfattr -n trusted.noise -v whack $file
echo "" echo -e "\nlist trusted EAs: <trusted:colour,noise>:"
echo "*** Test out the root namespace ***" getfattr -d -m '^trusted\.' $file
echo ""
echo "set EA <root:colour,marone>:" echo -e "\nlist user EAs: <user:colour,vomit>:"
${ATTR_PROG} -R -s colour -V marone foo getfattr -d $file
echo "set EA <user:colour,beige>:" echo -e "\nget trusted EA colour: marone"
${ATTR_PROG} -s colour -V beige foo getfattr -n trusted.colour $file
echo "set EA <user:vomit,pizza>:" echo -e "\nget trusted EA noise: whack"
${ATTR_PROG} -s vomit -V pizza foo getfattr -n trusted.noise $file
echo "set EA <root:noise,whack>:" echo -e "\nget trusted EA vomit which is a user EA => find nothing"
${ATTR_PROG} -R -s noise -V whack foo getfattr -n trusted.vomit $file
echo "list root EAs: <root:colour,noise>:" echo -e "\nunmount the FS and see if EAs are persistent"
${ATTR_PROG} -R -l foo _test_cycle_mount
echo "list user EAs: <user:colour,vomit>:" echo -e "\nget trusted EA colour: marone"
${ATTR_PROG} -l foo getfattr -n trusted.colour $file
echo "get root EA colour: marone" echo -e "\nget trusted EA noise: whack"
${ATTR_PROG} -R -g colour foo getfattr -n trusted.noise $file
echo "get root EA noise: whack" echo -e "\nget user EA vomit: pizza"
${ATTR_PROG} -R -g noise foo getfattr -n user.vomit $file
echo "get root EA vomit which is a user EA => find nothing" echo -e "\nremove the trusted colour EA"
${ATTR_PROG} -R -g vomit foo setfattr -x trusted.colour $file
echo "" echo -e "\nlist trusted EAs: <trusted:noise>:"
echo "unmount the FS and see if EAs are persistent" getfattr -d -m '^trusted\.' $file
echo ""
_umount_and_mount
echo "get root EA colour: marone" echo -e "\nlist user EAs: <user:colour,vomit>:"
${ATTR_PROG} -R -g colour foo getfattr -d $file
echo "get root EA noise: whack" echo -e "\nremove the final trusted EA noise"
${ATTR_PROG} -R -g noise foo setfattr -x trusted.noise $file
echo "get user EA vomit: pizza" echo -e "\nlist trusted EAs: none"
${ATTR_PROG} -g vomit foo getfattr -d -m '^trusted\.' $file
echo "remove the root colour EA"
${ATTR_PROG} -R -r colour foo
echo "list root EAs: <root:noise>:"
${ATTR_PROG} -R -l foo
echo "list user EAs: <user:colour,vomit>:"
${ATTR_PROG} -l foo
echo "remove the final root EA noise"
${ATTR_PROG} -R -r noise foo
echo "list root EAs: none"
${ATTR_PROG} -R -l foo
cd /
# success, all done # success, all done
status=0 status=0
+177
View File
@@ -0,0 +1,177 @@
QA output created by 097
create file foo
should be no EAs for foo:
set EA <noise,woof>:
set EA <colour,blue>:
set EA <size,small>:
list the EAs for foo: noise, colour, size
# file: TEST_DIR/foo
user.colour="blue"
user.noise="woof"
user.size="small"
check the list again for foo
# file: TEST_DIR/foo
user.colour="blue"
user.noise="woof"
user.size="small"
unmount the FS and see if EAs are persistent
check the list again for foo after umount/mount
# file: TEST_DIR/foo
user.colour="blue"
user.noise="woof"
user.size="small"
remove the colour EA on foo
list EAs for foo: noise, size
# file: TEST_DIR/foo
user.noise="woof"
user.size="small"
get the value of the noise EA
# file: TEST_DIR/foo
user.noise="woof"
get the value of the colour EA which was removed earlier
TEST_DIR/foo: user.colour: No such attribute
get the value of the size EA
# file: TEST_DIR/foo
user.size="small"
list all the EAs again: noise, size
# file: TEST_DIR/foo
user.noise="woof"
user.size="small"
change the value of the size EA from small to huge
get the size EA which should now have value huge
# file: TEST_DIR/foo
user.size="huge"
list EAs: noise, size
# file: TEST_DIR/foo
user.noise="woof"
user.size="huge"
remove the size EA from foo
list EAs: noise (size EA has been removed)
# file: TEST_DIR/foo
user.noise="woof"
try removing non-existent EA named woof
setfattr: TEST_DIR/foo: No such attribute
try removing already removed EA size
setfattr: TEST_DIR/foo: No such attribute
list EAs: noise
# file: TEST_DIR/foo
user.noise="woof"
try removing already removed EA colour
setfattr: TEST_DIR/foo: No such attribute
list EAs: noise
# file: TEST_DIR/foo
user.noise="woof"
remove remaining EA noise
list EAs: should be no EAs left now
unmount the FS and see if EAs are persistent
list EAs: should still be no EAs left
*** Test out the trusted namespace ***
set EA <trusted:colour,marone>:
set EA <user:colour,beige>:
set EA <user:vomit,pizza>:
set EA <trusted:noise,whack>:
list trusted EAs: <trusted:colour,noise>:
# file: TEST_DIR/foo
trusted.colour="marone"
trusted.noise="whack"
list user EAs: <user:colour,vomit>:
# file: TEST_DIR/foo
user.colour="beige"
user.vomit="pizza"
get trusted EA colour: marone
# file: TEST_DIR/foo
trusted.colour="marone"
get trusted EA noise: whack
# file: TEST_DIR/foo
trusted.noise="whack"
get trusted EA vomit which is a user EA => find nothing
TEST_DIR/foo: trusted.vomit: No such attribute
unmount the FS and see if EAs are persistent
get trusted EA colour: marone
# file: TEST_DIR/foo
trusted.colour="marone"
get trusted EA noise: whack
# file: TEST_DIR/foo
trusted.noise="whack"
get user EA vomit: pizza
# file: TEST_DIR/foo
user.vomit="pizza"
remove the trusted colour EA
list trusted EAs: <trusted:noise>:
# file: TEST_DIR/foo
trusted.noise="whack"
list user EAs: <user:colour,vomit>:
# file: TEST_DIR/foo
user.colour="beige"
user.vomit="pizza"
remove the final trusted EA noise
list trusted EAs: none
-132
View File
@@ -1,132 +0,0 @@
QA output created by 097
create file foo
should be no EAs for foo:
set EA <noise,woof>:
Attribute "noise" set to a 4 byte value for foo:
woof
set EA <colour,blue>:
Attribute "colour" set to a 4 byte value for foo:
blue
set EA <size,small>:
Attribute "size" set to a 5 byte value for foo:
small
list the EAs for foo: noise, colour, size
Attribute "noise" has a 4 byte value for foo
Attribute "colour" has a 4 byte value for foo
Attribute "size" has a 5 byte value for foo
check the list again for foo
Attribute "noise" has a 4 byte value for foo
Attribute "colour" has a 4 byte value for foo
Attribute "size" has a 5 byte value for foo
unmount the FS and see if EAs are persistent
check the list again for foo after umount/mount
Attribute "noise" has a 4 byte value for foo
Attribute "colour" has a 4 byte value for foo
Attribute "size" has a 5 byte value for foo
get the value of the noise EA
Attribute "noise" had a 4 byte value for foo:
woof
get the value of the colour EA which was removed earlier
Attribute "colour" had a 4 byte value for foo:
blue
get the value of the size EA
Attribute "size" had a 5 byte value for foo:
small
remove the colour EA on foo
list EAs for foo: noise, size
Attribute "noise" has a 4 byte value for foo
Attribute "size" has a 5 byte value for foo
get the value of the noise EA
Attribute "noise" had a 4 byte value for foo:
woof
get the value of the colour EA which was removed earlier
attr_get: Attribute not found
Could not get "colour" for foo
get the value of the size EA
Attribute "size" had a 5 byte value for foo:
small
list all the EAs again: noise, size
Attribute "noise" has a 4 byte value for foo
Attribute "size" has a 5 byte value for foo
change the value of the size EA from small to huge
Attribute "size" set to a 4 byte value for foo:
huge
get the size EA which should now have value huge
Attribute "size" had a 4 byte value for foo:
huge
list EAs: noise, size
Attribute "noise" has a 4 byte value for foo
Attribute "size" has a 4 byte value for foo
remove the size EA from foo
list EAs: noise (size EA has been removed)
Attribute "noise" has a 4 byte value for foo
get the noise EA: woof
Attribute "noise" had a 4 byte value for foo:
woof
try removing non-existent EA named woof
attr_remove: Attribute not found
Could not remove "woof" for foo
try removing already removed EA size
attr_remove: Attribute not found
Could not remove "size" for foo
list EAs: noise
Attribute "noise" has a 4 byte value for foo
try removing already removed EA colour
attr_remove: Attribute not found
Could not remove "colour" for foo
list EAs: noise
Attribute "noise" has a 4 byte value for foo
remove remaining EA noise
list EAs: should be no EAs left now
unmount the FS and see if EAs are persistent
list EAs: should still be no EAs left
*** Test out the root namespace ***
set EA <root:colour,marone>:
Attribute "colour" set to a 6 byte value for foo:
marone
set EA <user:colour,beige>:
Attribute "colour" set to a 5 byte value for foo:
beige
set EA <user:vomit,pizza>:
Attribute "vomit" set to a 5 byte value for foo:
pizza
set EA <root:noise,whack>:
Attribute "noise" set to a 5 byte value for foo:
whack
list root EAs: <root:colour,noise>:
Attribute "colour" has a 6 byte value for foo
Attribute "noise" has a 5 byte value for foo
list user EAs: <user:colour,vomit>:
Attribute "colour" has a 5 byte value for foo
Attribute "vomit" has a 5 byte value for foo
get root EA colour: marone
Attribute "colour" had a 6 byte value for foo:
marone
get root EA noise: whack
Attribute "noise" had a 5 byte value for foo:
whack
get root EA vomit which is a user EA => find nothing
attr_get: Attribute not found
Could not get "vomit" for foo
unmount the FS and see if EAs are persistent
get root EA colour: marone
Attribute "colour" had a 6 byte value for foo:
marone
get root EA noise: whack
Attribute "noise" had a 5 byte value for foo:
whack
get user EA vomit: pizza
Attribute "vomit" had a 5 byte value for foo:
pizza
remove the root colour EA
list root EAs: <root:noise>:
Attribute "noise" has a 5 byte value for foo
list user EAs: <user:colour,vomit>:
Attribute "colour" has a 5 byte value for foo
Attribute "vomit" has a 5 byte value for foo
remove the final root EA noise
list root EAs: none
-132
View File
@@ -1,132 +0,0 @@
QA output created by 097
create file foo
should be no EAs for foo:
set EA <noise,woof>:
Attribute "noise" set to a 4 byte value for foo:
woof
set EA <colour,blue>:
Attribute "colour" set to a 4 byte value for foo:
blue
set EA <size,small>:
Attribute "size" set to a 5 byte value for foo:
small
list the EAs for foo: noise, colour, size
Attribute "size" has a 5 byte value for foo
Attribute "noise" has a 4 byte value for foo
Attribute "colour" has a 4 byte value for foo
check the list again for foo
Attribute "size" has a 5 byte value for foo
Attribute "noise" has a 4 byte value for foo
Attribute "colour" has a 4 byte value for foo
unmount the FS and see if EAs are persistent
check the list again for foo after umount/mount
Attribute "size" has a 5 byte value for foo
Attribute "noise" has a 4 byte value for foo
Attribute "colour" has a 4 byte value for foo
get the value of the noise EA
Attribute "noise" had a 4 byte value for foo:
woof
get the value of the colour EA which was removed earlier
Attribute "colour" had a 4 byte value for foo:
blue
get the value of the size EA
Attribute "size" had a 5 byte value for foo:
small
remove the colour EA on foo
list EAs for foo: noise, size
Attribute "size" has a 5 byte value for foo
Attribute "noise" has a 4 byte value for foo
get the value of the noise EA
Attribute "noise" had a 4 byte value for foo:
woof
get the value of the colour EA which was removed earlier
attr_get: Attribute not found
Could not get "colour" for foo
get the value of the size EA
Attribute "size" had a 5 byte value for foo:
small
list all the EAs again: noise, size
Attribute "size" has a 5 byte value for foo
Attribute "noise" has a 4 byte value for foo
change the value of the size EA from small to huge
Attribute "size" set to a 4 byte value for foo:
huge
get the size EA which should now have value huge
Attribute "size" had a 4 byte value for foo:
huge
list EAs: noise, size
Attribute "noise" has a 4 byte value for foo
Attribute "size" has a 4 byte value for foo
remove the size EA from foo
list EAs: noise (size EA has been removed)
Attribute "noise" has a 4 byte value for foo
get the noise EA: woof
Attribute "noise" had a 4 byte value for foo:
woof
try removing non-existent EA named woof
attr_remove: Attribute not found
Could not remove "woof" for foo
try removing already removed EA size
attr_remove: Attribute not found
Could not remove "size" for foo
list EAs: noise
Attribute "noise" has a 4 byte value for foo
try removing already removed EA colour
attr_remove: Attribute not found
Could not remove "colour" for foo
list EAs: noise
Attribute "noise" has a 4 byte value for foo
remove remaining EA noise
list EAs: should be no EAs left now
unmount the FS and see if EAs are persistent
list EAs: should still be no EAs left
*** Test out the root namespace ***
set EA <root:colour,marone>:
Attribute "colour" set to a 6 byte value for foo:
marone
set EA <user:colour,beige>:
Attribute "colour" set to a 5 byte value for foo:
beige
set EA <user:vomit,pizza>:
Attribute "vomit" set to a 5 byte value for foo:
pizza
set EA <root:noise,whack>:
Attribute "noise" set to a 5 byte value for foo:
whack
list root EAs: <root:colour,noise>:
Attribute "noise" has a 5 byte value for foo
Attribute "colour" has a 6 byte value for foo
list user EAs: <user:colour,vomit>:
Attribute "vomit" has a 5 byte value for foo
Attribute "colour" has a 5 byte value for foo
get root EA colour: marone
Attribute "colour" had a 6 byte value for foo:
marone
get root EA noise: whack
Attribute "noise" had a 5 byte value for foo:
whack
get root EA vomit which is a user EA => find nothing
attr_get: Attribute not found
Could not get "vomit" for foo
unmount the FS and see if EAs are persistent
get root EA colour: marone
Attribute "colour" had a 6 byte value for foo:
marone
get root EA noise: whack
Attribute "noise" had a 5 byte value for foo:
whack
get user EA vomit: pizza
Attribute "vomit" had a 5 byte value for foo:
pizza
remove the root colour EA
list root EAs: <root:noise>:
Attribute "noise" has a 5 byte value for foo
list user EAs: <user:colour,vomit>:
Attribute "vomit" has a 5 byte value for foo
Attribute "colour" has a 5 byte value for foo
remove the final root EA noise
list root EAs: none
+1 -1
View File
@@ -99,7 +99,7 @@
094 auto quick prealloc 094 auto quick prealloc
095 auto rw stress 095 auto rw stress
096 auto prealloc quick zero 096 auto prealloc quick zero
097 udf auto 097 attr auto quick
098 auto quick metadata 098 auto quick metadata
099 udf auto 099 udf auto
100 udf auto 100 udf auto