062: Sort recursive getfattr output
authorEric Sandeen <sandeen@sandeen.net>
Fri, 27 Jan 2012 18:28:20 +0000 (12:28 -0600)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 27 Jan 2012 18:28:20 +0000 (12:28 -0600)
Test 062 was made "generic" a while back, but it fails on any filesystem
which returns getfattr -R results (aka readdir results) in something
other than inode-order.

With a little awk-fu we can sort the records from getfattr -R so that
the output is the same for xfs as well as ext4, etc.

Also filter out lost+found which extN creates at mkfs time, but
some other filesystems do not.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
062
062.out
common.attr

diff --git a/062 b/062
index f666e1bc955d541aa1608fb4edfff9b9a2770701..9800e33b388f7894789949890d292526855e8b1c 100755 (executable)
--- a/062
+++ b/062
@@ -67,7 +67,7 @@ _create_test_bed()
        mknod $SCRATCH_MNT/dev/c c 0 0
        mknod $SCRATCH_MNT/dev/p p
        # sanity check
-       find $SCRATCH_MNT | LC_COLLATE=POSIX sort | _filter_scratch
+       find $SCRATCH_MNT | LC_COLLATE=POSIX sort | _filter_scratch | grep -v "lost+found"
 }
 
 # real QA test starts here
@@ -160,18 +160,18 @@ _extend_test_bed()
        # whack a symlink in the middle, just to be difficult
        ln -s $SCRATCH_MNT/here/up $SCRATCH_MNT/descend/and
        # dump out our new starting point
-       find $SCRATCH_MNT | LC_COLLATE=POSIX sort | _filter_scratch
+       find $SCRATCH_MNT | LC_COLLATE=POSIX sort | _filter_scratch | grep -v "lost+found"
 }
 
 _extend_test_bed
 
 echo
 echo "*** directory descent with us following symlinks"
-getfattr -h -L -R -m '.' -e hex $SCRATCH_MNT
+getfattr -h -L -R -m '.' -e hex $SCRATCH_MNT | _sort_getfattr_output
 
 echo
 echo "*** directory descent without following symlinks"
-getfattr -h -P -R -m '.' -e hex $SCRATCH_MNT
+getfattr -h -P -R -m '.' -e hex $SCRATCH_MNT | _sort_getfattr_output
 
 
 # 
diff --git a/062.out b/062.out
index 699254a326234d9e347b96657b7d214e9616cb32..8cc3c65533e4c88f09bed0fc2b297143c2f9a464 100644 (file)
--- a/062.out
+++ b/062.out
@@ -508,21 +508,21 @@ SCRATCH_MNT/lnk
 SCRATCH_MNT/reg
 
 *** directory descent with us following symlinks
-# file: SCRATCH_MNT/reg
-trusted.name=0xbabe
-trusted.name3=0xdeface
-user.name=0xbabe
-user.name3=0xdeface
+# file: SCRATCH_MNT/descend
+user.1=0x3233
+user.x=0x797a
 
-# file: SCRATCH_MNT/dir
-trusted.name=0xbabe
-trusted.name3=0xdeface
-user.name=0xbabe
-user.name3=0xdeface
+# file: SCRATCH_MNT/descend/and/ascend
+trusted.9=0x3837
+trusted.a=0x6263
 
-# file: SCRATCH_MNT/lnk
-trusted.name=0xbabe
-trusted.name3=0xdeface
+# file: SCRATCH_MNT/descend/down
+user.1=0x3233
+user.x=0x797a
+
+# file: SCRATCH_MNT/descend/down/here
+user.1=0x3233
+user.x=0x797a
 
 # file: SCRATCH_MNT/dev/b
 trusted.name=0xbabe
@@ -536,6 +536,12 @@ trusted.name3=0xdeface
 trusted.name=0xbabe
 trusted.name3=0xdeface
 
+# file: SCRATCH_MNT/dir
+trusted.name=0xbabe
+trusted.name3=0xdeface
+user.name=0xbabe
+user.name3=0xdeface
+
 # file: SCRATCH_MNT/here
 trusted.9=0x3837
 trusted.a=0x6263
@@ -548,6 +554,18 @@ trusted.a=0x6263
 trusted.9=0x3837
 trusted.a=0x6263
 
+# file: SCRATCH_MNT/lnk
+trusted.name=0xbabe
+trusted.name3=0xdeface
+
+# file: SCRATCH_MNT/reg
+trusted.name=0xbabe
+trusted.name3=0xdeface
+user.name=0xbabe
+user.name3=0xdeface
+
+
+*** directory descent without following symlinks
 # file: SCRATCH_MNT/descend
 user.1=0x3233
 user.x=0x797a
@@ -560,28 +578,6 @@ user.x=0x797a
 user.1=0x3233
 user.x=0x797a
 
-# file: SCRATCH_MNT/descend/and/ascend
-trusted.9=0x3837
-trusted.a=0x6263
-
-
-*** directory descent without following symlinks
-# file: SCRATCH_MNT/reg
-trusted.name=0xbabe
-trusted.name3=0xdeface
-user.name=0xbabe
-user.name3=0xdeface
-
-# file: SCRATCH_MNT/dir
-trusted.name=0xbabe
-trusted.name3=0xdeface
-user.name=0xbabe
-user.name3=0xdeface
-
-# file: SCRATCH_MNT/lnk
-trusted.name=0xbabe
-trusted.name3=0xdeface
-
 # file: SCRATCH_MNT/dev/b
 trusted.name=0xbabe
 trusted.name3=0xdeface
@@ -594,6 +590,12 @@ trusted.name3=0xdeface
 trusted.name=0xbabe
 trusted.name3=0xdeface
 
+# file: SCRATCH_MNT/dir
+trusted.name=0xbabe
+trusted.name3=0xdeface
+user.name=0xbabe
+user.name3=0xdeface
+
 # file: SCRATCH_MNT/here
 trusted.9=0x3837
 trusted.a=0x6263
@@ -606,17 +608,15 @@ trusted.a=0x6263
 trusted.9=0x3837
 trusted.a=0x6263
 
-# file: SCRATCH_MNT/descend
-user.1=0x3233
-user.x=0x797a
-
-# file: SCRATCH_MNT/descend/down
-user.1=0x3233
-user.x=0x797a
+# file: SCRATCH_MNT/lnk
+trusted.name=0xbabe
+trusted.name3=0xdeface
 
-# file: SCRATCH_MNT/descend/down/here
-user.1=0x3233
-user.x=0x797a
+# file: SCRATCH_MNT/reg
+trusted.name=0xbabe
+trusted.name3=0xdeface
+user.name=0xbabe
+user.name3=0xdeface
 
 
 
index 37d09279a38627fe4ab96e38c0283a9f6c8d74cf..7f1ddf06d3efe3ba920b4cd8b98a48ff3cc9bdab 100644 (file)
@@ -176,5 +176,12 @@ _require_attrs()
     rm -f $TEST_DIR/syscalltest.out
 }
 
+# getfattr -R returns info in readdir order which varies from fs to fs.
+# This sorts the output by filename
+_sort_getfattr_output()
+{
+    awk '{a[FNR]=$0}END{n = asort(a); for(i=1; i <= n; i++) print a[i]"\n"}' RS=''
+}
+
 # make sure this script returns success
 /bin/true