parent-perm: avoid a bizarre test failure.
authorJim Meyering <meyering@redhat.com>
Tue, 8 Jan 2008 14:50:51 +0000 (15:50 +0100)
committerJim Meyering <meyering@redhat.com>
Tue, 8 Jan 2008 14:53:29 +0000 (15:53 +0100)
* tests/cp/parent-perm: Accommodate the situation in which
chmod ("dir", 02755) returns 0 yet fails to set the S_ISGID bit.

ChangeLog
tests/cp/parent-perm

index c38ab73..e834634 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2008-01-08  Jim Meyering  <meyering@redhat.com>
 
+       parent-perm: avoid a bizarre test failure.
+       * tests/cp/parent-perm: Accommodate the situation in which
+       chmod ("dir", 02755) returns 0 yet fails to set the S_ISGID bit.
+
        Remove uses of now-undefined Makefile variable.
        * src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): Remove uses
        of no-longer-defined variable, $(LIB_ACL_TRIVIAL).
index 1c7a222..cedcac4 100755 (executable)
@@ -33,6 +33,15 @@ cp -p --parent a/b/d/foo e || fail=1
 
 # Ensure that permissions on just-created directory, e/a/,
 # are the same as those on original, a/.
-test $(stat --printf %A a) = $(stat --printf %A e/a) || fail=1
+
+# The sed filter maps any 's' from an inherited set-GID bit
+# to the usual 'x'.  Otherwise, under unusual circumstances, this
+# test would fail with e.g., drwxr-sr-x != drwxr-xr-x .
+# For reference, the unusual circumstances is: build dir is set-gid,
+# so "a/" inherits that.  However, when the user does not belong to
+# the group of the build directory, chmod ("a/e", 02755) returns 0,
+# yet fails to set the S_ISGID bit.
+test $(stat --printf %A a|sed s/s/x/g) = $(stat --printf %A e/a|sed s/s/x/g) ||
+  fail=1
 
 (exit $fail); exit $fail