summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2009-02-23 03:15:50 +0100
committerAndreas Gruenbacher <agruen@suse.de>2009-02-23 03:25:26 +0100
commit6ac9ad9a2ceefcbf4c30ed2d0dc259c8edfe5072 (patch)
tree9cce5589e85e561d821d7a935a7807b4b2945aa3
parentaeaf2d577c10f42dbc21e8d7370ee9cf37e5667e (diff)
downloadattr-6ac9ad9a2ceefcbf4c30ed2d0dc259c8edfe5072.tar.gz
Add a small script for sorting the getfattr output
Instead of using grep and sort, use a small perl script for sorting the getfattr output. That way, the test remains more obvious. This reverts commit aeaf2d577c10f42dbc21e8d7370ee9cf37e5667e.
-rw-r--r--test/attr.test81
-rw-r--r--test/root/getfattr.test58
-rwxr-xr-xtest/sort-getfattr-output4
3 files changed, 121 insertions, 22 deletions
diff --git a/test/attr.test b/test/attr.test
index dfb065a..d501862 100644
--- a/test/attr.test
+++ b/test/attr.test
@@ -135,7 +135,7 @@ Test extended attribute block sharing
$ touch f g h
$ setfattr -n user.novalue f g h
- $ getfattr f g h
+ $ getfattr f g h | ../sort-getfattr-output
> # file: f
> user.novalue
>
@@ -147,7 +147,7 @@ Test extended attribute block sharing
>
$ setfattr -n user.name -v value f
- $ getfattr f g h
+ $ getfattr f g h | ../sort-getfattr-output
> # file: f
> user.name
> user.novalue
@@ -159,7 +159,7 @@ Test extended attribute block sharing
> user.novalue
>
- $ getfattr -d f g h
+ $ getfattr -d f g h | ../sort-getfattr-output
> # file: f
> user.name="value"
> user.novalue
@@ -172,7 +172,7 @@ Test extended attribute block sharing
>
$ setfattr -n user.name -v value g
- $ getfattr f g h
+ $ getfattr f g h | ../sort-getfattr-output
> # file: f
> user.name
> user.novalue
@@ -186,7 +186,7 @@ Test extended attribute block sharing
>
$ setfattr -x user.novalue h
- $ getfattr f g h
+ $ getfattr f g h | ../sort-getfattr-output
> # file: f
> user.name
> user.novalue
@@ -207,7 +207,7 @@ Attributes of symlinks vs. the files pointed to
$ setfattr -h -n user.filename -v l l
> setfattr: l: Operation not permitted
- $ getfattr -d f l
+ $ getfattr -d f l | ../sort-getfattr-output
> # file: f
> user.filename="l"
>
@@ -264,14 +264,29 @@ Tests for proper path recursion reported by Tony Ernst <tee@sgi.com> bnc#457660
$ setfattr -n "user.9" 1/2/3
$ setfattr -n "user.a" 1/2/3
- $ getfattr -h -L -R 1 | grep file: | sort
+ $ getfattr -h -L -R -m '.' -e hex 1 | ./sort-getfattr-output
> # file: 1
+ > user.9
+ > user.a
+ >
> # file: 1/2
+ > user.9
+ > user.a
+ >
> # file: 1/2/3
+ > user.9
+ > user.a
+ >
- $ getfattr -h -P -R 1/2 | grep file: | sort
+ $ getfattr -h -P -R -m '.' -e hex 1/2 | ./sort-getfattr-output
> # file: 1/2
+ > user.9
+ > user.a
+ >
> # file: 1/2/3
+ > user.9
+ > user.a
+ >
$ rm -R 1
@@ -287,34 +302,74 @@ Test for proper recursion of directory structures with -L -P -R
$ setfattr -n "user.a" 1/link
$ setfattr -n "user.a" 1/sub/sub-file
$ setfattr -n "user.a" 1/sub
- $ getfattr -P -R 1 | grep file: | sort
+ $ getfattr -P -R 1 | ./sort-getfattr-output
> # file: 1
+ > user.a
+ >
> # file: 1/link
+ > user.a
+ >
> # file: 1/link/link-file
+ > user.a
+ >
> # file: 1/sub
+ > user.a
+ >
> # file: 1/sub/link
+ > user.a
+ >
> # file: 1/sub/sub-file
+ > user.a
+ >
- $ getfattr -R -P 1/sub | grep file: | sort
+ $ getfattr -R -P 1/sub | ./sort-getfattr-output
> # file: 1/sub
+ > user.a
+ >
> # file: 1/sub/link
+ > user.a
+ >
> # file: 1/sub/sub-file
+ > user.a
+ >
- $ getfattr -L -R 1 | grep file: | sort
+ $ getfattr -L -R 1 | ./sort-getfattr-output
> # file: 1
+ > user.a
+ >
> # file: 1/link
+ > user.a
+ >
> # file: 1/link/link-file
+ > user.a
+ >
> # file: 1/sub
+ > user.a
+ >
> # file: 1/sub/link
+ > user.a
+ >
> # file: 1/sub/link/link-file
+ > user.a
+ >
> # file: 1/sub/sub-file
+ > user.a
+ >
- $ getfattr -R 1/sub/link | grep file: | sort
+ $ getfattr -R 1/sub/link | ./sort-getfattr-output
> # file: 1/sub/link
+ > user.a
+ >
> # file: 1/sub/link/link-file
+ > user.a
+ >
- $ getfattr -L -R 1/sub/link | grep file: | sort
+ $ getfattr -L -R 1/sub/link | ./sort-getfattr-output
> # file: 1/sub/link
+ > user.a
+ >
> # file: 1/sub/link/link-file
+ > user.a
+ >
$ rm -R 1
diff --git a/test/root/getfattr.test b/test/root/getfattr.test
index aaa6d9a..c9458e6 100644
--- a/test/root/getfattr.test
+++ b/test/root/getfattr.test
@@ -25,59 +25,99 @@ With -h, we do not dereference symlinks:
>
Do the same for symlinks we find in a directory hierarchy:
- $ getfattr -m- -Rd . | grep file: | sort
+ $ getfattr -m- -Rd .
> # file: f
+ > user.test="test"
+ >
> # file: l
+ > user.test="test"
+ >
- $ getfattr -m- -Rhd . | grep file: | sort
+ $ getfattr -m- -Rhd .
> # file: f
+ > user.test="test"
+ >
> # file: l
+ > trusted.test="test"
+ >
Make sure we follow symlinks on the command line only when we should:
$ ln -s . here
- $ getfattr -m- -Rd here | grep file: | sort
+ $ getfattr -m- -Rd here
> # file: here/f
+ > user.test="test"
+ >
> # file: here/l
+ > user.test="test"
+ >
- $ getfattr -m- -Rhd here | grep file: | sort
+ $ getfattr -m- -Rhd here
> # file: here/f
+ > user.test="test"
+ >
> # file: here/l
+ > trusted.test="test"
+ >
- $ getfattr -m- -RLhd here | grep file: | sort
+ $ getfattr -m- -RLhd here
> # file: here/f
+ > user.test="test"
+ >
> # file: here/l
+ > trusted.test="test"
+ >
$ getfattr -m- -RPhd here
Make sure we recurse into sub-directories:
$ mkdir sub
$ mv f l sub
- $ getfattr -m- -Rd . | grep file: | sort
+ $ getfattr -m- -Rd .
> # file: sub/f
+ > user.test="test"
+ >
> # file: sub/l
+ > user.test="test"
+ >
- $ getfattr -m- -Rhd . | grep file: | sort
+ $ getfattr -m- -Rhd .
> # file: sub/f
+ > user.test="test"
+ >
> # file: sub/l
+ > trusted.test="test"
+ >
Make sure we follow symlinks to directories only when we should:
$ mkdir sub2
$ ln -s ../sub sub2/to-sub
$ getfattr -m- -Rhd sub2
- $ getfattr -m- -RLhd sub2 | grep file: | sort
+ $ getfattr -m- -RLhd sub2
> # file: sub2/to-sub/f
+ > user.test="test"
+ >
> # file: sub2/to-sub/l
+ > trusted.test="test"
+ >
$ getfattr -m- -RPhd sub2
Symlink loop detection:
$ ln -s .. sub/up
- $ getfattr -m- -RLhd . | grep file: | sort
+ $ getfattr -m- -RLhd .
> # file: sub2/to-sub/f
+ > user.test="test"
+ >
> # file: sub2/to-sub/l
+ > trusted.test="test"
+ >
> # file: sub/f
+ > user.test="test"
+ >
> # file: sub/l
+ > trusted.test="test"
+ >
$ cd ..
$ rm -rf d
diff --git a/test/sort-getfattr-output b/test/sort-getfattr-output
new file mode 100755
index 0000000..9901ed3
--- /dev/null
+++ b/test/sort-getfattr-output
@@ -0,0 +1,4 @@
+#! /usr/bin/perl -w
+
+undef $/;
+print join("\n\n", sort split(/\n\n/, <>)), "\n\n";