diff options
Diffstat (limited to 'tests/cp/perm')
-rwxr-xr-x | tests/cp/perm | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/cp/perm b/tests/cp/perm new file mode 100755 index 000000000..b87c8fa5a --- /dev/null +++ b/tests/cp/perm @@ -0,0 +1,44 @@ +#!/bin/sh +# Make sure the permission-preserving code in copy.c (mv, cp, install) works. + +pwd=`pwd` +tmp=perm.$$ +trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0 +trap 'exit $?' 1 2 13 15 + +framework_failure=0 +mkdir $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +touch f || framework_failure=1 +chmod u=r,go= f || framework_failure=1 + +if test $framework_failure = 1; then + echo 'failure in testing framework' + exit 1 +fi + +fail=0 + +cp -p f f2 || fail=1 + +# Permissions on f2 must be `-r--------' + +set X `ls -l f2` +shift +test "$1" = -r-------- || fail=1 +chmod u+w,g=rwx f2 || fail=1 + +# Again, but with an existing target. +cp -p f f2 || fail=1 +set X `ls -l f2` +shift +test "$1" = -r-------- || fail=1 + +# Again, but with an existing target, and this time with `-f'. +cp -p -f f f2 || fail=1 +set X `ls -l f2` +shift +test "$1" = -r-------- || fail=1 + +(exit $fail); exit |