2 # ensure that `cp -d' preserves hard-links between command line arguments
3 # ensure that --preserve=links works with -RH and -RL
5 # Copyright (C) 2001, 2002, 2004, 2006-2009 Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if test "$VERBOSE" = yes; then
27 touch a || framework_failure
28 ln a b || framework_failure
29 mkdir c || framework_failure
30 cp -d a b c || framework_failure
31 test -f c
/a || framework_failure
32 test -f c
/b || framework_failure
36 a_inode
=`ls -i c/a|sed 's,c/.*,,'`
37 b_inode
=`ls -i c/b|sed 's,c/.*,,'`
38 test "$a_inode" = "$b_inode" || fail
=1
39 # --------------------------------------
45 cp --preserve=links
-R -H a b c
46 a_inode
=`ls -i c/a|sed 's,c/.*,,'`
47 b_inode
=`ls -i c/b|sed 's,c/.*,,'`
48 test "$a_inode" = "$b_inode" || fail
=1
49 # --------------------------------------
51 # Ensure that -L makes cp follow the b->a symlink
52 # and translates to hard-linked a and b in the destination dir.
53 rm -rf a b c d
; mkdir d
; (cd d
; touch a
; ln -s a b
)
54 cp --preserve=links
-R -L d c
55 a_inode
=`ls -i c/a|sed 's,c/.*,,'`
56 b_inode
=`ls -i c/b|sed 's,c/.*,,'`
57 test "$a_inode" = "$b_inode" || fail
=1
58 # --------------------------------------
60 # Same as above, but starting with a/b hard linked.
61 rm -rf a b c d
; mkdir d
; (cd d
; touch a
; ln a b
)
62 cp --preserve=links
-R -L d c
63 a_inode
=`ls -i c/a|sed 's,c/.*,,'`
64 b_inode
=`ls -i c/b|sed 's,c/.*,,'`
65 test "$a_inode" = "$b_inode" || fail
=1
66 # --------------------------------------
68 # Ensure that --no-preserve=links works.
69 rm -rf a b c d
; mkdir d
; (cd d
; touch a
; ln a b
)
70 cp -dR --no-preserve=links d c
71 a_inode
=`ls -i c/a|sed 's,c/.*,,'`
72 b_inode
=`ls -i c/b|sed 's,c/.*,,'`
73 test "$a_inode" = "$b_inode" && fail
=1
74 # --------------------------------------
76 # Ensure that -d still preserves hard links.
81 a_inode
=`ls -i c/a|sed 's,c/.*,,'`
82 b_inode
=`ls -i c/b|sed 's,c/.*,,'`
83 test "$a_inode" = "$b_inode" || fail
=1
84 # --------------------------------------
86 # Ensure that --no-preserve=mode works
90 cp -a --no-preserve=mode a b
91 mode
=`ls -l b|cut -b-10`
92 test "$mode" = "-rwx------" || fail
=1
94 # --------------------------------------