]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: add a test of cp --preserve=links
authorJim Meyering <meyering@redhat.com>
Wed, 19 Nov 2008 18:16:34 +0000 (19:16 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 20 Nov 2008 09:21:52 +0000 (10:21 +0100)
* tests/cp/link-preserve: Add a case and comments.

tests/cp/link-preserve

index 309c05121734d5cf0ae417c695f4e573e9a4ee87..fbde3ffe72773e2ae109e0d25719a3b957f095e4 100755 (executable)
@@ -48,9 +48,17 @@ b_inode=`ls -i c/b|sed 's,c/.*,,'`
 test "$a_inode" = "$b_inode" || fail=1
 # --------------------------------------
 
-rm -rf a b c d
-mkdir d
-(cd d; touch a; ln -s a b)
+# Ensure that -L makes cp follow the b->a symlink
+# and translates to hard-linked a and b in the destination dir.
+rm -rf a b c d; mkdir d; (cd d; touch a; ln -s a b)
+cp --preserve=links -R -L d c
+a_inode=`ls -i c/a|sed 's,c/.*,,'`
+b_inode=`ls -i c/b|sed 's,c/.*,,'`
+test "$a_inode" = "$b_inode" || fail=1
+# --------------------------------------
+
+# Same as above, but starting with a/b hard linked.
+rm -rf a b c d; mkdir d; (cd d; touch a; ln a b)
 cp --preserve=links -R -L d c
 a_inode=`ls -i c/a|sed 's,c/.*,,'`
 b_inode=`ls -i c/b|sed 's,c/.*,,'`
@@ -58,9 +66,7 @@ test "$a_inode" = "$b_inode" || fail=1
 # --------------------------------------
 
 # Ensure that --no-preserve=links works.
-rm -rf a b c d
-mkdir d
-(cd d; touch a; ln a b)
+rm -rf a b c d; mkdir d; (cd d; touch a; ln a b)
 cp -dR --no-preserve=links d c
 a_inode=`ls -i c/a|sed 's,c/.*,,'`
 b_inode=`ls -i c/b|sed 's,c/.*,,'`