diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2011-10-10 13:54:08 +0100 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2011-10-10 13:54:08 +0100 |
commit | 1e9d1410e355d8ad0ab1cdcc12c396e0670882c0 (patch) | |
tree | 93240faae9f8cbcbf4af748f08363f2a91ca37b3 /tests/test_lib.sh | |
parent | 665beee6012505d0a3e54cc06f73ef21884e889d (diff) | |
download | tbdiff-1e9d1410e355d8ad0ab1cdcc12c396e0670882c0.tar.gz |
Added test for extended attributes
Diffstat (limited to 'tests/test_lib.sh')
-rw-r--r-- | tests/test_lib.sh | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/tests/test_lib.sh b/tests/test_lib.sh index e95759d..eb66c9e 100644 --- a/tests/test_lib.sh +++ b/tests/test_lib.sh @@ -21,12 +21,12 @@ check_same_mode () { test $(stat -c "%f" $1) = $(stat -c "%f" $2) } -# check_content FILE EXPECTED_OCTAL_PERMISSIONS +# check_perm FILE EXPECTED_OCTAL_PERMISSIONS check_perm () { test $(stat -c %a $1) = $2 } -# check_content FILE EXPECTED_OCTAL_PERMISSIONS +# check_symlink FILE EXPECTED_PATH check_symlink () { test $(readlink $1) = $2 } @@ -41,6 +41,31 @@ check_group () { test $(stat -c %G $1) = $2 } +# check_xattrs FILE1 FILE2 +# check that two files have the same attributes +check_xattrs () { + test "`getfattr --dump --encoding=base64 $1 | tail -n +2`" = \ + "`getfattr --dump --encoding=base64 $2 | tail -n +2`" +} + +# check_xattr_exists FILE KEY +check_xattr_exists () { + # attr doesn't use user. prefix, but getfattr returns 0 on non-existant + noprefix=`echo $2 | sed s/user.//` + attr -g $2 $1 >dev/null 2>/dev/null +} + +# xattr_get FILE KEY +xattr_get () { + getfattr --only-values --name=$2 $1 +} + +# check_xattr_value FILE KEY VALUE +check_xattr_value () { + check_xattr_exists && + test "`xattr_get $1 $2`" = "$3" +} + # tests whether a command exists is_command () { type $1 >/dev/null 2>/dev/null |