2 # Make sure the permission-preserving code in copy.c (mv, cp, install) works.
4 # Copyright (C) 2000, 2002, 2004-2009 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 3 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, see <http://www.gnu.org/licenses/>.
19 if test "$VERBOSE" = yes; then
32 # Now, try it with `mv', with combinations of --force, no-f and
33 # existing-destination and not.
37 for cmd
in mv 'cp -p' cp; do
38 for force
in '' -f; do
39 for existing_dest
in yes no
; do
40 for g_perm
in r w x rw wx xr rwx
; do
41 for o_perm
in r w x rw wx xr rwx
; do
43 chmod u
=r
,g
=rx
,o
= src ||
exit 1
44 expected_perms
=$
(stat
--format=%A src
)
46 test $existing_dest = yes && {
48 chmod u
=rw
,g
=$g_perm,o
=$o_perm dest ||
exit 1
50 $cmd $force src dest ||
exit 1
51 test "$cmd" = mv && test -f src
&& exit 1
52 test "$cmd" = cp && { test -f src ||
exit 1; }
53 actual_perms
=$
(stat
--format=%A dest
)
55 case "$cmd:$force:$existing_dest" in
57 _g_perm
=`echo rwx|sed 's/[^'$g_perm']/-/g'`
58 _o_perm
=`echo rwx|sed 's/[^'$o_perm']/-/g'`
59 expected_perms
=-rw-$_g_perm$_o_perm
63 expected_perms
=`echo $expected_perms|sed 's/.....$/-----/'`
65 expected_perms
=`echo $expected_perms|sed 's/..\(..\).$/--\1-/'`
68 test _
$actual_perms = _
$expected_perms ||
exit 1
69 # Perform only one iteration when there's no existing destination.
70 test $existing_dest = no
&& break 3