2 # cp -R --parents dir-specified-with-trailing-slash/ other-dir
3 # would get a failed assertion.
5 # Copyright (C) 2000, 2002, 2004, 2005, 2006, 2007 Free Software
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 if test "$VERBOSE" = yes; then
31 t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
32 trap 'status=$?; cd "$pwd" && exec 1>&2; rm -rf $t0 && exit $status' 0
33 trap '(exit $?); exit' 1 2 13 15
37 # Record absolute path of srcdir and cd back to current dir.
38 cd $srcdir || framework_failure=1
40 cd "$pwd" || framework_failure=1
42 . $srcdir/../envvar-check
43 . $srcdir/../umask-check
45 mkdir -p $tmp || framework_failure=1
46 cd $tmp || framework_failure=1
48 . "$abs_srcdir/../setgid-check"
50 mkdir foo bar || framework_failure=1
51 mkdir -p a/b/c d e || framework_failure=1
52 touch f || framework_failure=1
54 if test $framework_failure = 1; then
55 echo 'failure in testing framework'
61 # With 4.0.37 and earlier (back to when?), this would fail
62 # with the failed assertion from dirname.c.
63 cp -R --parents foo/ bar || fail=1
65 # Exercise the make_path and re_protect code in cp.c.
66 # FIXME: compare verbose output with expected output.
67 cp --verbose -a --parents a/b/c d > /dev/null 2>&1 || fail=1
68 test -d d/a/b/c || fail=1
70 # With 6.7 and earlier, cp --parents f/g d would mistakenly create a
71 # directory d/f, even though f is a regular file.
72 cp --parents f/g d 2>/dev/null && fail=1
75 # Check that re_protect works.
77 cp -a --parents d/a/b/c e || fail=1
78 p=`ls -ld e/d|sed 's/ .*//'`; case $p in drwxr-xr-x);; *) fail=1;; esac
79 p=`ls -ld e/d/a|sed 's/ .*//'`; case $p in drwx-w--w-);; *) fail=1;; esac
80 p=`ls -ld e/d/a/b/c|sed 's/ .*//'`; case $p in drwxr-xr-x);; *) fail=1;; esac
82 (exit $fail); exit $fail