]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Accommodate FreeBSD 6.1 hard-link-to-symlink differences.
authorJim Meyering <meyering@redhat.com>
Thu, 1 Nov 2007 10:59:08 +0000 (11:59 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 1 Nov 2007 10:59:08 +0000 (11:59 +0100)
* tests/cp/same-file: Detect when linking to a symlink links to
the target of the symlink (FreeBSD 6.1 does this, Linux does not),
and skip the few tests that would otherwise fail.
Redirect output of final comparison to stderr, since all stdout
is already redirected.

ChangeLog
tests/cp/same-file

index 7ca39e57b3d893a57d35a8cbfc69af87ff75a2a4..397fc11237e562d40d2d3d404804c060ec29f359 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-11-01  Jim Meyering  <meyering@redhat.com>
+
+       Accommodate FreeBSD 6.1 hard-link-to-symlink differences.
+       * tests/cp/same-file: Detect when linking to a symlink links to
+       the target of the symlink (FreeBSD 6.1 does this, Linux does not),
+       and skip the few tests that would otherwise fail.
+       Redirect output of final comparison to stderr, since all stdout
+       is already redirected.
+
 2007-10-31  Jim Meyering  <meyering@redhat.com>
 
        Fix a "make distcheck" failure.
index 7bf6da85388f74eb7c3092c175f0387b6c9c5d3c..908573ad3bc56384aa65d74d7df8b6e7076ce9bd 100755 (executable)
@@ -32,6 +32,19 @@ fi
 
 VERSION_CONTROL=numbered; export VERSION_CONTROL
 
+# Determine whether a hard link to a symlink points to the symlink
+# itself or to its referent.  For example, the link from FreeBSD6.1
+# does dereference a symlink, but the one from Linux does not.
+ln -s no-such dangling-slink
+ln dangling-slink hard-link > /dev/null 2>&1 \
+  && hard_link_to_symlink_does_the_deref=no \
+  || hard_link_to_symlink_does_the_deref=yes
+rm -f no-such dangling-slink hard-link
+
+test $hard_link_to_symlink_does_the_deref = yes \
+    && remove_these_sed='/^0 -[bf]*l .*sl1 ->/d' \
+    || remove_these_sed='/^ELIDE NO TEST OUTPUT/d'
+
 actual=actual-$$
 expected=expected-$$
 
@@ -46,6 +59,9 @@ for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do
     case $args$options in
       # These tests are not portable.
       # They all involve making a hard link to a symbolic link.
+      # In the past, we've skipped the tests that are not portable,
+      # by doing "continue" here and eliminating the corresponding
+      # expected output lines below.  Don't do that anymore.
       'symlink foo'-dfl)
        continue;;
       'symlink foo'-bdl)
@@ -59,6 +75,18 @@ for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do
       'sl1 sl2'-dl)
        continue;;
     esac
+
+    # cont'd  Instead, skip them only on systems for which link does
+    # dereference a symlink.  Detect and skip such tests here.
+    case $hard_link_to_symlink_does_the_deref:$args:$options in
+      'yes:sl1 sl2:-fl')
+       continue ;;
+      'yes:sl1 sl2:-bl')
+       continue ;;
+      'yes:sl1 sl2:-bfl')
+       continue ;;
+    esac
+
     rm -rf dir
     mkdir dir
     cd dir
@@ -108,7 +136,7 @@ for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do
   echo
 done
 
-cat <<\EOF > $expected
+cat <<\EOF | sed "$remove_these_sed" > $expected
 1 [cp: `foo' and `symlink' are the same file] (foo symlink -> foo)
 1 -d [cp: `foo' and `symlink' are the same file] (foo symlink -> foo)
 1 -f [cp: `foo' and `symlink' are the same file] (foo symlink -> foo)
@@ -196,6 +224,6 @@ EOF
 
 fail=0;
 
-compare $expected $actual || fail=1
+compare $expected $actual 1>&2 || fail=1
 
 (exit $fail); exit $fail