2 # Make sure the permission-preserving code in copy.c (mv, cp, install) works.
4 # Copyright (C) 2000, 2002, 2004, 2005 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 . $srcdir/../very-expensive
23 if test "$VERBOSE" = yes; then
29 . $srcdir/../envvar-check
32 t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
33 trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
34 trap '(exit $?); exit' 1 2 13 15
37 mkdir -p $tmp || framework_failure=1
38 cd $tmp || framework_failure=1
42 if test $framework_failure = 1; then
43 echo 'failure in testing framework'
49 # Now, try it with `mv', with combinations of --force, no-f and
50 # existing-destination and not.
54 for cmd in mv 'cp -p' cp; do
55 for force in '' -f; do
56 for existing_dest in yes no; do
57 for g_perm in r w x rw wx xr rwx; do
58 for o_perm in r w x rw wx xr rwx; do
60 chmod u=r,g=rx,o= src || exit 1
65 test $existing_dest = yes && {
67 chmod u=rw,g=$g_perm,o=$o_perm dest || exit 1
69 $cmd $force src dest || exit 1
70 test "$cmd" = mv && test -f src && exit 1
71 test "$cmd" = cp && { test -f src || exit 1; }
75 case "$cmd:$force:$existing_dest" in
77 _g_perm=`echo rwx|sed 's/[^'$g_perm']/-/g'`
78 _o_perm=`echo rwx|sed 's/[^'$o_perm']/-/g'`
79 expected_perms=-rw-$_g_perm$_o_perm
83 expected_perms=`echo $expected_perms|sed 's/.....$/-----/'`
85 expected_perms=`echo $expected_perms|sed 's/..\(..\).$/--\1-/'`
88 test _$1 = _$expected_perms || exit 1
89 # Perform only one iteration when there's no existing destination.
90 test $existing_dest = no && break 3
98 (exit $fail); exit $fail