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 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 2 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, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 if test "$VERBOSE" = yes; then
27 . $srcdir/../envvar-check
28 . $srcdir/../lang-default
31 t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
32 trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0
33 trap '(exit $?); exit' 1 2 13 15
36 mkdir -p $tmp || framework_failure=1
37 cd $tmp || framework_failure=1
38 touch a || framework_failure=1
39 ln a b || framework_failure=1
40 mkdir c || framework_failure=1
41 cp -d a b c || framework_failure=1
42 test -f c/a || framework_failure=1
43 test -f c/b || framework_failure=1
45 if test $framework_failure = 1; then
46 echo 'failure in testing framework' 1>&2
52 a_inode=`ls -i c/a|sed 's,c/.*,,'`
53 b_inode=`ls -i c/b|sed 's,c/.*,,'`
54 test "$a_inode" = "$b_inode" || fail=1
55 # --------------------------------------
61 cp --preserve=links -R -H a b c
62 a_inode=`ls -i c/a|sed 's,c/.*,,'`
63 b_inode=`ls -i c/b|sed 's,c/.*,,'`
64 test "$a_inode" = "$b_inode" || fail=1
65 # --------------------------------------
69 (cd d; touch a; ln -s a b)
70 cp --preserve=links -R -L 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 --no-preserve=links works.
79 (cd d; touch a; ln a b)
80 cp -dR --no-preserve=links d c
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 -d still preserves hard links.
91 a_inode=`ls -i c/a|sed 's,c/.*,,'`
92 b_inode=`ls -i c/b|sed 's,c/.*,,'`
93 test "$a_inode" = "$b_inode" || fail=1
94 # --------------------------------------
96 # Ensure that --no-preserve=mode works
100 cp -a --no-preserve=mode a b
101 set _ `ls -l b`; shift; mode=$1
102 test "$mode" = "-rwx------" || fail=1
104 # --------------------------------------
106 (exit $fail); exit $fail