diff options
author | 2014-04-24 16:40:15 -0500 | |
---|---|---|
committer | 2014-04-24 17:06:00 -0500 | |
commit | 9485ba46bd622e328fe3557f94c38b77109e54fa (patch) | |
tree | a27ffedfdf8b5136118b50892be8c6026be39551 | |
parent | f7fccc4baf8b2105d7b832fdeb6c2eb28ace70be (diff) | |
download | pseudo-9485ba46bd622e328fe3557f94c38b77109e54fa.tar.gz pseudo-9485ba46bd622e328fe3557f94c38b77109e54fa.tar.bz2 pseudo-9485ba46bd622e328fe3557f94c38b77109e54fa.zip |
test/test-xattr.sh: Add test case for xattr
The test case is based on the simple test of doing:
touch foo
getfattr -d foo
setfattr -n "user.dummy" -v "test" foo
getfattr -d foo
# file: foo
user.dummy="test"
setfattr -n "security.dummy" -v "test" foo
getfattr -n "security.dummy" foo
If pseudo is not running, the first part should work as long as extended
attributes are enabled, but the attempt to set "security...."
should result in a failure similar to:
setfattr: foo: Operation not permitted
As long as pseudo is working properly, no errors should be reported, and
the data should come back with the same values as were originally set.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
-rwxr-xr-x | test/test-xattr.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/test-xattr.sh b/test/test-xattr.sh new file mode 100755 index 0000000..7d818d2 --- /dev/null +++ b/test/test-xattr.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Return vals: 2 - Unable to run xattr commands +# 1 - Invalid return value +# 0 - Pass + +touch f1 +attrs=`getfattr -d f1 | grep -v '^#'` +if [ -n "$attrs" ] +then + #echo "Fail, unexpected getfattr result '$attr'" + rm -f f1 + exit 1 +fi + +setfattr -n "user.dummy" -v "test_f1" f1 +if [ $? -ne 0 ] +then + #echo "Fail, unable to call setfattr" + rm -f f1 + exit 2 +fi + +attrs=`getfattr -d f1 | grep -v '^#'` +if [ "$attrs" != 'user.dummy="test_f1"' ] +then + #echo "Fail, unexpected getfattr result '$attr'" + rm -f f1 + exit 1 +fi + +setfattr -n "security.dummy" -v "test_f2" f1 +if [ $? -ne 0 ] +then + #echo "Fail, unable to call setfattr" + rm -f f1 + exit 2 +fi + +attrs=`getfattr -n "security.dummy" f1 | grep -v '^#'` +if [ "$attrs" != 'security.dummy="test_f2"' ] +then + #echo "Fail, unexpected getfattr result '$attr'" + rm -f f1 + exit 1 +fi + +#echo "Passed." +rm -f f1 +exit 0 |