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
/tests/generic/088.out
/tests/generic/097.out
/tests/xfs/018.op
/tests/xfs/022.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) 2017 Google, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -27,7 +28,6 @@
#-----------------------------------------------------------------------
#
seqfull=$0
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
@@ -35,215 +35,180 @@ echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
TARGET_DIR=
trap "_cleanup; exit \$status" 0 1 2 3 15
file=$TEST_DIR/foo
_cleanup()
{
rm -f $tmp.*
cd $TARGET_DIR
rm -f foo
rm -f $tmp.* $file
}
_umount_and_mount()
getfattr()
{
cd /
umount $TARGET_DIR
if [ "$FSTYP" == "xfs" ]; then
_test_mount
else
_scratch_mount
fi
cd $TARGET_DIR
$GETFATTR_PROG --absolute-names "$@" |& _filter_test_dir
}
setfattr()
{
$SETFATTR_PROG "$@" |& _filter_test_dir
}
# get standard environment, filters and checks
. ./common/rc
. ./common/attr
. ./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
_supported_fs generic
_supported_os IRIX
_supported_os Linux
_require_test
_require_scratch
_require_attrs
TARGET_DIR=$SCRATCH_MNT
[ "$FSTYP" == "xfs" ] && TARGET_DIR=$TEST_DIR
cd $TARGET_DIR
echo -e "\ncreate file foo"
rm -f $file
touch $file
echo "create file foo"
rm -f foo
touch foo
echo -e "\nshould be no EAs for foo:"
getfattr -d $file
echo "should be no EAs for foo:"
${ATTR_PROG} -l foo
echo -e "\nset EA <noise,woof>:"
setfattr -n user.noise -v woof $file
echo "set EA <noise,woof>:"
${ATTR_PROG} -s noise -V woof foo
echo -e "\nset EA <colour,blue>:"
setfattr -n user.colour -v blue $file
echo "set EA <colour,blue>:"
${ATTR_PROG} -s colour -V blue foo
echo -e "\nset EA <size,small>:"
setfattr -n user.size -v small $file
echo "set EA <size,small>:"
${ATTR_PROG} -s size -V small foo
echo -e "\nlist the EAs for foo: noise, colour, size"
getfattr -d $file
echo "list the EAs for foo: noise, colour, size"
${ATTR_PROG} -l foo
echo -e "\ncheck the list again for foo"
getfattr -d $file
echo "check the list again for foo"
${ATTR_PROG} -l foo
echo -e "\nunmount the FS and see if EAs are persistent"
_test_cycle_mount
echo "unmount the FS and see if EAs are persistent"
_umount_and_mount
echo -e "\ncheck the list again for foo after umount/mount"
getfattr -d $file
echo "check the list again for foo after umount/mount"
${ATTR_PROG} -l foo
echo -e "\nremove the colour EA on foo"
setfattr -x user.colour $file
echo "get the value of the noise EA"
${ATTR_PROG} -g noise foo
echo -e "\nlist EAs for foo: noise, size"
getfattr -d $file
echo "get the value of the colour EA which was removed earlier"
${ATTR_PROG} -g colour foo
echo -e "\nget the value of the noise EA"
getfattr -n user.noise $file
echo "get the value of the size EA"
${ATTR_PROG} -g size foo
echo -e "\nget the value of the colour EA which was removed earlier"
getfattr -n user.colour $file
echo "remove the colour EA on foo"
${ATTR_PROG} -r colour foo
echo -e "\nget the value of the size EA"
getfattr -n user.size $file
echo "list EAs for foo: noise, size"
${ATTR_PROG} -l foo
echo -e "\nlist all the EAs again: noise, size"
getfattr -d $file
echo "get the value of the noise EA"
${ATTR_PROG} -g noise foo
echo -e "\nchange the value of the size EA from small to huge"
setfattr -n user.size -v huge $file
echo "get the value of the colour EA which was removed earlier"
${ATTR_PROG} -g colour foo
echo -e "\nget the size EA which should now have value huge"
getfattr -n user.size $file
echo "get the value of the size EA"
${ATTR_PROG} -g size foo
echo -e "\nlist EAs: noise, size"
getfattr -d $file
echo "list all the EAs again: noise, size"
${ATTR_PROG} -l foo
echo -e "\nremove the size EA from foo"
setfattr -x user.size $file
echo "change the value of the size EA from small to huge"
${ATTR_PROG} -s size -V huge foo
echo -e "\nlist EAs: noise (size EA has been removed)"
getfattr -d $file
echo "get the size EA which should now have value huge"
${ATTR_PROG} -g size foo
echo -e "\ntry removing non-existent EA named woof"
setfattr -x user.woof $file
echo "list EAs: noise, size"
${ATTR_PROG} -l foo
echo -e "\ntry removing already removed EA size"
setfattr -x user.size $file
echo "remove the size EA from foo"
${ATTR_PROG} -r size foo
echo -e "\nlist EAs: noise"
getfattr -d $file
echo "list EAs: noise (size EA has been removed)"
${ATTR_PROG} -l foo
echo -e "\ntry removing already removed EA colour"
setfattr -x user.colour $file
echo "get the noise EA: woof"
${ATTR_PROG} -g noise foo
echo -e "\nlist EAs: noise"
getfattr -d $file
echo "try removing non-existent EA named woof"
${ATTR_PROG} -r woof foo
echo -e "\nremove remaining EA noise"
setfattr -x user.noise $file
echo "try removing already removed EA size"
${ATTR_PROG} -r size foo
echo -e "\nlist EAs: should be no EAs left now"
getfattr -d $file
echo "list EAs: noise"
${ATTR_PROG} -l foo
echo -e "\nunmount the FS and see if EAs are persistent"
_test_cycle_mount
echo "try removing already removed EA colour"
${ATTR_PROG} -r colour foo
echo -e "\nlist EAs: should still be no EAs left"
getfattr -d $file
echo "list EAs: noise"
${ATTR_PROG} -l foo
echo -e "\n*** Test out the trusted namespace ***"
echo "remove remaining EA noise"
${ATTR_PROG} -r noise foo
echo -e "\nset EA <trusted:colour,marone>:"
setfattr -n trusted.colour -v marone $file
echo "list EAs: should be no EAs left now"
${ATTR_PROG} -l foo
echo -e "\nset EA <user:colour,beige>:"
setfattr -n user.colour -v beige $file
echo "unmount the FS and see if EAs are persistent"
_umount_and_mount
echo -e "\nset EA <user:vomit,pizza>:"
setfattr -n user.vomit -v pizza $file
echo "list EAs: should still be no EAs left"
${ATTR_PROG} -l foo
echo -e "\nset EA <trusted:noise,whack>:"
setfattr -n trusted.noise -v whack $file
echo ""
echo "*** Test out the root namespace ***"
echo ""
echo -e "\nlist trusted EAs: <trusted:colour,noise>:"
getfattr -d -m '^trusted\.' $file
echo "set EA <root:colour,marone>:"
${ATTR_PROG} -R -s colour -V marone foo
echo -e "\nlist user EAs: <user:colour,vomit>:"
getfattr -d $file
echo "set EA <user:colour,beige>:"
${ATTR_PROG} -s colour -V beige foo
echo -e "\nget trusted EA colour: marone"
getfattr -n trusted.colour $file
echo "set EA <user:vomit,pizza>:"
${ATTR_PROG} -s vomit -V pizza foo
echo -e "\nget trusted EA noise: whack"
getfattr -n trusted.noise $file
echo "set EA <root:noise,whack>:"
${ATTR_PROG} -R -s noise -V whack foo
echo -e "\nget trusted EA vomit which is a user EA => find nothing"
getfattr -n trusted.vomit $file
echo "list root EAs: <root:colour,noise>:"
${ATTR_PROG} -R -l foo
echo -e "\nunmount the FS and see if EAs are persistent"
_test_cycle_mount
echo "list user EAs: <user:colour,vomit>:"
${ATTR_PROG} -l foo
echo -e "\nget trusted EA colour: marone"
getfattr -n trusted.colour $file
echo "get root EA colour: marone"
${ATTR_PROG} -R -g colour foo
echo -e "\nget trusted EA noise: whack"
getfattr -n trusted.noise $file
echo "get root EA noise: whack"
${ATTR_PROG} -R -g noise foo
echo -e "\nget user EA vomit: pizza"
getfattr -n user.vomit $file
echo "get root EA vomit which is a user EA => find nothing"
${ATTR_PROG} -R -g vomit foo
echo -e "\nremove the trusted colour EA"
setfattr -x trusted.colour $file
echo ""
echo "unmount the FS and see if EAs are persistent"
echo ""
_umount_and_mount
echo -e "\nlist trusted EAs: <trusted:noise>:"
getfattr -d -m '^trusted\.' $file
echo "get root EA colour: marone"
${ATTR_PROG} -R -g colour foo
echo -e "\nlist user EAs: <user:colour,vomit>:"
getfattr -d $file
echo "get root EA noise: whack"
${ATTR_PROG} -R -g noise foo
echo -e "\nremove the final trusted EA noise"
setfattr -x trusted.noise $file
echo "get user EA vomit: pizza"
${ATTR_PROG} -g vomit foo
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 /
echo -e "\nlist trusted EAs: none"
getfattr -d -m '^trusted\.' $file
# success, all done
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
095 auto rw stress
096 auto prealloc quick zero
097 udf auto
097 attr auto quick
098 auto quick metadata
099 udf auto
100 udf auto